babylon.d.ts 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Adds the translation vector (using 3 floats) in the current matrix
  2943. * @param x defines the 1st component of the translation
  2944. * @param y defines the 2nd component of the translation
  2945. * @param z defines the 3rd component of the translation
  2946. * @returns the current updated matrix
  2947. */
  2948. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2949. /**
  2950. * Inserts the translation vector in the current matrix
  2951. * @param vector3 defines the translation to insert
  2952. * @returns the current updated matrix
  2953. */
  2954. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2955. /**
  2956. * Gets the translation value of the current matrix
  2957. * @returns a new Vector3 as the extracted translation from the matrix
  2958. */
  2959. getTranslation(): Vector3;
  2960. /**
  2961. * Fill a Vector3 with the extracted translation from the matrix
  2962. * @param result defines the Vector3 where to store the translation
  2963. * @returns the current matrix
  2964. */
  2965. getTranslationToRef(result: Vector3): Matrix;
  2966. /**
  2967. * Remove rotation and scaling part from the matrix
  2968. * @returns the updated matrix
  2969. */
  2970. removeRotationAndScaling(): Matrix;
  2971. /**
  2972. * Multiply two matrices
  2973. * @param other defines the second operand
  2974. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2975. */
  2976. multiply(other: DeepImmutable<Matrix>): Matrix;
  2977. /**
  2978. * Copy the current matrix from the given one
  2979. * @param other defines the source matrix
  2980. * @returns the current updated matrix
  2981. */
  2982. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2983. /**
  2984. * Populates the given array from the starting index with the current matrix values
  2985. * @param array defines the target array
  2986. * @param offset defines the offset in the target array where to start storing values
  2987. * @returns the current matrix
  2988. */
  2989. copyToArray(array: Float32Array, offset?: number): Matrix;
  2990. /**
  2991. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the matrix where to store the multiplication
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2997. /**
  2998. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2999. * @param other defines the second operand
  3000. * @param result defines the array where to store the multiplication
  3001. * @param offset defines the offset in the target array where to start storing values
  3002. * @returns the current matrix
  3003. */
  3004. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3005. /**
  3006. * Check equality between this matrix and a second one
  3007. * @param value defines the second matrix to compare
  3008. * @returns true is the current matrix and the given one values are strictly equal
  3009. */
  3010. equals(value: DeepImmutable<Matrix>): boolean;
  3011. /**
  3012. * Clone the current matrix
  3013. * @returns a new matrix from the current matrix
  3014. */
  3015. clone(): Matrix;
  3016. /**
  3017. * Returns the name of the current matrix class
  3018. * @returns the string "Matrix"
  3019. */
  3020. getClassName(): string;
  3021. /**
  3022. * Gets the hash code of the current matrix
  3023. * @returns the hash code
  3024. */
  3025. getHashCode(): number;
  3026. /**
  3027. * Decomposes the current Matrix into a translation, rotation and scaling components
  3028. * @param scale defines the scale vector3 given as a reference to update
  3029. * @param rotation defines the rotation quaternion given as a reference to update
  3030. * @param translation defines the translation vector3 given as a reference to update
  3031. * @returns true if operation was successful
  3032. */
  3033. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3034. /**
  3035. * Gets specific row of the matrix
  3036. * @param index defines the number of the row to get
  3037. * @returns the index-th row of the current matrix as a new Vector4
  3038. */
  3039. getRow(index: number): Nullable<Vector4>;
  3040. /**
  3041. * Sets the index-th row of the current matrix to the vector4 values
  3042. * @param index defines the number of the row to set
  3043. * @param row defines the target vector4
  3044. * @returns the updated current matrix
  3045. */
  3046. setRow(index: number, row: Vector4): Matrix;
  3047. /**
  3048. * Compute the transpose of the matrix
  3049. * @returns the new transposed matrix
  3050. */
  3051. transpose(): Matrix;
  3052. /**
  3053. * Compute the transpose of the matrix and store it in a given matrix
  3054. * @param result defines the target matrix
  3055. * @returns the current matrix
  3056. */
  3057. transposeToRef(result: Matrix): Matrix;
  3058. /**
  3059. * Sets the index-th row of the current matrix with the given 4 x float values
  3060. * @param index defines the row index
  3061. * @param x defines the x component to set
  3062. * @param y defines the y component to set
  3063. * @param z defines the z component to set
  3064. * @param w defines the w component to set
  3065. * @returns the updated current matrix
  3066. */
  3067. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3068. /**
  3069. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3070. * @param scale defines the scale factor
  3071. * @returns a new matrix
  3072. */
  3073. scale(scale: number): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor to a given result matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Scale the current matrix values by a factor and add the result to a given matrix
  3083. * @param scale defines the scale factor
  3084. * @param result defines the Matrix to store the result
  3085. * @returns the current matrix
  3086. */
  3087. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3088. /**
  3089. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3090. * @param ref matrix to store the result
  3091. */
  3092. toNormalMatrix(ref: Matrix): void;
  3093. /**
  3094. * Gets only rotation part of the current matrix
  3095. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3096. */
  3097. getRotationMatrix(): Matrix;
  3098. /**
  3099. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3100. * @param result defines the target matrix to store data to
  3101. * @returns the current matrix
  3102. */
  3103. getRotationMatrixToRef(result: Matrix): Matrix;
  3104. /**
  3105. * Toggles model matrix from being right handed to left handed in place and vice versa
  3106. */
  3107. toggleModelMatrixHandInPlace(): void;
  3108. /**
  3109. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3110. */
  3111. toggleProjectionMatrixHandInPlace(): void;
  3112. /**
  3113. * Creates a matrix from an array
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @returns a new Matrix set from the starting index of the given array
  3117. */
  3118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3119. /**
  3120. * Copy the content of an array into a given matrix
  3121. * @param array defines the source array
  3122. * @param offset defines an offset in the source array
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3126. /**
  3127. * Stores an array into a matrix after having multiplied each component by a given factor
  3128. * @param array defines the source array
  3129. * @param offset defines the offset in the source array
  3130. * @param scale defines the scaling factor
  3131. * @param result defines the target matrix
  3132. */
  3133. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3134. /**
  3135. * Gets an identity matrix that must not be updated
  3136. */
  3137. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3138. /**
  3139. * Stores a list of values (16) inside a given matrix
  3140. * @param initialM11 defines 1st value of 1st row
  3141. * @param initialM12 defines 2nd value of 1st row
  3142. * @param initialM13 defines 3rd value of 1st row
  3143. * @param initialM14 defines 4th value of 1st row
  3144. * @param initialM21 defines 1st value of 2nd row
  3145. * @param initialM22 defines 2nd value of 2nd row
  3146. * @param initialM23 defines 3rd value of 2nd row
  3147. * @param initialM24 defines 4th value of 2nd row
  3148. * @param initialM31 defines 1st value of 3rd row
  3149. * @param initialM32 defines 2nd value of 3rd row
  3150. * @param initialM33 defines 3rd value of 3rd row
  3151. * @param initialM34 defines 4th value of 3rd row
  3152. * @param initialM41 defines 1st value of 4th row
  3153. * @param initialM42 defines 2nd value of 4th row
  3154. * @param initialM43 defines 3rd value of 4th row
  3155. * @param initialM44 defines 4th value of 4th row
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3159. /**
  3160. * Creates new matrix from a list of values (16)
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @returns the new matrix
  3178. */
  3179. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3180. /**
  3181. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @returns a new matrix
  3186. */
  3187. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3188. /**
  3189. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3190. * @param scale defines the scale vector3
  3191. * @param rotation defines the rotation quaternion
  3192. * @param translation defines the translation vector3
  3193. * @param result defines the target matrix
  3194. */
  3195. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3196. /**
  3197. * Creates a new identity matrix
  3198. * @returns a new identity matrix
  3199. */
  3200. static Identity(): Matrix;
  3201. /**
  3202. * Creates a new identity matrix and stores the result in a given matrix
  3203. * @param result defines the target matrix
  3204. */
  3205. static IdentityToRef(result: Matrix): void;
  3206. /**
  3207. * Creates a new zero matrix
  3208. * @returns a new zero matrix
  3209. */
  3210. static Zero(): Matrix;
  3211. /**
  3212. * Creates a new rotation matrix for "angle" radians around the X axis
  3213. * @param angle defines the angle (in radians) to use
  3214. * @return the new matrix
  3215. */
  3216. static RotationX(angle: number): Matrix;
  3217. /**
  3218. * Creates a new matrix as the invert of a given matrix
  3219. * @param source defines the source matrix
  3220. * @returns the new matrix
  3221. */
  3222. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3223. /**
  3224. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3225. * @param angle defines the angle (in radians) to use
  3226. * @param result defines the target matrix
  3227. */
  3228. static RotationXToRef(angle: number, result: Matrix): void;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the Y axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationY(angle: number): Matrix;
  3235. /**
  3236. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3237. * @param angle defines the angle (in radians) to use
  3238. * @param result defines the target matrix
  3239. */
  3240. static RotationYToRef(angle: number, result: Matrix): void;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the Z axis
  3243. * @param angle defines the angle (in radians) to use
  3244. * @return the new matrix
  3245. */
  3246. static RotationZ(angle: number): Matrix;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3249. * @param angle defines the angle (in radians) to use
  3250. * @param result defines the target matrix
  3251. */
  3252. static RotationZToRef(angle: number, result: Matrix): void;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3262. * @param axis defines the axis to use
  3263. * @param angle defines the angle (in radians) to use
  3264. * @param result defines the target matrix
  3265. */
  3266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3267. /**
  3268. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3269. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3270. * @param from defines the vector to align
  3271. * @param to defines the vector to align to
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3275. /**
  3276. * Creates a rotation matrix
  3277. * @param yaw defines the yaw angle in radians (Y axis)
  3278. * @param pitch defines the pitch angle in radians (X axis)
  3279. * @param roll defines the roll angle in radians (X axis)
  3280. * @returns the new rotation matrix
  3281. */
  3282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3283. /**
  3284. * Creates a rotation matrix and stores it in a given matrix
  3285. * @param yaw defines the yaw angle in radians (Y axis)
  3286. * @param pitch defines the pitch angle in radians (X axis)
  3287. * @param roll defines the roll angle in radians (X axis)
  3288. * @param result defines the target matrix
  3289. */
  3290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3291. /**
  3292. * Creates a scaling matrix
  3293. * @param x defines the scale factor on X axis
  3294. * @param y defines the scale factor on Y axis
  3295. * @param z defines the scale factor on Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Scaling(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a scaling matrix and stores it in a given matrix
  3301. * @param x defines the scale factor on X axis
  3302. * @param y defines the scale factor on Y axis
  3303. * @param z defines the scale factor on Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Creates a translation matrix
  3309. * @param x defines the translation on X axis
  3310. * @param y defines the translation on Y axis
  3311. * @param z defines the translationon Z axis
  3312. * @returns the new matrix
  3313. */
  3314. static Translation(x: number, y: number, z: number): Matrix;
  3315. /**
  3316. * Creates a translation matrix and stores it in a given matrix
  3317. * @param x defines the translation on X axis
  3318. * @param y defines the translation on Y axis
  3319. * @param z defines the translationon Z axis
  3320. * @param result defines the target matrix
  3321. */
  3322. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3323. /**
  3324. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3325. * @param startValue defines the start value
  3326. * @param endValue defines the end value
  3327. * @param gradient defines the gradient factor
  3328. * @returns the new matrix
  3329. */
  3330. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3331. /**
  3332. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3333. * @param startValue defines the start value
  3334. * @param endValue defines the end value
  3335. * @param gradient defines the gradient factor
  3336. * @param result defines the Matrix object where to store data
  3337. */
  3338. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3339. /**
  3340. * Builds a new matrix whose values are computed by:
  3341. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3342. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3343. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3344. * @param startValue defines the first matrix
  3345. * @param endValue defines the second matrix
  3346. * @param gradient defines the gradient between the two matrices
  3347. * @returns the new matrix
  3348. */
  3349. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3350. /**
  3351. * Update a matrix to values which are computed by:
  3352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3355. * @param startValue defines the first matrix
  3356. * @param endValue defines the second matrix
  3357. * @param gradient defines the gradient between the two matrices
  3358. * @param result defines the target matrix
  3359. */
  3360. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3361. /**
  3362. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3363. * This function works in left handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3372. * This function works in left handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3381. * This function works in right handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3390. * This function works in right handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param width defines the viewport width
  3400. * @param height defines the viewport height
  3401. * @param znear defines the near clip plane
  3402. * @param zfar defines the far clip plane
  3403. * @returns a new matrix as a left-handed orthographic projection matrix
  3404. */
  3405. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3406. /**
  3407. * Store a left-handed orthographic projection to a given matrix
  3408. * @param width defines the viewport width
  3409. * @param height defines the viewport height
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @param result defines the target matrix
  3413. */
  3414. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param left defines the viewport left coordinate
  3418. * @param right defines the viewport right coordinate
  3419. * @param bottom defines the viewport bottom coordinate
  3420. * @param top defines the viewport top coordinate
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @returns a new matrix as a left-handed orthographic projection matrix
  3424. */
  3425. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3426. /**
  3427. * Stores a left-handed orthographic projection into a given matrix
  3428. * @param left defines the viewport left coordinate
  3429. * @param right defines the viewport right coordinate
  3430. * @param bottom defines the viewport bottom coordinate
  3431. * @param top defines the viewport top coordinate
  3432. * @param znear defines the near clip plane
  3433. * @param zfar defines the far clip plane
  3434. * @param result defines the target matrix
  3435. */
  3436. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3437. /**
  3438. * Creates a right-handed orthographic projection matrix
  3439. * @param left defines the viewport left coordinate
  3440. * @param right defines the viewport right coordinate
  3441. * @param bottom defines the viewport bottom coordinate
  3442. * @param top defines the viewport top coordinate
  3443. * @param znear defines the near clip plane
  3444. * @param zfar defines the far clip plane
  3445. * @returns a new matrix as a right-handed orthographic projection matrix
  3446. */
  3447. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3448. /**
  3449. * Stores a right-handed orthographic projection into a given matrix
  3450. * @param left defines the viewport left coordinate
  3451. * @param right defines the viewport right coordinate
  3452. * @param bottom defines the viewport bottom coordinate
  3453. * @param top defines the viewport top coordinate
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @param result defines the target matrix
  3457. */
  3458. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3459. /**
  3460. * Creates a left-handed perspective projection matrix
  3461. * @param width defines the viewport width
  3462. * @param height defines the viewport height
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @returns a new matrix as a left-handed perspective projection matrix
  3466. */
  3467. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3468. /**
  3469. * Creates a left-handed perspective projection matrix
  3470. * @param fov defines the horizontal field of view
  3471. * @param aspect defines the aspect ratio
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @returns a new matrix as a left-handed perspective projection matrix
  3475. */
  3476. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3477. /**
  3478. * Stores a left-handed perspective projection into a given matrix
  3479. * @param fov defines the horizontal field of view
  3480. * @param aspect defines the aspect ratio
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @param result defines the target matrix
  3484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3485. */
  3486. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3487. /**
  3488. * Creates a right-handed perspective projection matrix
  3489. * @param fov defines the horizontal field of view
  3490. * @param aspect defines the aspect ratio
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @returns a new matrix as a right-handed perspective projection matrix
  3494. */
  3495. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3496. /**
  3497. * Stores a right-handed perspective projection into a given matrix
  3498. * @param fov defines the horizontal field of view
  3499. * @param aspect defines the aspect ratio
  3500. * @param znear defines the near clip plane
  3501. * @param zfar defines the far clip plane
  3502. * @param result defines the target matrix
  3503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3504. */
  3505. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3506. /**
  3507. * Stores a perspective projection for WebVR info a given matrix
  3508. * @param fov defines the field of view
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @param result defines the target matrix
  3512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3513. */
  3514. static PerspectiveFovWebVRToRef(fov: {
  3515. upDegrees: number;
  3516. downDegrees: number;
  3517. leftDegrees: number;
  3518. rightDegrees: number;
  3519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3520. /**
  3521. * Computes a complete transformation matrix
  3522. * @param viewport defines the viewport to use
  3523. * @param world defines the world matrix
  3524. * @param view defines the view matrix
  3525. * @param projection defines the projection matrix
  3526. * @param zmin defines the near clip plane
  3527. * @param zmax defines the far clip plane
  3528. * @returns the transformation matrix
  3529. */
  3530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3531. /**
  3532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3533. * @param matrix defines the matrix to use
  3534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3535. */
  3536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3537. /**
  3538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3539. * @param matrix defines the matrix to use
  3540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3541. */
  3542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3543. /**
  3544. * Compute the transpose of a given matrix
  3545. * @param matrix defines the matrix to transpose
  3546. * @returns the new matrix
  3547. */
  3548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3549. /**
  3550. * Compute the transpose of a matrix and store it in a target matrix
  3551. * @param matrix defines the matrix to transpose
  3552. * @param result defines the target matrix
  3553. */
  3554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3555. /**
  3556. * Computes a reflection matrix from a plane
  3557. * @param plane defines the reflection plane
  3558. * @returns a new matrix
  3559. */
  3560. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3561. /**
  3562. * Computes a reflection matrix from a plane
  3563. * @param plane defines the reflection plane
  3564. * @param result defines the target matrix
  3565. */
  3566. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3567. /**
  3568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3569. * @param xaxis defines the value of the 1st axis
  3570. * @param yaxis defines the value of the 2nd axis
  3571. * @param zaxis defines the value of the 3rd axis
  3572. * @param result defines the target matrix
  3573. */
  3574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3575. /**
  3576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3577. * @param quat defines the quaternion to use
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3581. }
  3582. /**
  3583. * Represens a plane by the equation ax + by + cz + d = 0
  3584. */
  3585. export class Plane {
  3586. /**
  3587. * Normal of the plane (a,b,c)
  3588. */
  3589. normal: Vector3;
  3590. /**
  3591. * d component of the plane
  3592. */
  3593. d: number;
  3594. /**
  3595. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3596. * @param a a component of the plane
  3597. * @param b b component of the plane
  3598. * @param c c component of the plane
  3599. * @param d d component of the plane
  3600. */
  3601. constructor(a: number, b: number, c: number, d: number);
  3602. /**
  3603. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3604. */
  3605. asArray(): number[];
  3606. /**
  3607. * @returns a new plane copied from the current Plane.
  3608. */
  3609. clone(): Plane;
  3610. /**
  3611. * @returns the string "Plane".
  3612. */
  3613. getClassName(): string;
  3614. /**
  3615. * @returns the Plane hash code.
  3616. */
  3617. getHashCode(): number;
  3618. /**
  3619. * Normalize the current Plane in place.
  3620. * @returns the updated Plane.
  3621. */
  3622. normalize(): Plane;
  3623. /**
  3624. * Applies a transformation the plane and returns the result
  3625. * @param transformation the transformation matrix to be applied to the plane
  3626. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3627. */
  3628. transform(transformation: DeepImmutable<Matrix>): Plane;
  3629. /**
  3630. * Calcualtte the dot product between the point and the plane normal
  3631. * @param point point to calculate the dot product with
  3632. * @returns the dot product (float) of the point coordinates and the plane normal.
  3633. */
  3634. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3635. /**
  3636. * Updates the current Plane from the plane defined by the three given points.
  3637. * @param point1 one of the points used to contruct the plane
  3638. * @param point2 one of the points used to contruct the plane
  3639. * @param point3 one of the points used to contruct the plane
  3640. * @returns the updated Plane.
  3641. */
  3642. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3643. /**
  3644. * Checks if the plane is facing a given direction
  3645. * @param direction the direction to check if the plane is facing
  3646. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3647. * @returns True is the vector "direction" is the same side than the plane normal.
  3648. */
  3649. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3650. /**
  3651. * Calculates the distance to a point
  3652. * @param point point to calculate distance to
  3653. * @returns the signed distance (float) from the given point to the Plane.
  3654. */
  3655. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Creates a plane from an array
  3658. * @param array the array to create a plane from
  3659. * @returns a new Plane from the given array.
  3660. */
  3661. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3662. /**
  3663. * Creates a plane from three points
  3664. * @param point1 point used to create the plane
  3665. * @param point2 point used to create the plane
  3666. * @param point3 point used to create the plane
  3667. * @returns a new Plane defined by the three given points.
  3668. */
  3669. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3670. /**
  3671. * Creates a plane from an origin point and a normal
  3672. * @param origin origin of the plane to be constructed
  3673. * @param normal normal of the plane to be constructed
  3674. * @returns a new Plane the normal vector to this plane at the given origin point.
  3675. * Note : the vector "normal" is updated because normalized.
  3676. */
  3677. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3678. /**
  3679. * Calculates the distance from a plane and a point
  3680. * @param origin origin of the plane to be constructed
  3681. * @param normal normal of the plane to be constructed
  3682. * @param point point to calculate distance to
  3683. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3684. */
  3685. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3686. }
  3687. /**
  3688. * Class used to represent a viewport on screen
  3689. */
  3690. export class Viewport {
  3691. /** viewport left coordinate */
  3692. x: number;
  3693. /** viewport top coordinate */
  3694. y: number;
  3695. /**viewport width */
  3696. width: number;
  3697. /** viewport height */
  3698. height: number;
  3699. /**
  3700. * Creates a Viewport object located at (x, y) and sized (width, height)
  3701. * @param x defines viewport left coordinate
  3702. * @param y defines viewport top coordinate
  3703. * @param width defines the viewport width
  3704. * @param height defines the viewport height
  3705. */
  3706. constructor(
  3707. /** viewport left coordinate */
  3708. x: number,
  3709. /** viewport top coordinate */
  3710. y: number,
  3711. /**viewport width */
  3712. width: number,
  3713. /** viewport height */
  3714. height: number);
  3715. /**
  3716. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @returns a new Viewport
  3720. */
  3721. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3722. /**
  3723. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3724. * @param renderWidth defines the rendering width
  3725. * @param renderHeight defines the rendering height
  3726. * @param ref defines the target viewport
  3727. * @returns the current viewport
  3728. */
  3729. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3730. /**
  3731. * Returns a new Viewport copied from the current one
  3732. * @returns a new Viewport
  3733. */
  3734. clone(): Viewport;
  3735. }
  3736. /**
  3737. * Reprasents a camera frustum
  3738. */
  3739. export class Frustum {
  3740. /**
  3741. * Gets the planes representing the frustum
  3742. * @param transform matrix to be applied to the returned planes
  3743. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3744. */
  3745. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3746. /**
  3747. * Gets the near frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the far frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the left frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Gets the right frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the top frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the bottom frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3784. * @param transform transformation matrix to be applied to the resulting frustum planes
  3785. * @param frustumPlanes the resuling frustum planes
  3786. */
  3787. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3788. }
  3789. /** Defines supported spaces */
  3790. export enum Space {
  3791. /** Local (object) space */
  3792. LOCAL = 0,
  3793. /** World space */
  3794. WORLD = 1,
  3795. /** Bone space */
  3796. BONE = 2
  3797. }
  3798. /** Defines the 3 main axes */
  3799. export class Axis {
  3800. /** X axis */
  3801. static X: Vector3;
  3802. /** Y axis */
  3803. static Y: Vector3;
  3804. /** Z axis */
  3805. static Z: Vector3;
  3806. }
  3807. /** Class used to represent a Bezier curve */
  3808. export class BezierCurve {
  3809. /**
  3810. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3811. * @param t defines the time
  3812. * @param x1 defines the left coordinate on X axis
  3813. * @param y1 defines the left coordinate on Y axis
  3814. * @param x2 defines the right coordinate on X axis
  3815. * @param y2 defines the right coordinate on Y axis
  3816. * @returns the interpolated value
  3817. */
  3818. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3819. }
  3820. /**
  3821. * Defines potential orientation for back face culling
  3822. */
  3823. export enum Orientation {
  3824. /**
  3825. * Clockwise
  3826. */
  3827. CW = 0,
  3828. /** Counter clockwise */
  3829. CCW = 1
  3830. }
  3831. /**
  3832. * Defines angle representation
  3833. */
  3834. export class Angle {
  3835. private _radians;
  3836. /**
  3837. * Creates an Angle object of "radians" radians (float).
  3838. * @param radians the angle in radians
  3839. */
  3840. constructor(radians: number);
  3841. /**
  3842. * Get value in degrees
  3843. * @returns the Angle value in degrees (float)
  3844. */
  3845. degrees(): number;
  3846. /**
  3847. * Get value in radians
  3848. * @returns the Angle value in radians (float)
  3849. */
  3850. radians(): number;
  3851. /**
  3852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3853. * @param a defines first vector
  3854. * @param b defines second vector
  3855. * @returns a new Angle
  3856. */
  3857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3858. /**
  3859. * Gets a new Angle object from the given float in radians
  3860. * @param radians defines the angle value in radians
  3861. * @returns a new Angle
  3862. */
  3863. static FromRadians(radians: number): Angle;
  3864. /**
  3865. * Gets a new Angle object from the given float in degrees
  3866. * @param degrees defines the angle value in degrees
  3867. * @returns a new Angle
  3868. */
  3869. static FromDegrees(degrees: number): Angle;
  3870. }
  3871. /**
  3872. * This represents an arc in a 2d space.
  3873. */
  3874. export class Arc2 {
  3875. /** Defines the start point of the arc */
  3876. startPoint: Vector2;
  3877. /** Defines the mid point of the arc */
  3878. midPoint: Vector2;
  3879. /** Defines the end point of the arc */
  3880. endPoint: Vector2;
  3881. /**
  3882. * Defines the center point of the arc.
  3883. */
  3884. centerPoint: Vector2;
  3885. /**
  3886. * Defines the radius of the arc.
  3887. */
  3888. radius: number;
  3889. /**
  3890. * Defines the angle of the arc (from mid point to end point).
  3891. */
  3892. angle: Angle;
  3893. /**
  3894. * Defines the start angle of the arc (from start point to middle point).
  3895. */
  3896. startAngle: Angle;
  3897. /**
  3898. * Defines the orientation of the arc (clock wise/counter clock wise).
  3899. */
  3900. orientation: Orientation;
  3901. /**
  3902. * Creates an Arc object from the three given points : start, middle and end.
  3903. * @param startPoint Defines the start point of the arc
  3904. * @param midPoint Defines the midlle point of the arc
  3905. * @param endPoint Defines the end point of the arc
  3906. */
  3907. constructor(
  3908. /** Defines the start point of the arc */
  3909. startPoint: Vector2,
  3910. /** Defines the mid point of the arc */
  3911. midPoint: Vector2,
  3912. /** Defines the end point of the arc */
  3913. endPoint: Vector2);
  3914. }
  3915. /**
  3916. * Represents a 2D path made up of multiple 2D points
  3917. */
  3918. export class Path2 {
  3919. private _points;
  3920. private _length;
  3921. /**
  3922. * If the path start and end point are the same
  3923. */
  3924. closed: boolean;
  3925. /**
  3926. * Creates a Path2 object from the starting 2D coordinates x and y.
  3927. * @param x the starting points x value
  3928. * @param y the starting points y value
  3929. */
  3930. constructor(x: number, y: number);
  3931. /**
  3932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3933. * @param x the added points x value
  3934. * @param y the added points y value
  3935. * @returns the updated Path2.
  3936. */
  3937. addLineTo(x: number, y: number): Path2;
  3938. /**
  3939. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3940. * @param midX middle point x value
  3941. * @param midY middle point y value
  3942. * @param endX end point x value
  3943. * @param endY end point y value
  3944. * @param numberOfSegments (default: 36)
  3945. * @returns the updated Path2.
  3946. */
  3947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3948. /**
  3949. * Closes the Path2.
  3950. * @returns the Path2.
  3951. */
  3952. close(): Path2;
  3953. /**
  3954. * Gets the sum of the distance between each sequential point in the path
  3955. * @returns the Path2 total length (float).
  3956. */
  3957. length(): number;
  3958. /**
  3959. * Gets the points which construct the path
  3960. * @returns the Path2 internal array of points.
  3961. */
  3962. getPoints(): Vector2[];
  3963. /**
  3964. * Retreives the point at the distance aways from the starting point
  3965. * @param normalizedLengthPosition the length along the path to retreive the point from
  3966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3967. */
  3968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3969. /**
  3970. * Creates a new path starting from an x and y position
  3971. * @param x starting x value
  3972. * @param y starting y value
  3973. * @returns a new Path2 starting at the coordinates (x, y).
  3974. */
  3975. static StartingAt(x: number, y: number): Path2;
  3976. }
  3977. /**
  3978. * Represents a 3D path made up of multiple 3D points
  3979. */
  3980. export class Path3D {
  3981. /**
  3982. * an array of Vector3, the curve axis of the Path3D
  3983. */
  3984. path: Vector3[];
  3985. private _curve;
  3986. private _distances;
  3987. private _tangents;
  3988. private _normals;
  3989. private _binormals;
  3990. private _raw;
  3991. /**
  3992. * new Path3D(path, normal, raw)
  3993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3995. * @param path an array of Vector3, the curve axis of the Path3D
  3996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3998. */
  3999. constructor(
  4000. /**
  4001. * an array of Vector3, the curve axis of the Path3D
  4002. */
  4003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4004. /**
  4005. * Returns the Path3D array of successive Vector3 designing its curve.
  4006. * @returns the Path3D array of successive Vector3 designing its curve.
  4007. */
  4008. getCurve(): Vector3[];
  4009. /**
  4010. * Returns an array populated with tangent vectors on each Path3D curve point.
  4011. * @returns an array populated with tangent vectors on each Path3D curve point.
  4012. */
  4013. getTangents(): Vector3[];
  4014. /**
  4015. * Returns an array populated with normal vectors on each Path3D curve point.
  4016. * @returns an array populated with normal vectors on each Path3D curve point.
  4017. */
  4018. getNormals(): Vector3[];
  4019. /**
  4020. * Returns an array populated with binormal vectors on each Path3D curve point.
  4021. * @returns an array populated with binormal vectors on each Path3D curve point.
  4022. */
  4023. getBinormals(): Vector3[];
  4024. /**
  4025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4027. */
  4028. getDistances(): number[];
  4029. /**
  4030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4031. * @param path path which all values are copied into the curves points
  4032. * @param firstNormal which should be projected onto the curve
  4033. * @returns the same object updated.
  4034. */
  4035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4036. private _compute;
  4037. private _getFirstNonNullVector;
  4038. private _getLastNonNullVector;
  4039. private _normalVector;
  4040. }
  4041. /**
  4042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4043. * A Curve3 is designed from a series of successive Vector3.
  4044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4045. */
  4046. export class Curve3 {
  4047. private _points;
  4048. private _length;
  4049. /**
  4050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4052. * @param v1 (Vector3) the control point
  4053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4054. * @param nbPoints (integer) the wanted number of points in the curve
  4055. * @returns the created Curve3
  4056. */
  4057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4058. /**
  4059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4061. * @param v1 (Vector3) the first control point
  4062. * @param v2 (Vector3) the second control point
  4063. * @param v3 (Vector3) the end point of the Cubic Bezier
  4064. * @param nbPoints (integer) the wanted number of points in the curve
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4068. /**
  4069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4070. * @param p1 (Vector3) the origin point of the Hermite Spline
  4071. * @param t1 (Vector3) the tangent vector at the origin point
  4072. * @param p2 (Vector3) the end point of the Hermite Spline
  4073. * @param t2 (Vector3) the tangent vector at the end point
  4074. * @param nbPoints (integer) the wanted number of points in the curve
  4075. * @returns the created Curve3
  4076. */
  4077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4078. /**
  4079. * Returns a Curve3 object along a CatmullRom Spline curve :
  4080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4081. * @param nbPoints (integer) the wanted number of points between each curve control points
  4082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4086. /**
  4087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4088. * A Curve3 is designed from a series of successive Vector3.
  4089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4090. * @param points points which make up the curve
  4091. */
  4092. constructor(points: Vector3[]);
  4093. /**
  4094. * @returns the Curve3 stored array of successive Vector3
  4095. */
  4096. getPoints(): Vector3[];
  4097. /**
  4098. * @returns the computed length (float) of the curve.
  4099. */
  4100. length(): number;
  4101. /**
  4102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4104. * curveA and curveB keep unchanged.
  4105. * @param curve the curve to continue from this curve
  4106. * @returns the newly constructed curve
  4107. */
  4108. continue(curve: DeepImmutable<Curve3>): Curve3;
  4109. private _computeLength;
  4110. }
  4111. /**
  4112. * Contains position and normal vectors for a vertex
  4113. */
  4114. export class PositionNormalVertex {
  4115. /** the position of the vertex (defaut: 0,0,0) */
  4116. position: Vector3;
  4117. /** the normal of the vertex (defaut: 0,1,0) */
  4118. normal: Vector3;
  4119. /**
  4120. * Creates a PositionNormalVertex
  4121. * @param position the position of the vertex (defaut: 0,0,0)
  4122. * @param normal the normal of the vertex (defaut: 0,1,0)
  4123. */
  4124. constructor(
  4125. /** the position of the vertex (defaut: 0,0,0) */
  4126. position?: Vector3,
  4127. /** the normal of the vertex (defaut: 0,1,0) */
  4128. normal?: Vector3);
  4129. /**
  4130. * Clones the PositionNormalVertex
  4131. * @returns the cloned PositionNormalVertex
  4132. */
  4133. clone(): PositionNormalVertex;
  4134. }
  4135. /**
  4136. * Contains position, normal and uv vectors for a vertex
  4137. */
  4138. export class PositionNormalTextureVertex {
  4139. /** the position of the vertex (defaut: 0,0,0) */
  4140. position: Vector3;
  4141. /** the normal of the vertex (defaut: 0,1,0) */
  4142. normal: Vector3;
  4143. /** the uv of the vertex (default: 0,0) */
  4144. uv: Vector2;
  4145. /**
  4146. * Creates a PositionNormalTextureVertex
  4147. * @param position the position of the vertex (defaut: 0,0,0)
  4148. * @param normal the normal of the vertex (defaut: 0,1,0)
  4149. * @param uv the uv of the vertex (default: 0,0)
  4150. */
  4151. constructor(
  4152. /** the position of the vertex (defaut: 0,0,0) */
  4153. position?: Vector3,
  4154. /** the normal of the vertex (defaut: 0,1,0) */
  4155. normal?: Vector3,
  4156. /** the uv of the vertex (default: 0,0) */
  4157. uv?: Vector2);
  4158. /**
  4159. * Clones the PositionNormalTextureVertex
  4160. * @returns the cloned PositionNormalTextureVertex
  4161. */
  4162. clone(): PositionNormalTextureVertex;
  4163. }
  4164. /**
  4165. * @hidden
  4166. */
  4167. export class Tmp {
  4168. static Color3: Color3[];
  4169. static Color4: Color4[];
  4170. static Vector2: Vector2[];
  4171. static Vector3: Vector3[];
  4172. static Vector4: Vector4[];
  4173. static Quaternion: Quaternion[];
  4174. static Matrix: Matrix[];
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * Class used to enable access to offline support
  4180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4181. */
  4182. export interface IOfflineProvider {
  4183. /**
  4184. * Gets a boolean indicating if scene must be saved in the database
  4185. */
  4186. enableSceneOffline: boolean;
  4187. /**
  4188. * Gets a boolean indicating if textures must be saved in the database
  4189. */
  4190. enableTexturesOffline: boolean;
  4191. /**
  4192. * Open the offline support and make it available
  4193. * @param successCallback defines the callback to call on success
  4194. * @param errorCallback defines the callback to call on error
  4195. */
  4196. open(successCallback: () => void, errorCallback: () => void): void;
  4197. /**
  4198. * Loads an image from the offline support
  4199. * @param url defines the url to load from
  4200. * @param image defines the target DOM image
  4201. */
  4202. loadImage(url: string, image: HTMLImageElement): void;
  4203. /**
  4204. * Loads a file from offline support
  4205. * @param url defines the URL to load from
  4206. * @param sceneLoaded defines a callback to call on success
  4207. * @param progressCallBack defines a callback to call when progress changed
  4208. * @param errorCallback defines a callback to call on error
  4209. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4210. */
  4211. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4212. }
  4213. }
  4214. declare module BABYLON {
  4215. /**
  4216. * A class serves as a medium between the observable and its observers
  4217. */
  4218. export class EventState {
  4219. /**
  4220. * Create a new EventState
  4221. * @param mask defines the mask associated with this state
  4222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4223. * @param target defines the original target of the state
  4224. * @param currentTarget defines the current target of the state
  4225. */
  4226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4227. /**
  4228. * Initialize the current event state
  4229. * @param mask defines the mask associated with this state
  4230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4231. * @param target defines the original target of the state
  4232. * @param currentTarget defines the current target of the state
  4233. * @returns the current event state
  4234. */
  4235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4236. /**
  4237. * An Observer can set this property to true to prevent subsequent observers of being notified
  4238. */
  4239. skipNextObservers: boolean;
  4240. /**
  4241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4242. */
  4243. mask: number;
  4244. /**
  4245. * The object that originally notified the event
  4246. */
  4247. target?: any;
  4248. /**
  4249. * The current object in the bubbling phase
  4250. */
  4251. currentTarget?: any;
  4252. /**
  4253. * This will be populated with the return value of the last function that was executed.
  4254. * If it is the first function in the callback chain it will be the event data.
  4255. */
  4256. lastReturnValue?: any;
  4257. }
  4258. /**
  4259. * Represent an Observer registered to a given Observable object.
  4260. */
  4261. export class Observer<T> {
  4262. /**
  4263. * Defines the callback to call when the observer is notified
  4264. */
  4265. callback: (eventData: T, eventState: EventState) => void;
  4266. /**
  4267. * Defines the mask of the observer (used to filter notifications)
  4268. */
  4269. mask: number;
  4270. /**
  4271. * Defines the current scope used to restore the JS context
  4272. */
  4273. scope: any;
  4274. /** @hidden */
  4275. _willBeUnregistered: boolean;
  4276. /**
  4277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4278. */
  4279. unregisterOnNextCall: boolean;
  4280. /**
  4281. * Creates a new observer
  4282. * @param callback defines the callback to call when the observer is notified
  4283. * @param mask defines the mask of the observer (used to filter notifications)
  4284. * @param scope defines the current scope used to restore the JS context
  4285. */
  4286. constructor(
  4287. /**
  4288. * Defines the callback to call when the observer is notified
  4289. */
  4290. callback: (eventData: T, eventState: EventState) => void,
  4291. /**
  4292. * Defines the mask of the observer (used to filter notifications)
  4293. */
  4294. mask: number,
  4295. /**
  4296. * Defines the current scope used to restore the JS context
  4297. */
  4298. scope?: any);
  4299. }
  4300. /**
  4301. * Represent a list of observers registered to multiple Observables object.
  4302. */
  4303. export class MultiObserver<T> {
  4304. private _observers;
  4305. private _observables;
  4306. /**
  4307. * Release associated resources
  4308. */
  4309. dispose(): void;
  4310. /**
  4311. * Raise a callback when one of the observable will notify
  4312. * @param observables defines a list of observables to watch
  4313. * @param callback defines the callback to call on notification
  4314. * @param mask defines the mask used to filter notifications
  4315. * @param scope defines the current scope used to restore the JS context
  4316. * @returns the new MultiObserver
  4317. */
  4318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4319. }
  4320. /**
  4321. * The Observable class is a simple implementation of the Observable pattern.
  4322. *
  4323. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4325. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4326. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4327. */
  4328. export class Observable<T> {
  4329. private _observers;
  4330. private _eventState;
  4331. private _onObserverAdded;
  4332. /**
  4333. * Creates a new observable
  4334. * @param onObserverAdded defines a callback to call when a new observer is added
  4335. */
  4336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4337. /**
  4338. * Create a new Observer with the specified callback
  4339. * @param callback the callback that will be executed for that Observer
  4340. * @param mask the mask used to filter observers
  4341. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4342. * @param scope optional scope for the callback to be called from
  4343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4344. * @returns the new observer created for the callback
  4345. */
  4346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4347. /**
  4348. * Create a new Observer with the specified callback and unregisters after the next notification
  4349. * @param callback the callback that will be executed for that Observer
  4350. * @returns the new observer created for the callback
  4351. */
  4352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4353. /**
  4354. * Remove an Observer from the Observable object
  4355. * @param observer the instance of the Observer to remove
  4356. * @returns false if it doesn't belong to this Observable
  4357. */
  4358. remove(observer: Nullable<Observer<T>>): boolean;
  4359. /**
  4360. * Remove a callback from the Observable object
  4361. * @param callback the callback to remove
  4362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4363. * @returns false if it doesn't belong to this Observable
  4364. */
  4365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4366. private _deferUnregister;
  4367. private _remove;
  4368. /**
  4369. * Moves the observable to the top of the observer list making it get called first when notified
  4370. * @param observer the observer to move
  4371. */
  4372. makeObserverTopPriority(observer: Observer<T>): void;
  4373. /**
  4374. * Moves the observable to the bottom of the observer list making it get called last when notified
  4375. * @param observer the observer to move
  4376. */
  4377. makeObserverBottomPriority(observer: Observer<T>): void;
  4378. /**
  4379. * Notify all Observers by calling their respective callback with the given data
  4380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4381. * @param eventData defines the data to send to all observers
  4382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4383. * @param target defines the original target of the state
  4384. * @param currentTarget defines the current target of the state
  4385. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4386. */
  4387. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4388. /**
  4389. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4390. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4391. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4392. * and it is crucial that all callbacks will be executed.
  4393. * The order of the callbacks is kept, callbacks are not executed parallel.
  4394. *
  4395. * @param eventData The data to be sent to each callback
  4396. * @param mask is used to filter observers defaults to -1
  4397. * @param target defines the callback target (see EventState)
  4398. * @param currentTarget defines he current object in the bubbling phase
  4399. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4400. */
  4401. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4402. /**
  4403. * Notify a specific observer
  4404. * @param observer defines the observer to notify
  4405. * @param eventData defines the data to be sent to each callback
  4406. * @param mask is used to filter observers defaults to -1
  4407. */
  4408. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4409. /**
  4410. * Gets a boolean indicating if the observable has at least one observer
  4411. * @returns true is the Observable has at least one Observer registered
  4412. */
  4413. hasObservers(): boolean;
  4414. /**
  4415. * Clear the list of observers
  4416. */
  4417. clear(): void;
  4418. /**
  4419. * Clone the current observable
  4420. * @returns a new observable
  4421. */
  4422. clone(): Observable<T>;
  4423. /**
  4424. * Does this observable handles observer registered with a given mask
  4425. * @param mask defines the mask to be tested
  4426. * @return whether or not one observer registered with the given mask is handeled
  4427. **/
  4428. hasSpecificMask(mask?: number): boolean;
  4429. }
  4430. }
  4431. declare module BABYLON {
  4432. /**
  4433. * Class used to help managing file picking and drag'n'drop
  4434. * File Storage
  4435. */
  4436. export class FilesInputStore {
  4437. /**
  4438. * List of files ready to be loaded
  4439. */
  4440. static FilesToLoad: {
  4441. [key: string]: File;
  4442. };
  4443. }
  4444. }
  4445. declare module BABYLON {
  4446. /** Defines the cross module used constants to avoid circular dependncies */
  4447. export class Constants {
  4448. /** Defines that alpha blending is disabled */
  4449. static readonly ALPHA_DISABLE: number;
  4450. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4451. static readonly ALPHA_ADD: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4453. static readonly ALPHA_COMBINE: number;
  4454. /** Defines that alpha blending to DEST - SRC * DEST */
  4455. static readonly ALPHA_SUBTRACT: number;
  4456. /** Defines that alpha blending to SRC * DEST */
  4457. static readonly ALPHA_MULTIPLY: number;
  4458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4459. static readonly ALPHA_MAXIMIZED: number;
  4460. /** Defines that alpha blending to SRC + DEST */
  4461. static readonly ALPHA_ONEONE: number;
  4462. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4463. static readonly ALPHA_PREMULTIPLIED: number;
  4464. /**
  4465. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4466. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4467. */
  4468. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4469. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4470. static readonly ALPHA_INTERPOLATE: number;
  4471. /**
  4472. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4473. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4474. */
  4475. static readonly ALPHA_SCREENMODE: number;
  4476. /** Defines that the ressource is not delayed*/
  4477. static readonly DELAYLOADSTATE_NONE: number;
  4478. /** Defines that the ressource was successfully delay loaded */
  4479. static readonly DELAYLOADSTATE_LOADED: number;
  4480. /** Defines that the ressource is currently delay loading */
  4481. static readonly DELAYLOADSTATE_LOADING: number;
  4482. /** Defines that the ressource is delayed and has not started loading */
  4483. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4485. static readonly NEVER: number;
  4486. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4487. static readonly ALWAYS: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4489. static readonly LESS: number;
  4490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4491. static readonly EQUAL: number;
  4492. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4493. static readonly LEQUAL: number;
  4494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4495. static readonly GREATER: number;
  4496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4497. static readonly GEQUAL: number;
  4498. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4499. static readonly NOTEQUAL: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be kept */
  4501. static readonly KEEP: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4503. static readonly REPLACE: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4505. static readonly INCR: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4507. static readonly DECR: number;
  4508. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4509. static readonly INVERT: number;
  4510. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4511. static readonly INCR_WRAP: number;
  4512. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4513. static readonly DECR_WRAP: number;
  4514. /** Texture is not repeating outside of 0..1 UVs */
  4515. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4516. /** Texture is repeating outside of 0..1 UVs */
  4517. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4518. /** Texture is repeating and mirrored */
  4519. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4520. /** ALPHA */
  4521. static readonly TEXTUREFORMAT_ALPHA: number;
  4522. /** LUMINANCE */
  4523. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4524. /** LUMINANCE_ALPHA */
  4525. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4526. /** RGB */
  4527. static readonly TEXTUREFORMAT_RGB: number;
  4528. /** RGBA */
  4529. static readonly TEXTUREFORMAT_RGBA: number;
  4530. /** RED */
  4531. static readonly TEXTUREFORMAT_RED: number;
  4532. /** RED (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R: number;
  4534. /** RG */
  4535. static readonly TEXTUREFORMAT_RG: number;
  4536. /** RED_INTEGER */
  4537. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4538. /** RED_INTEGER (2nd reference) */
  4539. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4540. /** RG_INTEGER */
  4541. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4542. /** RGB_INTEGER */
  4543. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4544. /** RGBA_INTEGER */
  4545. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4546. /** UNSIGNED_BYTE */
  4547. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4548. /** UNSIGNED_BYTE (2nd reference) */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4550. /** FLOAT */
  4551. static readonly TEXTURETYPE_FLOAT: number;
  4552. /** HALF_FLOAT */
  4553. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4554. /** BYTE */
  4555. static readonly TEXTURETYPE_BYTE: number;
  4556. /** SHORT */
  4557. static readonly TEXTURETYPE_SHORT: number;
  4558. /** UNSIGNED_SHORT */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4560. /** INT */
  4561. static readonly TEXTURETYPE_INT: number;
  4562. /** UNSIGNED_INT */
  4563. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4564. /** UNSIGNED_SHORT_4_4_4_4 */
  4565. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4566. /** UNSIGNED_SHORT_5_5_5_1 */
  4567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4568. /** UNSIGNED_SHORT_5_6_5 */
  4569. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4570. /** UNSIGNED_INT_2_10_10_10_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4572. /** UNSIGNED_INT_24_8 */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4574. /** UNSIGNED_INT_10F_11F_11F_REV */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4576. /** UNSIGNED_INT_5_9_9_9_REV */
  4577. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4578. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4579. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4586. /** nearest is mag = nearest and min = nearest and mip = linear */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4590. /** Trilinear is mag = linear and min = linear and mip = linear */
  4591. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = nearest and mip = nearest */
  4593. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4594. /** mag = nearest and min = linear and mip = nearest */
  4595. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4596. /** mag = nearest and min = linear and mip = linear */
  4597. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4598. /** mag = nearest and min = linear and mip = none */
  4599. static readonly TEXTURE_NEAREST_LINEAR: number;
  4600. /** mag = nearest and min = nearest and mip = none */
  4601. static readonly TEXTURE_NEAREST_NEAREST: number;
  4602. /** mag = linear and min = nearest and mip = nearest */
  4603. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4604. /** mag = linear and min = nearest and mip = linear */
  4605. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4606. /** mag = linear and min = linear and mip = none */
  4607. static readonly TEXTURE_LINEAR_LINEAR: number;
  4608. /** mag = linear and min = nearest and mip = none */
  4609. static readonly TEXTURE_LINEAR_NEAREST: number;
  4610. /** Explicit coordinates mode */
  4611. static readonly TEXTURE_EXPLICIT_MODE: number;
  4612. /** Spherical coordinates mode */
  4613. static readonly TEXTURE_SPHERICAL_MODE: number;
  4614. /** Planar coordinates mode */
  4615. static readonly TEXTURE_PLANAR_MODE: number;
  4616. /** Cubic coordinates mode */
  4617. static readonly TEXTURE_CUBIC_MODE: number;
  4618. /** Projection coordinates mode */
  4619. static readonly TEXTURE_PROJECTION_MODE: number;
  4620. /** Skybox coordinates mode */
  4621. static readonly TEXTURE_SKYBOX_MODE: number;
  4622. /** Inverse Cubic coordinates mode */
  4623. static readonly TEXTURE_INVCUBIC_MODE: number;
  4624. /** Equirectangular coordinates mode */
  4625. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4626. /** Equirectangular Fixed coordinates mode */
  4627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4628. /** Equirectangular Fixed Mirrored coordinates mode */
  4629. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4630. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4631. static readonly SCALEMODE_FLOOR: number;
  4632. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4633. static readonly SCALEMODE_NEAREST: number;
  4634. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4635. static readonly SCALEMODE_CEILING: number;
  4636. /**
  4637. * The dirty texture flag value
  4638. */
  4639. static readonly MATERIAL_TextureDirtyFlag: number;
  4640. /**
  4641. * The dirty light flag value
  4642. */
  4643. static readonly MATERIAL_LightDirtyFlag: number;
  4644. /**
  4645. * The dirty fresnel flag value
  4646. */
  4647. static readonly MATERIAL_FresnelDirtyFlag: number;
  4648. /**
  4649. * The dirty attribute flag value
  4650. */
  4651. static readonly MATERIAL_AttributesDirtyFlag: number;
  4652. /**
  4653. * The dirty misc flag value
  4654. */
  4655. static readonly MATERIAL_MiscDirtyFlag: number;
  4656. /**
  4657. * The all dirty flag value
  4658. */
  4659. static readonly MATERIAL_AllDirtyFlag: number;
  4660. /**
  4661. * Returns the triangle fill mode
  4662. */
  4663. static readonly MATERIAL_TriangleFillMode: number;
  4664. /**
  4665. * Returns the wireframe mode
  4666. */
  4667. static readonly MATERIAL_WireFrameFillMode: number;
  4668. /**
  4669. * Returns the point fill mode
  4670. */
  4671. static readonly MATERIAL_PointFillMode: number;
  4672. /**
  4673. * Returns the point list draw mode
  4674. */
  4675. static readonly MATERIAL_PointListDrawMode: number;
  4676. /**
  4677. * Returns the line list draw mode
  4678. */
  4679. static readonly MATERIAL_LineListDrawMode: number;
  4680. /**
  4681. * Returns the line loop draw mode
  4682. */
  4683. static readonly MATERIAL_LineLoopDrawMode: number;
  4684. /**
  4685. * Returns the line strip draw mode
  4686. */
  4687. static readonly MATERIAL_LineStripDrawMode: number;
  4688. /**
  4689. * Returns the triangle strip draw mode
  4690. */
  4691. static readonly MATERIAL_TriangleStripDrawMode: number;
  4692. /**
  4693. * Returns the triangle fan draw mode
  4694. */
  4695. static readonly MATERIAL_TriangleFanDrawMode: number;
  4696. /**
  4697. * Stores the clock-wise side orientation
  4698. */
  4699. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4700. /**
  4701. * Stores the counter clock-wise side orientation
  4702. */
  4703. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4704. /**
  4705. * Nothing
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_NothingTrigger: number;
  4709. /**
  4710. * On pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnPickTrigger: number;
  4714. /**
  4715. * On left pick
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnLeftPickTrigger: number;
  4719. /**
  4720. * On right pick
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnRightPickTrigger: number;
  4724. /**
  4725. * On center pick
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnCenterPickTrigger: number;
  4729. /**
  4730. * On pick down
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickDownTrigger: number;
  4734. /**
  4735. * On double pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnDoublePickTrigger: number;
  4739. /**
  4740. * On pick up
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickUpTrigger: number;
  4744. /**
  4745. * On pick out.
  4746. * This trigger will only be raised if you also declared a OnPickDown
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnPickOutTrigger: number;
  4750. /**
  4751. * On long press
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnLongPressTrigger: number;
  4755. /**
  4756. * On pointer over
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPointerOverTrigger: number;
  4760. /**
  4761. * On pointer out
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnPointerOutTrigger: number;
  4765. /**
  4766. * On every frame
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnEveryFrameTrigger: number;
  4770. /**
  4771. * On intersection enter
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4775. /**
  4776. * On intersection exit
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnIntersectionExitTrigger: number;
  4780. /**
  4781. * On key down
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnKeyDownTrigger: number;
  4785. /**
  4786. * On key up
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnKeyUpTrigger: number;
  4790. /**
  4791. * Billboard mode will only apply to Y axis
  4792. */
  4793. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4794. /**
  4795. * Billboard mode will apply to all axes
  4796. */
  4797. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4798. /**
  4799. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4800. */
  4801. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4802. /**
  4803. * Gets or sets base Assets URL
  4804. */
  4805. static readonly PARTICLES_BaseAssetsUrl: string;
  4806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4807. * Test order :
  4808. * Is the bounding sphere outside the frustum ?
  4809. * If not, are the bounding box vertices outside the frustum ?
  4810. * It not, then the cullable object is in the frustum.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4813. /** Culling strategy : Bounding Sphere Only.
  4814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4815. * It's also less accurate than the standard because some not visible objects can still be selected.
  4816. * Test : is the bounding sphere outside the frustum ?
  4817. * If not, then the cullable object is in the frustum.
  4818. */
  4819. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4820. /** Culling strategy : Optimistic Inclusion.
  4821. * This in an inclusion test first, then the standard exclusion test.
  4822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4823. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4824. * Anyway, it's as accurate as the standard strategy.
  4825. * Test :
  4826. * Is the cullable object bounding sphere center in the frustum ?
  4827. * If not, apply the default culling strategy.
  4828. */
  4829. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4833. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4835. * Test :
  4836. * Is the cullable object bounding sphere center in the frustum ?
  4837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4840. /**
  4841. * No logging while loading
  4842. */
  4843. static readonly SCENELOADER_NO_LOGGING: number;
  4844. /**
  4845. * Minimal logging while loading
  4846. */
  4847. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4848. /**
  4849. * Summary logging while loading
  4850. */
  4851. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4852. /**
  4853. * Detailled logging while loading
  4854. */
  4855. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4861. * Babylon.js
  4862. */
  4863. export class DomManagement {
  4864. /**
  4865. * Checks if the window object exists
  4866. * @returns true if the window object exists
  4867. */
  4868. static IsWindowObjectExist(): boolean;
  4869. /**
  4870. * Extracts text content from a DOM element hierarchy
  4871. * @param element defines the root element
  4872. * @returns a string
  4873. */
  4874. static GetDOMTextContent(element: HTMLElement): string;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /**
  4879. * Logger used througouht the application to allow configuration of
  4880. * the log level required for the messages.
  4881. */
  4882. export class Logger {
  4883. /**
  4884. * No log
  4885. */
  4886. static readonly NoneLogLevel: number;
  4887. /**
  4888. * Only message logs
  4889. */
  4890. static readonly MessageLogLevel: number;
  4891. /**
  4892. * Only warning logs
  4893. */
  4894. static readonly WarningLogLevel: number;
  4895. /**
  4896. * Only error logs
  4897. */
  4898. static readonly ErrorLogLevel: number;
  4899. /**
  4900. * All logs
  4901. */
  4902. static readonly AllLogLevel: number;
  4903. private static _LogCache;
  4904. /**
  4905. * Gets a value indicating the number of loading errors
  4906. * @ignorenaming
  4907. */
  4908. static errorsCount: number;
  4909. /**
  4910. * Callback called when a new log is added
  4911. */
  4912. static OnNewCacheEntry: (entry: string) => void;
  4913. private static _AddLogEntry;
  4914. private static _FormatMessage;
  4915. private static _LogDisabled;
  4916. private static _LogEnabled;
  4917. private static _WarnDisabled;
  4918. private static _WarnEnabled;
  4919. private static _ErrorDisabled;
  4920. private static _ErrorEnabled;
  4921. /**
  4922. * Log a message to the console
  4923. */
  4924. static Log: (message: string) => void;
  4925. /**
  4926. * Write a warning message to the console
  4927. */
  4928. static Warn: (message: string) => void;
  4929. /**
  4930. * Write an error message to the console
  4931. */
  4932. static Error: (message: string) => void;
  4933. /**
  4934. * Gets current log cache (list of logs)
  4935. */
  4936. static readonly LogCache: string;
  4937. /**
  4938. * Clears the log cache
  4939. */
  4940. static ClearLogCache(): void;
  4941. /**
  4942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4943. */
  4944. static LogLevels: number;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /** @hidden */
  4949. export class _TypeStore {
  4950. /** @hidden */
  4951. static RegisteredTypes: {
  4952. [key: string]: Object;
  4953. };
  4954. /** @hidden */
  4955. static GetClass(fqdn: string): any;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class containing a set of static utilities functions for deep copy.
  4961. */
  4962. export class DeepCopier {
  4963. /**
  4964. * Tries to copy an object by duplicating every property
  4965. * @param source defines the source object
  4966. * @param destination defines the target object
  4967. * @param doNotCopyList defines a list of properties to avoid
  4968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4969. */
  4970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class containing a set of static utilities functions for precision date
  4976. */
  4977. export class PrecisionDate {
  4978. /**
  4979. * Gets either window.performance.now() if supported or Date.now() else
  4980. */
  4981. static readonly Now: number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /** @hidden */
  4986. export class _DevTools {
  4987. static WarnImport(name: string): string;
  4988. }
  4989. }
  4990. declare module BABYLON {
  4991. /**
  4992. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4993. */
  4994. export class WebRequest {
  4995. private _xhr;
  4996. /**
  4997. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4998. * i.e. when loading files, where the server/service expects an Authorization header
  4999. */
  5000. static CustomRequestHeaders: {
  5001. [key: string]: string;
  5002. };
  5003. /**
  5004. * Add callback functions in this array to update all the requests before they get sent to the network
  5005. */
  5006. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5007. private _injectCustomRequestHeaders;
  5008. /**
  5009. * Gets or sets a function to be called when loading progress changes
  5010. */
  5011. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5012. /**
  5013. * Returns client's state
  5014. */
  5015. readonly readyState: number;
  5016. /**
  5017. * Returns client's status
  5018. */
  5019. readonly status: number;
  5020. /**
  5021. * Returns client's status as a text
  5022. */
  5023. readonly statusText: string;
  5024. /**
  5025. * Returns client's response
  5026. */
  5027. readonly response: any;
  5028. /**
  5029. * Returns client's response url
  5030. */
  5031. readonly responseURL: string;
  5032. /**
  5033. * Returns client's response as text
  5034. */
  5035. readonly responseText: string;
  5036. /**
  5037. * Gets or sets the expected response type
  5038. */
  5039. responseType: XMLHttpRequestResponseType;
  5040. /** @hidden */
  5041. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5042. /** @hidden */
  5043. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5044. /**
  5045. * Cancels any network activity
  5046. */
  5047. abort(): void;
  5048. /**
  5049. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5050. * @param body defines an optional request body
  5051. */
  5052. send(body?: Document | BodyInit | null): void;
  5053. /**
  5054. * Sets the request method, request URL
  5055. * @param method defines the method to use (GET, POST, etc..)
  5056. * @param url defines the url to connect with
  5057. */
  5058. open(method: string, url: string): void;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to evalaute queries containing `and` and `or` operators
  5064. */
  5065. export class AndOrNotEvaluator {
  5066. /**
  5067. * Evaluate a query
  5068. * @param query defines the query to evaluate
  5069. * @param evaluateCallback defines the callback used to filter result
  5070. * @returns true if the query matches
  5071. */
  5072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5073. private static _HandleParenthesisContent;
  5074. private static _SimplifyNegation;
  5075. }
  5076. }
  5077. declare module BABYLON {
  5078. /**
  5079. * Class used to store custom tags
  5080. */
  5081. export class Tags {
  5082. /**
  5083. * Adds support for tags on the given object
  5084. * @param obj defines the object to use
  5085. */
  5086. static EnableFor(obj: any): void;
  5087. /**
  5088. * Removes tags support
  5089. * @param obj defines the object to use
  5090. */
  5091. static DisableFor(obj: any): void;
  5092. /**
  5093. * Gets a boolean indicating if the given object has tags
  5094. * @param obj defines the object to use
  5095. * @returns a boolean
  5096. */
  5097. static HasTags(obj: any): boolean;
  5098. /**
  5099. * Gets the tags available on a given object
  5100. * @param obj defines the object to use
  5101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5102. * @returns the tags
  5103. */
  5104. static GetTags(obj: any, asString?: boolean): any;
  5105. /**
  5106. * Adds tags to an object
  5107. * @param obj defines the object to use
  5108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5110. */
  5111. static AddTagsTo(obj: any, tagsString: string): void;
  5112. /**
  5113. * @hidden
  5114. */
  5115. static _AddTagTo(obj: any, tag: string): void;
  5116. /**
  5117. * Removes specific tags from a specific object
  5118. * @param obj defines the object to use
  5119. * @param tagsString defines the tags to remove
  5120. */
  5121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5122. /**
  5123. * @hidden
  5124. */
  5125. static _RemoveTagFrom(obj: any, tag: string): void;
  5126. /**
  5127. * Defines if tags hosted on an object match a given query
  5128. * @param obj defines the object to use
  5129. * @param tagsQuery defines the tag query
  5130. * @returns a boolean
  5131. */
  5132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /**
  5137. * Manages the defines for the Material
  5138. */
  5139. export class MaterialDefines {
  5140. private _keys;
  5141. private _isDirty;
  5142. /** @hidden */
  5143. _renderId: number;
  5144. /** @hidden */
  5145. _areLightsDirty: boolean;
  5146. /** @hidden */
  5147. _areAttributesDirty: boolean;
  5148. /** @hidden */
  5149. _areTexturesDirty: boolean;
  5150. /** @hidden */
  5151. _areFresnelDirty: boolean;
  5152. /** @hidden */
  5153. _areMiscDirty: boolean;
  5154. /** @hidden */
  5155. _areImageProcessingDirty: boolean;
  5156. /** @hidden */
  5157. _normals: boolean;
  5158. /** @hidden */
  5159. _uvs: boolean;
  5160. /** @hidden */
  5161. _needNormals: boolean;
  5162. /** @hidden */
  5163. _needUVs: boolean;
  5164. /**
  5165. * Specifies if the material needs to be re-calculated
  5166. */
  5167. readonly isDirty: boolean;
  5168. /**
  5169. * Marks the material to indicate that it has been re-calculated
  5170. */
  5171. markAsProcessed(): void;
  5172. /**
  5173. * Marks the material to indicate that it needs to be re-calculated
  5174. */
  5175. markAsUnprocessed(): void;
  5176. /**
  5177. * Marks the material to indicate all of its defines need to be re-calculated
  5178. */
  5179. markAllAsDirty(): void;
  5180. /**
  5181. * Marks the material to indicate that image processing needs to be re-calculated
  5182. */
  5183. markAsImageProcessingDirty(): void;
  5184. /**
  5185. * Marks the material to indicate the lights need to be re-calculated
  5186. */
  5187. markAsLightDirty(): void;
  5188. /**
  5189. * Marks the attribute state as changed
  5190. */
  5191. markAsAttributesDirty(): void;
  5192. /**
  5193. * Marks the texture state as changed
  5194. */
  5195. markAsTexturesDirty(): void;
  5196. /**
  5197. * Marks the fresnel state as changed
  5198. */
  5199. markAsFresnelDirty(): void;
  5200. /**
  5201. * Marks the misc state as changed
  5202. */
  5203. markAsMiscDirty(): void;
  5204. /**
  5205. * Rebuilds the material defines
  5206. */
  5207. rebuild(): void;
  5208. /**
  5209. * Specifies if two material defines are equal
  5210. * @param other - A material define instance to compare to
  5211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5212. */
  5213. isEqual(other: MaterialDefines): boolean;
  5214. /**
  5215. * Clones this instance's defines to another instance
  5216. * @param other - material defines to clone values to
  5217. */
  5218. cloneTo(other: MaterialDefines): void;
  5219. /**
  5220. * Resets the material define values
  5221. */
  5222. reset(): void;
  5223. /**
  5224. * Converts the material define values to a string
  5225. * @returns - String of material define information
  5226. */
  5227. toString(): string;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5233. */
  5234. export class PerformanceMonitor {
  5235. private _enabled;
  5236. private _rollingFrameTime;
  5237. private _lastFrameTimeMs;
  5238. /**
  5239. * constructor
  5240. * @param frameSampleSize The number of samples required to saturate the sliding window
  5241. */
  5242. constructor(frameSampleSize?: number);
  5243. /**
  5244. * Samples current frame
  5245. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5246. */
  5247. sampleFrame(timeMs?: number): void;
  5248. /**
  5249. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5250. */
  5251. readonly averageFrameTime: number;
  5252. /**
  5253. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5254. */
  5255. readonly averageFrameTimeVariance: number;
  5256. /**
  5257. * Returns the frame time of the most recent frame
  5258. */
  5259. readonly instantaneousFrameTime: number;
  5260. /**
  5261. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5262. */
  5263. readonly averageFPS: number;
  5264. /**
  5265. * Returns the average framerate in frames per second using the most recent frame time
  5266. */
  5267. readonly instantaneousFPS: number;
  5268. /**
  5269. * Returns true if enough samples have been taken to completely fill the sliding window
  5270. */
  5271. readonly isSaturated: boolean;
  5272. /**
  5273. * Enables contributions to the sliding window sample set
  5274. */
  5275. enable(): void;
  5276. /**
  5277. * Disables contributions to the sliding window sample set
  5278. * Samples will not be interpolated over the disabled period
  5279. */
  5280. disable(): void;
  5281. /**
  5282. * Returns true if sampling is enabled
  5283. */
  5284. readonly isEnabled: boolean;
  5285. /**
  5286. * Resets performance monitor
  5287. */
  5288. reset(): void;
  5289. }
  5290. /**
  5291. * RollingAverage
  5292. *
  5293. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5294. */
  5295. export class RollingAverage {
  5296. /**
  5297. * Current average
  5298. */
  5299. average: number;
  5300. /**
  5301. * Current variance
  5302. */
  5303. variance: number;
  5304. protected _samples: Array<number>;
  5305. protected _sampleCount: number;
  5306. protected _pos: number;
  5307. protected _m2: number;
  5308. /**
  5309. * constructor
  5310. * @param length The number of samples required to saturate the sliding window
  5311. */
  5312. constructor(length: number);
  5313. /**
  5314. * Adds a sample to the sample set
  5315. * @param v The sample value
  5316. */
  5317. add(v: number): void;
  5318. /**
  5319. * Returns previously added values or null if outside of history or outside the sliding window domain
  5320. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5321. * @return Value previously recorded with add() or null if outside of range
  5322. */
  5323. history(i: number): number;
  5324. /**
  5325. * Returns true if enough samples have been taken to completely fill the sliding window
  5326. * @return true if sample-set saturated
  5327. */
  5328. isSaturated(): boolean;
  5329. /**
  5330. * Resets the rolling average (equivalent to 0 samples taken so far)
  5331. */
  5332. reset(): void;
  5333. /**
  5334. * Wraps a value around the sample range boundaries
  5335. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5336. * @return Wrapped position in sample range
  5337. */
  5338. protected _wrapPosition(i: number): number;
  5339. }
  5340. }
  5341. declare module BABYLON {
  5342. /**
  5343. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5344. * The underlying implementation relies on an associative array to ensure the best performances.
  5345. * The value can be anything including 'null' but except 'undefined'
  5346. */
  5347. export class StringDictionary<T> {
  5348. /**
  5349. * This will clear this dictionary and copy the content from the 'source' one.
  5350. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5351. * @param source the dictionary to take the content from and copy to this dictionary
  5352. */
  5353. copyFrom(source: StringDictionary<T>): void;
  5354. /**
  5355. * Get a value based from its key
  5356. * @param key the given key to get the matching value from
  5357. * @return the value if found, otherwise undefined is returned
  5358. */
  5359. get(key: string): T | undefined;
  5360. /**
  5361. * Get a value from its key or add it if it doesn't exist.
  5362. * This method will ensure you that a given key/data will be present in the dictionary.
  5363. * @param key the given key to get the matching value from
  5364. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5365. * The factory will only be invoked if there's no data for the given key.
  5366. * @return the value corresponding to the key.
  5367. */
  5368. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5369. /**
  5370. * Get a value from its key if present in the dictionary otherwise add it
  5371. * @param key the key to get the value from
  5372. * @param val if there's no such key/value pair in the dictionary add it with this value
  5373. * @return the value corresponding to the key
  5374. */
  5375. getOrAdd(key: string, val: T): T;
  5376. /**
  5377. * Check if there's a given key in the dictionary
  5378. * @param key the key to check for
  5379. * @return true if the key is present, false otherwise
  5380. */
  5381. contains(key: string): boolean;
  5382. /**
  5383. * Add a new key and its corresponding value
  5384. * @param key the key to add
  5385. * @param value the value corresponding to the key
  5386. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5387. */
  5388. add(key: string, value: T): boolean;
  5389. /**
  5390. * Update a specific value associated to a key
  5391. * @param key defines the key to use
  5392. * @param value defines the value to store
  5393. * @returns true if the value was updated (or false if the key was not found)
  5394. */
  5395. set(key: string, value: T): boolean;
  5396. /**
  5397. * Get the element of the given key and remove it from the dictionary
  5398. * @param key defines the key to search
  5399. * @returns the value associated with the key or null if not found
  5400. */
  5401. getAndRemove(key: string): Nullable<T>;
  5402. /**
  5403. * Remove a key/value from the dictionary.
  5404. * @param key the key to remove
  5405. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5406. */
  5407. remove(key: string): boolean;
  5408. /**
  5409. * Clear the whole content of the dictionary
  5410. */
  5411. clear(): void;
  5412. /**
  5413. * Gets the current count
  5414. */
  5415. readonly count: number;
  5416. /**
  5417. * Execute a callback on each key/val of the dictionary.
  5418. * Note that you can remove any element in this dictionary in the callback implementation
  5419. * @param callback the callback to execute on a given key/value pair
  5420. */
  5421. forEach(callback: (key: string, val: T) => void): void;
  5422. /**
  5423. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5424. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5425. * Note that you can remove any element in this dictionary in the callback implementation
  5426. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5427. * @returns the first item
  5428. */
  5429. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5430. private _count;
  5431. private _data;
  5432. }
  5433. }
  5434. declare module BABYLON {
  5435. /**
  5436. * Helper class that provides a small promise polyfill
  5437. */
  5438. export class PromisePolyfill {
  5439. /**
  5440. * Static function used to check if the polyfill is required
  5441. * If this is the case then the function will inject the polyfill to window.Promise
  5442. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5443. */
  5444. static Apply(force?: boolean): void;
  5445. }
  5446. }
  5447. declare module BABYLON {
  5448. /**
  5449. * Class used to store data that will be store in GPU memory
  5450. */
  5451. export class Buffer {
  5452. private _engine;
  5453. private _buffer;
  5454. /** @hidden */
  5455. _data: Nullable<DataArray>;
  5456. private _updatable;
  5457. private _instanced;
  5458. /**
  5459. * Gets the byte stride.
  5460. */
  5461. readonly byteStride: number;
  5462. /**
  5463. * Constructor
  5464. * @param engine the engine
  5465. * @param data the data to use for this buffer
  5466. * @param updatable whether the data is updatable
  5467. * @param stride the stride (optional)
  5468. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5469. * @param instanced whether the buffer is instanced (optional)
  5470. * @param useBytes set to true if the stride in in bytes (optional)
  5471. */
  5472. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5473. /**
  5474. * Create a new VertexBuffer based on the current buffer
  5475. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5476. * @param offset defines offset in the buffer (0 by default)
  5477. * @param size defines the size in floats of attributes (position is 3 for instance)
  5478. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5479. * @param instanced defines if the vertex buffer contains indexed data
  5480. * @param useBytes defines if the offset and stride are in bytes
  5481. * @returns the new vertex buffer
  5482. */
  5483. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5484. /**
  5485. * Gets a boolean indicating if the Buffer is updatable?
  5486. * @returns true if the buffer is updatable
  5487. */
  5488. isUpdatable(): boolean;
  5489. /**
  5490. * Gets current buffer's data
  5491. * @returns a DataArray or null
  5492. */
  5493. getData(): Nullable<DataArray>;
  5494. /**
  5495. * Gets underlying native buffer
  5496. * @returns underlying native buffer
  5497. */
  5498. getBuffer(): Nullable<WebGLBuffer>;
  5499. /**
  5500. * Gets the stride in float32 units (i.e. byte stride / 4).
  5501. * May not be an integer if the byte stride is not divisible by 4.
  5502. * DEPRECATED. Use byteStride instead.
  5503. * @returns the stride in float32 units
  5504. */
  5505. getStrideSize(): number;
  5506. /**
  5507. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5508. * @param data defines the data to store
  5509. */
  5510. create(data?: Nullable<DataArray>): void;
  5511. /** @hidden */
  5512. _rebuild(): void;
  5513. /**
  5514. * Update current buffer data
  5515. * @param data defines the data to store
  5516. */
  5517. update(data: DataArray): void;
  5518. /**
  5519. * Updates the data directly.
  5520. * @param data the new data
  5521. * @param offset the new offset
  5522. * @param vertexCount the vertex count (optional)
  5523. * @param useBytes set to true if the offset is in bytes
  5524. */
  5525. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5526. /**
  5527. * Release all resources
  5528. */
  5529. dispose(): void;
  5530. }
  5531. /**
  5532. * Specialized buffer used to store vertex data
  5533. */
  5534. export class VertexBuffer {
  5535. /** @hidden */
  5536. _buffer: Buffer;
  5537. private _kind;
  5538. private _size;
  5539. private _ownsBuffer;
  5540. private _instanced;
  5541. private _instanceDivisor;
  5542. /**
  5543. * The byte type.
  5544. */
  5545. static readonly BYTE: number;
  5546. /**
  5547. * The unsigned byte type.
  5548. */
  5549. static readonly UNSIGNED_BYTE: number;
  5550. /**
  5551. * The short type.
  5552. */
  5553. static readonly SHORT: number;
  5554. /**
  5555. * The unsigned short type.
  5556. */
  5557. static readonly UNSIGNED_SHORT: number;
  5558. /**
  5559. * The integer type.
  5560. */
  5561. static readonly INT: number;
  5562. /**
  5563. * The unsigned integer type.
  5564. */
  5565. static readonly UNSIGNED_INT: number;
  5566. /**
  5567. * The float type.
  5568. */
  5569. static readonly FLOAT: number;
  5570. /**
  5571. * Gets or sets the instance divisor when in instanced mode
  5572. */
  5573. instanceDivisor: number;
  5574. /**
  5575. * Gets the byte stride.
  5576. */
  5577. readonly byteStride: number;
  5578. /**
  5579. * Gets the byte offset.
  5580. */
  5581. readonly byteOffset: number;
  5582. /**
  5583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5584. */
  5585. readonly normalized: boolean;
  5586. /**
  5587. * Gets the data type of each component in the array.
  5588. */
  5589. readonly type: number;
  5590. /**
  5591. * Constructor
  5592. * @param engine the engine
  5593. * @param data the data to use for this vertex buffer
  5594. * @param kind the vertex buffer kind
  5595. * @param updatable whether the data is updatable
  5596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5597. * @param stride the stride (optional)
  5598. * @param instanced whether the buffer is instanced (optional)
  5599. * @param offset the offset of the data (optional)
  5600. * @param size the number of components (optional)
  5601. * @param type the type of the component (optional)
  5602. * @param normalized whether the data contains normalized data (optional)
  5603. * @param useBytes set to true if stride and offset are in bytes (optional)
  5604. */
  5605. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5606. /** @hidden */
  5607. _rebuild(): void;
  5608. /**
  5609. * Returns the kind of the VertexBuffer (string)
  5610. * @returns a string
  5611. */
  5612. getKind(): string;
  5613. /**
  5614. * Gets a boolean indicating if the VertexBuffer is updatable?
  5615. * @returns true if the buffer is updatable
  5616. */
  5617. isUpdatable(): boolean;
  5618. /**
  5619. * Gets current buffer's data
  5620. * @returns a DataArray or null
  5621. */
  5622. getData(): Nullable<DataArray>;
  5623. /**
  5624. * Gets underlying native buffer
  5625. * @returns underlying native buffer
  5626. */
  5627. getBuffer(): Nullable<WebGLBuffer>;
  5628. /**
  5629. * Gets the stride in float32 units (i.e. byte stride / 4).
  5630. * May not be an integer if the byte stride is not divisible by 4.
  5631. * DEPRECATED. Use byteStride instead.
  5632. * @returns the stride in float32 units
  5633. */
  5634. getStrideSize(): number;
  5635. /**
  5636. * Returns the offset as a multiple of the type byte length.
  5637. * DEPRECATED. Use byteOffset instead.
  5638. * @returns the offset in bytes
  5639. */
  5640. getOffset(): number;
  5641. /**
  5642. * Returns the number of components per vertex attribute (integer)
  5643. * @returns the size in float
  5644. */
  5645. getSize(): number;
  5646. /**
  5647. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5648. * @returns true if this buffer is instanced
  5649. */
  5650. getIsInstanced(): boolean;
  5651. /**
  5652. * Returns the instancing divisor, zero for non-instanced (integer).
  5653. * @returns a number
  5654. */
  5655. getInstanceDivisor(): number;
  5656. /**
  5657. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5658. * @param data defines the data to store
  5659. */
  5660. create(data?: DataArray): void;
  5661. /**
  5662. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5663. * This function will create a new buffer if the current one is not updatable
  5664. * @param data defines the data to store
  5665. */
  5666. update(data: DataArray): void;
  5667. /**
  5668. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5669. * Returns the directly updated WebGLBuffer.
  5670. * @param data the new data
  5671. * @param offset the new offset
  5672. * @param useBytes set to true if the offset is in bytes
  5673. */
  5674. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5675. /**
  5676. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5677. */
  5678. dispose(): void;
  5679. /**
  5680. * Enumerates each value of this vertex buffer as numbers.
  5681. * @param count the number of values to enumerate
  5682. * @param callback the callback function called for each value
  5683. */
  5684. forEach(count: number, callback: (value: number, index: number) => void): void;
  5685. /**
  5686. * Positions
  5687. */
  5688. static readonly PositionKind: string;
  5689. /**
  5690. * Normals
  5691. */
  5692. static readonly NormalKind: string;
  5693. /**
  5694. * Tangents
  5695. */
  5696. static readonly TangentKind: string;
  5697. /**
  5698. * Texture coordinates
  5699. */
  5700. static readonly UVKind: string;
  5701. /**
  5702. * Texture coordinates 2
  5703. */
  5704. static readonly UV2Kind: string;
  5705. /**
  5706. * Texture coordinates 3
  5707. */
  5708. static readonly UV3Kind: string;
  5709. /**
  5710. * Texture coordinates 4
  5711. */
  5712. static readonly UV4Kind: string;
  5713. /**
  5714. * Texture coordinates 5
  5715. */
  5716. static readonly UV5Kind: string;
  5717. /**
  5718. * Texture coordinates 6
  5719. */
  5720. static readonly UV6Kind: string;
  5721. /**
  5722. * Colors
  5723. */
  5724. static readonly ColorKind: string;
  5725. /**
  5726. * Matrix indices (for bones)
  5727. */
  5728. static readonly MatricesIndicesKind: string;
  5729. /**
  5730. * Matrix weights (for bones)
  5731. */
  5732. static readonly MatricesWeightsKind: string;
  5733. /**
  5734. * Additional matrix indices (for bones)
  5735. */
  5736. static readonly MatricesIndicesExtraKind: string;
  5737. /**
  5738. * Additional matrix weights (for bones)
  5739. */
  5740. static readonly MatricesWeightsExtraKind: string;
  5741. /**
  5742. * Deduces the stride given a kind.
  5743. * @param kind The kind string to deduce
  5744. * @returns The deduced stride
  5745. */
  5746. static DeduceStride(kind: string): number;
  5747. /**
  5748. * Gets the byte length of the given type.
  5749. * @param type the type
  5750. * @returns the number of bytes
  5751. */
  5752. static GetTypeByteLength(type: number): number;
  5753. /**
  5754. * Enumerates each value of the given parameters as numbers.
  5755. * @param data the data to enumerate
  5756. * @param byteOffset the byte offset of the data
  5757. * @param byteStride the byte stride of the data
  5758. * @param componentCount the number of components per element
  5759. * @param componentType the type of the component
  5760. * @param count the total number of components
  5761. * @param normalized whether the data is normalized
  5762. * @param callback the callback function called for each value
  5763. */
  5764. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5765. private static _GetFloatValue;
  5766. }
  5767. }
  5768. declare module BABYLON {
  5769. /**
  5770. * Class representing spherical polynomial coefficients to the 3rd degree
  5771. */
  5772. export class SphericalPolynomial {
  5773. /**
  5774. * The x coefficients of the spherical polynomial
  5775. */
  5776. x: Vector3;
  5777. /**
  5778. * The y coefficients of the spherical polynomial
  5779. */
  5780. y: Vector3;
  5781. /**
  5782. * The z coefficients of the spherical polynomial
  5783. */
  5784. z: Vector3;
  5785. /**
  5786. * The xx coefficients of the spherical polynomial
  5787. */
  5788. xx: Vector3;
  5789. /**
  5790. * The yy coefficients of the spherical polynomial
  5791. */
  5792. yy: Vector3;
  5793. /**
  5794. * The zz coefficients of the spherical polynomial
  5795. */
  5796. zz: Vector3;
  5797. /**
  5798. * The xy coefficients of the spherical polynomial
  5799. */
  5800. xy: Vector3;
  5801. /**
  5802. * The yz coefficients of the spherical polynomial
  5803. */
  5804. yz: Vector3;
  5805. /**
  5806. * The zx coefficients of the spherical polynomial
  5807. */
  5808. zx: Vector3;
  5809. /**
  5810. * Adds an ambient color to the spherical polynomial
  5811. * @param color the color to add
  5812. */
  5813. addAmbient(color: Color3): void;
  5814. /**
  5815. * Scales the spherical polynomial by the given amount
  5816. * @param scale the amount to scale
  5817. */
  5818. scale(scale: number): void;
  5819. /**
  5820. * Gets the spherical polynomial from harmonics
  5821. * @param harmonics the spherical harmonics
  5822. * @returns the spherical polynomial
  5823. */
  5824. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5825. /**
  5826. * Constructs a spherical polynomial from an array.
  5827. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5831. }
  5832. /**
  5833. * Class representing spherical harmonics coefficients to the 3rd degree
  5834. */
  5835. export class SphericalHarmonics {
  5836. /**
  5837. * The l0,0 coefficients of the spherical harmonics
  5838. */
  5839. l00: Vector3;
  5840. /**
  5841. * The l1,-1 coefficients of the spherical harmonics
  5842. */
  5843. l1_1: Vector3;
  5844. /**
  5845. * The l1,0 coefficients of the spherical harmonics
  5846. */
  5847. l10: Vector3;
  5848. /**
  5849. * The l1,1 coefficients of the spherical harmonics
  5850. */
  5851. l11: Vector3;
  5852. /**
  5853. * The l2,-2 coefficients of the spherical harmonics
  5854. */
  5855. l2_2: Vector3;
  5856. /**
  5857. * The l2,-1 coefficients of the spherical harmonics
  5858. */
  5859. l2_1: Vector3;
  5860. /**
  5861. * The l2,0 coefficients of the spherical harmonics
  5862. */
  5863. l20: Vector3;
  5864. /**
  5865. * The l2,1 coefficients of the spherical harmonics
  5866. */
  5867. l21: Vector3;
  5868. /**
  5869. * The l2,2 coefficients of the spherical harmonics
  5870. */
  5871. lL22: Vector3;
  5872. /**
  5873. * Adds a light to the spherical harmonics
  5874. * @param direction the direction of the light
  5875. * @param color the color of the light
  5876. * @param deltaSolidAngle the delta solid angle of the light
  5877. */
  5878. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5879. /**
  5880. * Scales the spherical harmonics by the given amount
  5881. * @param scale the amount to scale
  5882. */
  5883. scale(scale: number): void;
  5884. /**
  5885. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5886. *
  5887. * ```
  5888. * E_lm = A_l * L_lm
  5889. * ```
  5890. *
  5891. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5892. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5893. * the scaling factors are given in equation 9.
  5894. */
  5895. convertIncidentRadianceToIrradiance(): void;
  5896. /**
  5897. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5898. *
  5899. * ```
  5900. * L = (1/pi) * E * rho
  5901. * ```
  5902. *
  5903. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5904. */
  5905. convertIrradianceToLambertianRadiance(): void;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. /**
  5913. * Constructs a spherical harmonics from an array.
  5914. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5918. }
  5919. }
  5920. declare module BABYLON {
  5921. /**
  5922. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5923. */
  5924. export interface CubeMapInfo {
  5925. /**
  5926. * The pixel array for the front face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. front: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the back face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. back: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the left face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. left: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the right face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. right: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The pixel array for the up face.
  5947. * This is stored in format, left to right, up to down format.
  5948. */
  5949. up: Nullable<ArrayBufferView>;
  5950. /**
  5951. * The pixel array for the down face.
  5952. * This is stored in format, left to right, up to down format.
  5953. */
  5954. down: Nullable<ArrayBufferView>;
  5955. /**
  5956. * The size of the cubemap stored.
  5957. *
  5958. * Each faces will be size * size pixels.
  5959. */
  5960. size: number;
  5961. /**
  5962. * The format of the texture.
  5963. *
  5964. * RGBA, RGB.
  5965. */
  5966. format: number;
  5967. /**
  5968. * The type of the texture data.
  5969. *
  5970. * UNSIGNED_INT, FLOAT.
  5971. */
  5972. type: number;
  5973. /**
  5974. * Specifies whether the texture is in gamma space.
  5975. */
  5976. gammaSpace: boolean;
  5977. }
  5978. /**
  5979. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5980. */
  5981. export class PanoramaToCubeMapTools {
  5982. private static FACE_FRONT;
  5983. private static FACE_BACK;
  5984. private static FACE_RIGHT;
  5985. private static FACE_LEFT;
  5986. private static FACE_DOWN;
  5987. private static FACE_UP;
  5988. /**
  5989. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5990. *
  5991. * @param float32Array The source data.
  5992. * @param inputWidth The width of the input panorama.
  5993. * @param inputHeight The height of the input panorama.
  5994. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5995. * @return The cubemap data
  5996. */
  5997. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5998. private static CreateCubemapTexture;
  5999. private static CalcProjectionSpherical;
  6000. }
  6001. }
  6002. declare module BABYLON {
  6003. /**
  6004. * Helper class dealing with the extraction of spherical polynomial dataArray
  6005. * from a cube map.
  6006. */
  6007. export class CubeMapToSphericalPolynomialTools {
  6008. private static FileFaces;
  6009. /**
  6010. * Converts a texture to the according Spherical Polynomial data.
  6011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6012. *
  6013. * @param texture The texture to extract the information from.
  6014. * @return The Spherical Polynomial data.
  6015. */
  6016. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6017. /**
  6018. * Converts a cubemap to the according Spherical Polynomial data.
  6019. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6020. *
  6021. * @param cubeInfo The Cube map to extract the information from.
  6022. * @return The Spherical Polynomial data.
  6023. */
  6024. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6025. }
  6026. }
  6027. declare module BABYLON {
  6028. /**
  6029. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6030. * during the life time of the application.
  6031. */
  6032. export class EngineStore {
  6033. /** Gets the list of created engines */
  6034. static Instances: Engine[];
  6035. /**
  6036. * Gets the latest created engine
  6037. */
  6038. static readonly LastCreatedEngine: Nullable<Engine>;
  6039. /**
  6040. * Gets the latest created scene
  6041. */
  6042. static readonly LastCreatedScene: Nullable<Scene>;
  6043. }
  6044. }
  6045. declare module BABYLON {
  6046. /**
  6047. * Define options used to create a render target texture
  6048. */
  6049. export class RenderTargetCreationOptions {
  6050. /**
  6051. * Specifies is mipmaps must be generated
  6052. */
  6053. generateMipMaps?: boolean;
  6054. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6055. generateDepthBuffer?: boolean;
  6056. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6057. generateStencilBuffer?: boolean;
  6058. /** Defines texture type (int by default) */
  6059. type?: number;
  6060. /** Defines sampling mode (trilinear by default) */
  6061. samplingMode?: number;
  6062. /** Defines format (RGBA by default) */
  6063. format?: number;
  6064. }
  6065. }
  6066. declare module BABYLON {
  6067. /**
  6068. * @hidden
  6069. **/
  6070. export class _AlphaState {
  6071. private _isAlphaBlendDirty;
  6072. private _isBlendFunctionParametersDirty;
  6073. private _isBlendEquationParametersDirty;
  6074. private _isBlendConstantsDirty;
  6075. private _alphaBlend;
  6076. private _blendFunctionParameters;
  6077. private _blendEquationParameters;
  6078. private _blendConstants;
  6079. /**
  6080. * Initializes the state.
  6081. */
  6082. constructor();
  6083. readonly isDirty: boolean;
  6084. alphaBlend: boolean;
  6085. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6086. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6087. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6088. reset(): void;
  6089. apply(gl: WebGLRenderingContext): void;
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * @hidden
  6095. **/
  6096. export class _DepthCullingState {
  6097. private _isDepthTestDirty;
  6098. private _isDepthMaskDirty;
  6099. private _isDepthFuncDirty;
  6100. private _isCullFaceDirty;
  6101. private _isCullDirty;
  6102. private _isZOffsetDirty;
  6103. private _isFrontFaceDirty;
  6104. private _depthTest;
  6105. private _depthMask;
  6106. private _depthFunc;
  6107. private _cull;
  6108. private _cullFace;
  6109. private _zOffset;
  6110. private _frontFace;
  6111. /**
  6112. * Initializes the state.
  6113. */
  6114. constructor();
  6115. readonly isDirty: boolean;
  6116. zOffset: number;
  6117. cullFace: Nullable<number>;
  6118. cull: Nullable<boolean>;
  6119. depthFunc: Nullable<number>;
  6120. depthMask: boolean;
  6121. depthTest: boolean;
  6122. frontFace: Nullable<number>;
  6123. reset(): void;
  6124. apply(gl: WebGLRenderingContext): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. /**
  6129. * @hidden
  6130. **/
  6131. export class _StencilState {
  6132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6133. static readonly ALWAYS: number;
  6134. /** Passed to stencilOperation to specify that stencil value must be kept */
  6135. static readonly KEEP: number;
  6136. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6137. static readonly REPLACE: number;
  6138. private _isStencilTestDirty;
  6139. private _isStencilMaskDirty;
  6140. private _isStencilFuncDirty;
  6141. private _isStencilOpDirty;
  6142. private _stencilTest;
  6143. private _stencilMask;
  6144. private _stencilFunc;
  6145. private _stencilFuncRef;
  6146. private _stencilFuncMask;
  6147. private _stencilOpStencilFail;
  6148. private _stencilOpDepthFail;
  6149. private _stencilOpStencilDepthPass;
  6150. readonly isDirty: boolean;
  6151. stencilFunc: number;
  6152. stencilFuncRef: number;
  6153. stencilFuncMask: number;
  6154. stencilOpStencilFail: number;
  6155. stencilOpDepthFail: number;
  6156. stencilOpStencilDepthPass: number;
  6157. stencilMask: number;
  6158. stencilTest: boolean;
  6159. constructor();
  6160. reset(): void;
  6161. apply(gl: WebGLRenderingContext): void;
  6162. }
  6163. }
  6164. declare module BABYLON {
  6165. /**
  6166. * @hidden
  6167. **/
  6168. export class _TimeToken {
  6169. _startTimeQuery: Nullable<WebGLQuery>;
  6170. _endTimeQuery: Nullable<WebGLQuery>;
  6171. _timeElapsedQuery: Nullable<WebGLQuery>;
  6172. _timeElapsedQueryEnded: boolean;
  6173. }
  6174. }
  6175. declare module BABYLON {
  6176. /**
  6177. * Class used to store data associated with WebGL texture data for the engine
  6178. * This class should not be used directly
  6179. */
  6180. export class InternalTexture {
  6181. /** hidden */
  6182. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6183. /**
  6184. * The source of the texture data is unknown
  6185. */
  6186. static DATASOURCE_UNKNOWN: number;
  6187. /**
  6188. * Texture data comes from an URL
  6189. */
  6190. static DATASOURCE_URL: number;
  6191. /**
  6192. * Texture data is only used for temporary storage
  6193. */
  6194. static DATASOURCE_TEMP: number;
  6195. /**
  6196. * Texture data comes from raw data (ArrayBuffer)
  6197. */
  6198. static DATASOURCE_RAW: number;
  6199. /**
  6200. * Texture content is dynamic (video or dynamic texture)
  6201. */
  6202. static DATASOURCE_DYNAMIC: number;
  6203. /**
  6204. * Texture content is generated by rendering to it
  6205. */
  6206. static DATASOURCE_RENDERTARGET: number;
  6207. /**
  6208. * Texture content is part of a multi render target process
  6209. */
  6210. static DATASOURCE_MULTIRENDERTARGET: number;
  6211. /**
  6212. * Texture data comes from a cube data file
  6213. */
  6214. static DATASOURCE_CUBE: number;
  6215. /**
  6216. * Texture data comes from a raw cube data
  6217. */
  6218. static DATASOURCE_CUBERAW: number;
  6219. /**
  6220. * Texture data come from a prefiltered cube data file
  6221. */
  6222. static DATASOURCE_CUBEPREFILTERED: number;
  6223. /**
  6224. * Texture content is raw 3D data
  6225. */
  6226. static DATASOURCE_RAW3D: number;
  6227. /**
  6228. * Texture content is a depth texture
  6229. */
  6230. static DATASOURCE_DEPTHTEXTURE: number;
  6231. /**
  6232. * Texture data comes from a raw cube data encoded with RGBD
  6233. */
  6234. static DATASOURCE_CUBERAW_RGBD: number;
  6235. /**
  6236. * Defines if the texture is ready
  6237. */
  6238. isReady: boolean;
  6239. /**
  6240. * Defines if the texture is a cube texture
  6241. */
  6242. isCube: boolean;
  6243. /**
  6244. * Defines if the texture contains 3D data
  6245. */
  6246. is3D: boolean;
  6247. /**
  6248. * Defines if the texture contains multiview data
  6249. */
  6250. isMultiview: boolean;
  6251. /**
  6252. * Gets the URL used to load this texture
  6253. */
  6254. url: string;
  6255. /**
  6256. * Gets the sampling mode of the texture
  6257. */
  6258. samplingMode: number;
  6259. /**
  6260. * Gets a boolean indicating if the texture needs mipmaps generation
  6261. */
  6262. generateMipMaps: boolean;
  6263. /**
  6264. * Gets the number of samples used by the texture (WebGL2+ only)
  6265. */
  6266. samples: number;
  6267. /**
  6268. * Gets the type of the texture (int, float...)
  6269. */
  6270. type: number;
  6271. /**
  6272. * Gets the format of the texture (RGB, RGBA...)
  6273. */
  6274. format: number;
  6275. /**
  6276. * Observable called when the texture is loaded
  6277. */
  6278. onLoadedObservable: Observable<InternalTexture>;
  6279. /**
  6280. * Gets the width of the texture
  6281. */
  6282. width: number;
  6283. /**
  6284. * Gets the height of the texture
  6285. */
  6286. height: number;
  6287. /**
  6288. * Gets the depth of the texture
  6289. */
  6290. depth: number;
  6291. /**
  6292. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6293. */
  6294. baseWidth: number;
  6295. /**
  6296. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6297. */
  6298. baseHeight: number;
  6299. /**
  6300. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6301. */
  6302. baseDepth: number;
  6303. /**
  6304. * Gets a boolean indicating if the texture is inverted on Y axis
  6305. */
  6306. invertY: boolean;
  6307. /** @hidden */
  6308. _invertVScale: boolean;
  6309. /** @hidden */
  6310. _associatedChannel: number;
  6311. /** @hidden */
  6312. _dataSource: number;
  6313. /** @hidden */
  6314. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6315. /** @hidden */
  6316. _bufferView: Nullable<ArrayBufferView>;
  6317. /** @hidden */
  6318. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6319. /** @hidden */
  6320. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6321. /** @hidden */
  6322. _size: number;
  6323. /** @hidden */
  6324. _extension: string;
  6325. /** @hidden */
  6326. _files: Nullable<string[]>;
  6327. /** @hidden */
  6328. _workingCanvas: Nullable<HTMLCanvasElement>;
  6329. /** @hidden */
  6330. _workingContext: Nullable<CanvasRenderingContext2D>;
  6331. /** @hidden */
  6332. _framebuffer: Nullable<WebGLFramebuffer>;
  6333. /** @hidden */
  6334. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6335. /** @hidden */
  6336. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6337. /** @hidden */
  6338. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6339. /** @hidden */
  6340. _attachments: Nullable<number[]>;
  6341. /** @hidden */
  6342. _cachedCoordinatesMode: Nullable<number>;
  6343. /** @hidden */
  6344. _cachedWrapU: Nullable<number>;
  6345. /** @hidden */
  6346. _cachedWrapV: Nullable<number>;
  6347. /** @hidden */
  6348. _cachedWrapR: Nullable<number>;
  6349. /** @hidden */
  6350. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6351. /** @hidden */
  6352. _isDisabled: boolean;
  6353. /** @hidden */
  6354. _compression: Nullable<string>;
  6355. /** @hidden */
  6356. _generateStencilBuffer: boolean;
  6357. /** @hidden */
  6358. _generateDepthBuffer: boolean;
  6359. /** @hidden */
  6360. _comparisonFunction: number;
  6361. /** @hidden */
  6362. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6363. /** @hidden */
  6364. _lodGenerationScale: number;
  6365. /** @hidden */
  6366. _lodGenerationOffset: number;
  6367. /** @hidden */
  6368. _colorTextureArray: Nullable<WebGLTexture>;
  6369. /** @hidden */
  6370. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6371. /** @hidden */
  6372. _lodTextureHigh: Nullable<BaseTexture>;
  6373. /** @hidden */
  6374. _lodTextureMid: Nullable<BaseTexture>;
  6375. /** @hidden */
  6376. _lodTextureLow: Nullable<BaseTexture>;
  6377. /** @hidden */
  6378. _isRGBD: boolean;
  6379. /** @hidden */
  6380. _webGLTexture: Nullable<WebGLTexture>;
  6381. /** @hidden */
  6382. _references: number;
  6383. private _engine;
  6384. /**
  6385. * Gets the Engine the texture belongs to.
  6386. * @returns The babylon engine
  6387. */
  6388. getEngine(): Engine;
  6389. /**
  6390. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6391. */
  6392. readonly dataSource: number;
  6393. /**
  6394. * Creates a new InternalTexture
  6395. * @param engine defines the engine to use
  6396. * @param dataSource defines the type of data that will be used
  6397. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6398. */
  6399. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6400. /**
  6401. * Increments the number of references (ie. the number of Texture that point to it)
  6402. */
  6403. incrementReferences(): void;
  6404. /**
  6405. * Change the size of the texture (not the size of the content)
  6406. * @param width defines the new width
  6407. * @param height defines the new height
  6408. * @param depth defines the new depth (1 by default)
  6409. */
  6410. updateSize(width: int, height: int, depth?: int): void;
  6411. /** @hidden */
  6412. _rebuild(): void;
  6413. /** @hidden */
  6414. _swapAndDie(target: InternalTexture): void;
  6415. /**
  6416. * Dispose the current allocated resources
  6417. */
  6418. dispose(): void;
  6419. }
  6420. }
  6421. declare module BABYLON {
  6422. /**
  6423. * This represents the main contract an easing function should follow.
  6424. * Easing functions are used throughout the animation system.
  6425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6426. */
  6427. export interface IEasingFunction {
  6428. /**
  6429. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6430. * of the easing function.
  6431. * The link below provides some of the most common examples of easing functions.
  6432. * @see https://easings.net/
  6433. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6434. * @returns the corresponding value on the curve defined by the easing function
  6435. */
  6436. ease(gradient: number): number;
  6437. }
  6438. /**
  6439. * Base class used for every default easing function.
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class EasingFunction implements IEasingFunction {
  6443. /**
  6444. * Interpolation follows the mathematical formula associated with the easing function.
  6445. */
  6446. static readonly EASINGMODE_EASEIN: number;
  6447. /**
  6448. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6449. */
  6450. static readonly EASINGMODE_EASEOUT: number;
  6451. /**
  6452. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6453. */
  6454. static readonly EASINGMODE_EASEINOUT: number;
  6455. private _easingMode;
  6456. /**
  6457. * Sets the easing mode of the current function.
  6458. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6459. */
  6460. setEasingMode(easingMode: number): void;
  6461. /**
  6462. * Gets the current easing mode.
  6463. * @returns the easing mode
  6464. */
  6465. getEasingMode(): number;
  6466. /**
  6467. * @hidden
  6468. */
  6469. easeInCore(gradient: number): number;
  6470. /**
  6471. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6472. * of the easing function.
  6473. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6474. * @returns the corresponding value on the curve defined by the easing function
  6475. */
  6476. ease(gradient: number): number;
  6477. }
  6478. /**
  6479. * Easing function with a circle shape (see link below).
  6480. * @see https://easings.net/#easeInCirc
  6481. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6482. */
  6483. export class CircleEase extends EasingFunction implements IEasingFunction {
  6484. /** @hidden */
  6485. easeInCore(gradient: number): number;
  6486. }
  6487. /**
  6488. * Easing function with a ease back shape (see link below).
  6489. * @see https://easings.net/#easeInBack
  6490. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6491. */
  6492. export class BackEase extends EasingFunction implements IEasingFunction {
  6493. /** Defines the amplitude of the function */
  6494. amplitude: number;
  6495. /**
  6496. * Instantiates a back ease easing
  6497. * @see https://easings.net/#easeInBack
  6498. * @param amplitude Defines the amplitude of the function
  6499. */
  6500. constructor(
  6501. /** Defines the amplitude of the function */
  6502. amplitude?: number);
  6503. /** @hidden */
  6504. easeInCore(gradient: number): number;
  6505. }
  6506. /**
  6507. * Easing function with a bouncing shape (see link below).
  6508. * @see https://easings.net/#easeInBounce
  6509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6510. */
  6511. export class BounceEase extends EasingFunction implements IEasingFunction {
  6512. /** Defines the number of bounces */
  6513. bounces: number;
  6514. /** Defines the amplitude of the bounce */
  6515. bounciness: number;
  6516. /**
  6517. * Instantiates a bounce easing
  6518. * @see https://easings.net/#easeInBounce
  6519. * @param bounces Defines the number of bounces
  6520. * @param bounciness Defines the amplitude of the bounce
  6521. */
  6522. constructor(
  6523. /** Defines the number of bounces */
  6524. bounces?: number,
  6525. /** Defines the amplitude of the bounce */
  6526. bounciness?: number);
  6527. /** @hidden */
  6528. easeInCore(gradient: number): number;
  6529. }
  6530. /**
  6531. * Easing function with a power of 3 shape (see link below).
  6532. * @see https://easings.net/#easeInCubic
  6533. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6534. */
  6535. export class CubicEase extends EasingFunction implements IEasingFunction {
  6536. /** @hidden */
  6537. easeInCore(gradient: number): number;
  6538. }
  6539. /**
  6540. * Easing function with an elastic shape (see link below).
  6541. * @see https://easings.net/#easeInElastic
  6542. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6543. */
  6544. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6545. /** Defines the number of oscillations*/
  6546. oscillations: number;
  6547. /** Defines the amplitude of the oscillations*/
  6548. springiness: number;
  6549. /**
  6550. * Instantiates an elastic easing function
  6551. * @see https://easings.net/#easeInElastic
  6552. * @param oscillations Defines the number of oscillations
  6553. * @param springiness Defines the amplitude of the oscillations
  6554. */
  6555. constructor(
  6556. /** Defines the number of oscillations*/
  6557. oscillations?: number,
  6558. /** Defines the amplitude of the oscillations*/
  6559. springiness?: number);
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with an exponential shape (see link below).
  6565. * @see https://easings.net/#easeInExpo
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6569. /** Defines the exponent of the function */
  6570. exponent: number;
  6571. /**
  6572. * Instantiates an exponential easing function
  6573. * @see https://easings.net/#easeInExpo
  6574. * @param exponent Defines the exponent of the function
  6575. */
  6576. constructor(
  6577. /** Defines the exponent of the function */
  6578. exponent?: number);
  6579. /** @hidden */
  6580. easeInCore(gradient: number): number;
  6581. }
  6582. /**
  6583. * Easing function with a power shape (see link below).
  6584. * @see https://easings.net/#easeInQuad
  6585. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6586. */
  6587. export class PowerEase extends EasingFunction implements IEasingFunction {
  6588. /** Defines the power of the function */
  6589. power: number;
  6590. /**
  6591. * Instantiates an power base easing function
  6592. * @see https://easings.net/#easeInQuad
  6593. * @param power Defines the power of the function
  6594. */
  6595. constructor(
  6596. /** Defines the power of the function */
  6597. power?: number);
  6598. /** @hidden */
  6599. easeInCore(gradient: number): number;
  6600. }
  6601. /**
  6602. * Easing function with a power of 2 shape (see link below).
  6603. * @see https://easings.net/#easeInQuad
  6604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6605. */
  6606. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6607. /** @hidden */
  6608. easeInCore(gradient: number): number;
  6609. }
  6610. /**
  6611. * Easing function with a power of 4 shape (see link below).
  6612. * @see https://easings.net/#easeInQuart
  6613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6614. */
  6615. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6616. /** @hidden */
  6617. easeInCore(gradient: number): number;
  6618. }
  6619. /**
  6620. * Easing function with a power of 5 shape (see link below).
  6621. * @see https://easings.net/#easeInQuint
  6622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6623. */
  6624. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6625. /** @hidden */
  6626. easeInCore(gradient: number): number;
  6627. }
  6628. /**
  6629. * Easing function with a sin shape (see link below).
  6630. * @see https://easings.net/#easeInSine
  6631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6632. */
  6633. export class SineEase extends EasingFunction implements IEasingFunction {
  6634. /** @hidden */
  6635. easeInCore(gradient: number): number;
  6636. }
  6637. /**
  6638. * Easing function with a bezier shape (see link below).
  6639. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6640. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6641. */
  6642. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6643. /** Defines the x component of the start tangent in the bezier curve */
  6644. x1: number;
  6645. /** Defines the y component of the start tangent in the bezier curve */
  6646. y1: number;
  6647. /** Defines the x component of the end tangent in the bezier curve */
  6648. x2: number;
  6649. /** Defines the y component of the end tangent in the bezier curve */
  6650. y2: number;
  6651. /**
  6652. * Instantiates a bezier function
  6653. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6654. * @param x1 Defines the x component of the start tangent in the bezier curve
  6655. * @param y1 Defines the y component of the start tangent in the bezier curve
  6656. * @param x2 Defines the x component of the end tangent in the bezier curve
  6657. * @param y2 Defines the y component of the end tangent in the bezier curve
  6658. */
  6659. constructor(
  6660. /** Defines the x component of the start tangent in the bezier curve */
  6661. x1?: number,
  6662. /** Defines the y component of the start tangent in the bezier curve */
  6663. y1?: number,
  6664. /** Defines the x component of the end tangent in the bezier curve */
  6665. x2?: number,
  6666. /** Defines the y component of the end tangent in the bezier curve */
  6667. y2?: number);
  6668. /** @hidden */
  6669. easeInCore(gradient: number): number;
  6670. }
  6671. }
  6672. declare module BABYLON {
  6673. /**
  6674. * Defines an interface which represents an animation key frame
  6675. */
  6676. export interface IAnimationKey {
  6677. /**
  6678. * Frame of the key frame
  6679. */
  6680. frame: number;
  6681. /**
  6682. * Value at the specifies key frame
  6683. */
  6684. value: any;
  6685. /**
  6686. * The input tangent for the cubic hermite spline
  6687. */
  6688. inTangent?: any;
  6689. /**
  6690. * The output tangent for the cubic hermite spline
  6691. */
  6692. outTangent?: any;
  6693. /**
  6694. * The animation interpolation type
  6695. */
  6696. interpolation?: AnimationKeyInterpolation;
  6697. }
  6698. /**
  6699. * Enum for the animation key frame interpolation type
  6700. */
  6701. export enum AnimationKeyInterpolation {
  6702. /**
  6703. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6704. */
  6705. STEP = 1
  6706. }
  6707. }
  6708. declare module BABYLON {
  6709. /**
  6710. * Represents the range of an animation
  6711. */
  6712. export class AnimationRange {
  6713. /**The name of the animation range**/
  6714. name: string;
  6715. /**The starting frame of the animation */
  6716. from: number;
  6717. /**The ending frame of the animation*/
  6718. to: number;
  6719. /**
  6720. * Initializes the range of an animation
  6721. * @param name The name of the animation range
  6722. * @param from The starting frame of the animation
  6723. * @param to The ending frame of the animation
  6724. */
  6725. constructor(
  6726. /**The name of the animation range**/
  6727. name: string,
  6728. /**The starting frame of the animation */
  6729. from: number,
  6730. /**The ending frame of the animation*/
  6731. to: number);
  6732. /**
  6733. * Makes a copy of the animation range
  6734. * @returns A copy of the animation range
  6735. */
  6736. clone(): AnimationRange;
  6737. }
  6738. }
  6739. declare module BABYLON {
  6740. /**
  6741. * Composed of a frame, and an action function
  6742. */
  6743. export class AnimationEvent {
  6744. /** The frame for which the event is triggered **/
  6745. frame: number;
  6746. /** The event to perform when triggered **/
  6747. action: (currentFrame: number) => void;
  6748. /** Specifies if the event should be triggered only once**/
  6749. onlyOnce?: boolean | undefined;
  6750. /**
  6751. * Specifies if the animation event is done
  6752. */
  6753. isDone: boolean;
  6754. /**
  6755. * Initializes the animation event
  6756. * @param frame The frame for which the event is triggered
  6757. * @param action The event to perform when triggered
  6758. * @param onlyOnce Specifies if the event should be triggered only once
  6759. */
  6760. constructor(
  6761. /** The frame for which the event is triggered **/
  6762. frame: number,
  6763. /** The event to perform when triggered **/
  6764. action: (currentFrame: number) => void,
  6765. /** Specifies if the event should be triggered only once**/
  6766. onlyOnce?: boolean | undefined);
  6767. /** @hidden */
  6768. _clone(): AnimationEvent;
  6769. }
  6770. }
  6771. declare module BABYLON {
  6772. /**
  6773. * Interface used to define a behavior
  6774. */
  6775. export interface Behavior<T> {
  6776. /** gets or sets behavior's name */
  6777. name: string;
  6778. /**
  6779. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6780. */
  6781. init(): void;
  6782. /**
  6783. * Called when the behavior is attached to a target
  6784. * @param target defines the target where the behavior is attached to
  6785. */
  6786. attach(target: T): void;
  6787. /**
  6788. * Called when the behavior is detached from its target
  6789. */
  6790. detach(): void;
  6791. }
  6792. /**
  6793. * Interface implemented by classes supporting behaviors
  6794. */
  6795. export interface IBehaviorAware<T> {
  6796. /**
  6797. * Attach a behavior
  6798. * @param behavior defines the behavior to attach
  6799. * @returns the current host
  6800. */
  6801. addBehavior(behavior: Behavior<T>): T;
  6802. /**
  6803. * Remove a behavior from the current object
  6804. * @param behavior defines the behavior to detach
  6805. * @returns the current host
  6806. */
  6807. removeBehavior(behavior: Behavior<T>): T;
  6808. /**
  6809. * Gets a behavior using its name to search
  6810. * @param name defines the name to search
  6811. * @returns the behavior or null if not found
  6812. */
  6813. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6814. }
  6815. }
  6816. declare module BABYLON {
  6817. /**
  6818. * @hidden
  6819. */
  6820. export class IntersectionInfo {
  6821. bu: Nullable<number>;
  6822. bv: Nullable<number>;
  6823. distance: number;
  6824. faceId: number;
  6825. subMeshId: number;
  6826. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6827. }
  6828. }
  6829. declare module BABYLON {
  6830. /**
  6831. * Class used to store bounding sphere information
  6832. */
  6833. export class BoundingSphere {
  6834. /**
  6835. * Gets the center of the bounding sphere in local space
  6836. */
  6837. readonly center: Vector3;
  6838. /**
  6839. * Radius of the bounding sphere in local space
  6840. */
  6841. radius: number;
  6842. /**
  6843. * Gets the center of the bounding sphere in world space
  6844. */
  6845. readonly centerWorld: Vector3;
  6846. /**
  6847. * Radius of the bounding sphere in world space
  6848. */
  6849. radiusWorld: number;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * Creates a new bounding sphere
  6862. * @param min defines the minimum vector (in local space)
  6863. * @param max defines the maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6867. /**
  6868. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6869. * @param min defines the new minimum vector (in local space)
  6870. * @param max defines the new maximum vector (in local space)
  6871. * @param worldMatrix defines the new world matrix
  6872. */
  6873. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Scale the current bounding sphere by applying a scale factor
  6876. * @param factor defines the scale factor to apply
  6877. * @returns the current bounding box
  6878. */
  6879. scale(factor: number): BoundingSphere;
  6880. /**
  6881. * Gets the world matrix of the bounding box
  6882. * @returns a matrix
  6883. */
  6884. getWorldMatrix(): DeepImmutable<Matrix>;
  6885. /** @hidden */
  6886. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6887. /**
  6888. * Tests if the bounding sphere is intersecting the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an intersection
  6891. */
  6892. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if the bounding sphere center is in between the frustum planes.
  6895. * Used for optimistic fast inclusion.
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if the sphere center is in between the frustum planes
  6898. */
  6899. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding sphere
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding sphere
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Checks if two sphere intersct
  6908. * @param sphere0 sphere 0
  6909. * @param sphere1 sphere 1
  6910. * @returns true if the speres intersect
  6911. */
  6912. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6913. }
  6914. }
  6915. declare module BABYLON {
  6916. /**
  6917. * Class used to store bounding box information
  6918. */
  6919. export class BoundingBox implements ICullable {
  6920. /**
  6921. * Gets the 8 vectors representing the bounding box in local space
  6922. */
  6923. readonly vectors: Vector3[];
  6924. /**
  6925. * Gets the center of the bounding box in local space
  6926. */
  6927. readonly center: Vector3;
  6928. /**
  6929. * Gets the center of the bounding box in world space
  6930. */
  6931. readonly centerWorld: Vector3;
  6932. /**
  6933. * Gets the extend size in local space
  6934. */
  6935. readonly extendSize: Vector3;
  6936. /**
  6937. * Gets the extend size in world space
  6938. */
  6939. readonly extendSizeWorld: Vector3;
  6940. /**
  6941. * Gets the OBB (object bounding box) directions
  6942. */
  6943. readonly directions: Vector3[];
  6944. /**
  6945. * Gets the 8 vectors representing the bounding box in world space
  6946. */
  6947. readonly vectorsWorld: Vector3[];
  6948. /**
  6949. * Gets the minimum vector in world space
  6950. */
  6951. readonly minimumWorld: Vector3;
  6952. /**
  6953. * Gets the maximum vector in world space
  6954. */
  6955. readonly maximumWorld: Vector3;
  6956. /**
  6957. * Gets the minimum vector in local space
  6958. */
  6959. readonly minimum: Vector3;
  6960. /**
  6961. * Gets the maximum vector in local space
  6962. */
  6963. readonly maximum: Vector3;
  6964. private _worldMatrix;
  6965. private static readonly TmpVector3;
  6966. /**
  6967. * @hidden
  6968. */
  6969. _tag: number;
  6970. /**
  6971. * Creates a new bounding box
  6972. * @param min defines the minimum vector (in local space)
  6973. * @param max defines the maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6977. /**
  6978. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6979. * @param min defines the new minimum vector (in local space)
  6980. * @param max defines the new maximum vector (in local space)
  6981. * @param worldMatrix defines the new world matrix
  6982. */
  6983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * Scale the current bounding box by applying a scale factor
  6986. * @param factor defines the scale factor to apply
  6987. * @returns the current bounding box
  6988. */
  6989. scale(factor: number): BoundingBox;
  6990. /**
  6991. * Gets the world matrix of the bounding box
  6992. * @returns a matrix
  6993. */
  6994. getWorldMatrix(): DeepImmutable<Matrix>;
  6995. /** @hidden */
  6996. _update(world: DeepImmutable<Matrix>): void;
  6997. /**
  6998. * Tests if the bounding box is intersecting the frustum planes
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @returns true if there is an intersection
  7001. */
  7002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if the bounding box is entirely inside the frustum planes
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if there is an inclusion
  7007. */
  7008. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding box
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding box
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Tests if the bounding box intersects with a bounding sphere
  7017. * @param sphere defines the sphere to test
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7021. /**
  7022. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7023. * @param min defines the min vector to use
  7024. * @param max defines the max vector to use
  7025. * @returns true if there is an intersection
  7026. */
  7027. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7028. /**
  7029. * Tests if two bounding boxes are intersections
  7030. * @param box0 defines the first box to test
  7031. * @param box1 defines the second box to test
  7032. * @returns true if there is an intersection
  7033. */
  7034. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7035. /**
  7036. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7037. * @param minPoint defines the minimum vector of the bounding box
  7038. * @param maxPoint defines the maximum vector of the bounding box
  7039. * @param sphereCenter defines the sphere center
  7040. * @param sphereRadius defines the sphere radius
  7041. * @returns true if there is an intersection
  7042. */
  7043. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an inclusion
  7049. */
  7050. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. /**
  7052. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7053. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7054. * @param frustumPlanes defines the frustum planes to test
  7055. * @return true if there is an intersection
  7056. */
  7057. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7058. }
  7059. }
  7060. declare module BABYLON {
  7061. /** @hidden */
  7062. export class Collider {
  7063. /** Define if a collision was found */
  7064. collisionFound: boolean;
  7065. /**
  7066. * Define last intersection point in local space
  7067. */
  7068. intersectionPoint: Vector3;
  7069. /**
  7070. * Define last collided mesh
  7071. */
  7072. collidedMesh: Nullable<AbstractMesh>;
  7073. private _collisionPoint;
  7074. private _planeIntersectionPoint;
  7075. private _tempVector;
  7076. private _tempVector2;
  7077. private _tempVector3;
  7078. private _tempVector4;
  7079. private _edge;
  7080. private _baseToVertex;
  7081. private _destinationPoint;
  7082. private _slidePlaneNormal;
  7083. private _displacementVector;
  7084. /** @hidden */
  7085. _radius: Vector3;
  7086. /** @hidden */
  7087. _retry: number;
  7088. private _velocity;
  7089. private _basePoint;
  7090. private _epsilon;
  7091. /** @hidden */
  7092. _velocityWorldLength: number;
  7093. /** @hidden */
  7094. _basePointWorld: Vector3;
  7095. private _velocityWorld;
  7096. private _normalizedVelocity;
  7097. /** @hidden */
  7098. _initialVelocity: Vector3;
  7099. /** @hidden */
  7100. _initialPosition: Vector3;
  7101. private _nearestDistance;
  7102. private _collisionMask;
  7103. collisionMask: number;
  7104. /**
  7105. * Gets the plane normal used to compute the sliding response (in local space)
  7106. */
  7107. readonly slidePlaneNormal: Vector3;
  7108. /** @hidden */
  7109. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7110. /** @hidden */
  7111. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7112. /** @hidden */
  7113. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7114. /** @hidden */
  7115. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7116. /** @hidden */
  7117. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7118. /** @hidden */
  7119. _getResponse(pos: Vector3, vel: Vector3): void;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Interface for cullable objects
  7125. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7126. */
  7127. export interface ICullable {
  7128. /**
  7129. * Checks if the object or part of the object is in the frustum
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isInFrustum(frustumPlanes: Plane[]): boolean;
  7134. /**
  7135. * Checks if a cullable object (mesh...) is in the camera frustum
  7136. * Unlike isInFrustum this cheks the full bounding box
  7137. * @param frustumPlanes Camera near/planes
  7138. * @returns true if the object is in frustum otherwise false
  7139. */
  7140. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7141. }
  7142. /**
  7143. * Info for a bounding data of a mesh
  7144. */
  7145. export class BoundingInfo implements ICullable {
  7146. /**
  7147. * Bounding box for the mesh
  7148. */
  7149. readonly boundingBox: BoundingBox;
  7150. /**
  7151. * Bounding sphere for the mesh
  7152. */
  7153. readonly boundingSphere: BoundingSphere;
  7154. private _isLocked;
  7155. private static readonly TmpVector3;
  7156. /**
  7157. * Constructs bounding info
  7158. * @param minimum min vector of the bounding box/sphere
  7159. * @param maximum max vector of the bounding box/sphere
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7163. /**
  7164. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7165. * @param min defines the new minimum vector (in local space)
  7166. * @param max defines the new maximum vector (in local space)
  7167. * @param worldMatrix defines the new world matrix
  7168. */
  7169. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7170. /**
  7171. * min vector of the bounding box/sphere
  7172. */
  7173. readonly minimum: Vector3;
  7174. /**
  7175. * max vector of the bounding box/sphere
  7176. */
  7177. readonly maximum: Vector3;
  7178. /**
  7179. * If the info is locked and won't be updated to avoid perf overhead
  7180. */
  7181. isLocked: boolean;
  7182. /**
  7183. * Updates the bounding sphere and box
  7184. * @param world world matrix to be used to update
  7185. */
  7186. update(world: DeepImmutable<Matrix>): void;
  7187. /**
  7188. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7189. * @param center New center of the bounding info
  7190. * @param extend New extend of the bounding info
  7191. * @returns the current bounding info
  7192. */
  7193. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7194. /**
  7195. * Scale the current bounding info by applying a scale factor
  7196. * @param factor defines the scale factor to apply
  7197. * @returns the current bounding info
  7198. */
  7199. scale(factor: number): BoundingInfo;
  7200. /**
  7201. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7202. * @param frustumPlanes defines the frustum to test
  7203. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7204. * @returns true if the bounding info is in the frustum planes
  7205. */
  7206. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7207. /**
  7208. * Gets the world distance between the min and max points of the bounding box
  7209. */
  7210. readonly diagonalLength: number;
  7211. /**
  7212. * Checks if a cullable object (mesh...) is in the camera frustum
  7213. * Unlike isInFrustum this cheks the full bounding box
  7214. * @param frustumPlanes Camera near/planes
  7215. * @returns true if the object is in frustum otherwise false
  7216. */
  7217. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7218. /** @hidden */
  7219. _checkCollision(collider: Collider): boolean;
  7220. /**
  7221. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param point the point to check intersection with
  7224. * @returns if the point intersects
  7225. */
  7226. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7227. /**
  7228. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7229. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7230. * @param boundingInfo the bounding info to check intersection with
  7231. * @param precise if the intersection should be done using OBB
  7232. * @returns if the bounding info intersects
  7233. */
  7234. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7235. }
  7236. }
  7237. declare module BABYLON {
  7238. /**
  7239. * Defines an array and its length.
  7240. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7241. */
  7242. export interface ISmartArrayLike<T> {
  7243. /**
  7244. * The data of the array.
  7245. */
  7246. data: Array<T>;
  7247. /**
  7248. * The active length of the array.
  7249. */
  7250. length: number;
  7251. }
  7252. /**
  7253. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7254. */
  7255. export class SmartArray<T> implements ISmartArrayLike<T> {
  7256. /**
  7257. * The full set of data from the array.
  7258. */
  7259. data: Array<T>;
  7260. /**
  7261. * The active length of the array.
  7262. */
  7263. length: number;
  7264. protected _id: number;
  7265. /**
  7266. * Instantiates a Smart Array.
  7267. * @param capacity defines the default capacity of the array.
  7268. */
  7269. constructor(capacity: number);
  7270. /**
  7271. * Pushes a value at the end of the active data.
  7272. * @param value defines the object to push in the array.
  7273. */
  7274. push(value: T): void;
  7275. /**
  7276. * Iterates over the active data and apply the lambda to them.
  7277. * @param func defines the action to apply on each value.
  7278. */
  7279. forEach(func: (content: T) => void): void;
  7280. /**
  7281. * Sorts the full sets of data.
  7282. * @param compareFn defines the comparison function to apply.
  7283. */
  7284. sort(compareFn: (a: T, b: T) => number): void;
  7285. /**
  7286. * Resets the active data to an empty array.
  7287. */
  7288. reset(): void;
  7289. /**
  7290. * Releases all the data from the array as well as the array.
  7291. */
  7292. dispose(): void;
  7293. /**
  7294. * Concats the active data with a given array.
  7295. * @param array defines the data to concatenate with.
  7296. */
  7297. concat(array: any): void;
  7298. /**
  7299. * Returns the position of a value in the active data.
  7300. * @param value defines the value to find the index for
  7301. * @returns the index if found in the active data otherwise -1
  7302. */
  7303. indexOf(value: T): number;
  7304. /**
  7305. * Returns whether an element is part of the active data.
  7306. * @param value defines the value to look for
  7307. * @returns true if found in the active data otherwise false
  7308. */
  7309. contains(value: T): boolean;
  7310. private static _GlobalId;
  7311. }
  7312. /**
  7313. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7314. * The data in this array can only be present once
  7315. */
  7316. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7317. private _duplicateId;
  7318. /**
  7319. * Pushes a value at the end of the active data.
  7320. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7321. * @param value defines the object to push in the array.
  7322. */
  7323. push(value: T): void;
  7324. /**
  7325. * Pushes a value at the end of the active data.
  7326. * If the data is already present, it won t be added again
  7327. * @param value defines the object to push in the array.
  7328. * @returns true if added false if it was already present
  7329. */
  7330. pushNoDuplicate(value: T): boolean;
  7331. /**
  7332. * Resets the active data to an empty array.
  7333. */
  7334. reset(): void;
  7335. /**
  7336. * Concats the active data with a given array.
  7337. * This ensures no dupplicate will be present in the result.
  7338. * @param array defines the data to concatenate with.
  7339. */
  7340. concatWithNoDuplicate(array: any): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7346. * separate meshes. This can be use to improve performances.
  7347. * @see http://doc.babylonjs.com/how_to/multi_materials
  7348. */
  7349. export class MultiMaterial extends Material {
  7350. private _subMaterials;
  7351. /**
  7352. * Gets or Sets the list of Materials used within the multi material.
  7353. * They need to be ordered according to the submeshes order in the associated mesh
  7354. */
  7355. subMaterials: Nullable<Material>[];
  7356. /**
  7357. * Function used to align with Node.getChildren()
  7358. * @returns the list of Materials used within the multi material
  7359. */
  7360. getChildren(): Nullable<Material>[];
  7361. /**
  7362. * Instantiates a new Multi Material
  7363. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7364. * separate meshes. This can be use to improve performances.
  7365. * @see http://doc.babylonjs.com/how_to/multi_materials
  7366. * @param name Define the name in the scene
  7367. * @param scene Define the scene the material belongs to
  7368. */
  7369. constructor(name: string, scene: Scene);
  7370. private _hookArray;
  7371. /**
  7372. * Get one of the submaterial by its index in the submaterials array
  7373. * @param index The index to look the sub material at
  7374. * @returns The Material if the index has been defined
  7375. */
  7376. getSubMaterial(index: number): Nullable<Material>;
  7377. /**
  7378. * Get the list of active textures for the whole sub materials list.
  7379. * @returns All the textures that will be used during the rendering
  7380. */
  7381. getActiveTextures(): BaseTexture[];
  7382. /**
  7383. * Gets the current class name of the material e.g. "MultiMaterial"
  7384. * Mainly use in serialization.
  7385. * @returns the class name
  7386. */
  7387. getClassName(): string;
  7388. /**
  7389. * Checks if the material is ready to render the requested sub mesh
  7390. * @param mesh Define the mesh the submesh belongs to
  7391. * @param subMesh Define the sub mesh to look readyness for
  7392. * @param useInstances Define whether or not the material is used with instances
  7393. * @returns true if ready, otherwise false
  7394. */
  7395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7396. /**
  7397. * Clones the current material and its related sub materials
  7398. * @param name Define the name of the newly cloned material
  7399. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7400. * @returns the cloned material
  7401. */
  7402. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7403. /**
  7404. * Serializes the materials into a JSON representation.
  7405. * @returns the JSON representation
  7406. */
  7407. serialize(): any;
  7408. /**
  7409. * Dispose the material and release its associated resources
  7410. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7411. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7412. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7413. */
  7414. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7415. /**
  7416. * Creates a MultiMaterial from parsed MultiMaterial data.
  7417. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7418. * @param scene defines the hosting scene
  7419. * @returns a new MultiMaterial
  7420. */
  7421. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7422. }
  7423. }
  7424. declare module BABYLON {
  7425. /**
  7426. * Class used to represent data loading progression
  7427. */
  7428. export class SceneLoaderFlags {
  7429. private static _ForceFullSceneLoadingForIncremental;
  7430. private static _ShowLoadingScreen;
  7431. private static _CleanBoneMatrixWeights;
  7432. private static _loggingLevel;
  7433. /**
  7434. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7435. */
  7436. static ForceFullSceneLoadingForIncremental: boolean;
  7437. /**
  7438. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7439. */
  7440. static ShowLoadingScreen: boolean;
  7441. /**
  7442. * Defines the current logging level (while loading the scene)
  7443. * @ignorenaming
  7444. */
  7445. static loggingLevel: number;
  7446. /**
  7447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7448. */
  7449. static CleanBoneMatrixWeights: boolean;
  7450. }
  7451. }
  7452. declare module BABYLON {
  7453. /**
  7454. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7455. * @see https://doc.babylonjs.com/how_to/transformnode
  7456. */
  7457. export class TransformNode extends Node {
  7458. /**
  7459. * Object will not rotate to face the camera
  7460. */
  7461. static BILLBOARDMODE_NONE: number;
  7462. /**
  7463. * Object will rotate to face the camera but only on the x axis
  7464. */
  7465. static BILLBOARDMODE_X: number;
  7466. /**
  7467. * Object will rotate to face the camera but only on the y axis
  7468. */
  7469. static BILLBOARDMODE_Y: number;
  7470. /**
  7471. * Object will rotate to face the camera but only on the z axis
  7472. */
  7473. static BILLBOARDMODE_Z: number;
  7474. /**
  7475. * Object will rotate to face the camera
  7476. */
  7477. static BILLBOARDMODE_ALL: number;
  7478. private _forward;
  7479. private _forwardInverted;
  7480. private _up;
  7481. private _right;
  7482. private _rightInverted;
  7483. private _position;
  7484. private _rotation;
  7485. private _rotationQuaternion;
  7486. protected _scaling: Vector3;
  7487. protected _isDirty: boolean;
  7488. private _transformToBoneReferal;
  7489. private _billboardMode;
  7490. /**
  7491. * Gets or sets the billboard mode. Default is 0.
  7492. *
  7493. * | Value | Type | Description |
  7494. * | --- | --- | --- |
  7495. * | 0 | BILLBOARDMODE_NONE | |
  7496. * | 1 | BILLBOARDMODE_X | |
  7497. * | 2 | BILLBOARDMODE_Y | |
  7498. * | 4 | BILLBOARDMODE_Z | |
  7499. * | 7 | BILLBOARDMODE_ALL | |
  7500. *
  7501. */
  7502. billboardMode: number;
  7503. private _preserveParentRotationForBillboard;
  7504. /**
  7505. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7506. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7507. */
  7508. preserveParentRotationForBillboard: boolean;
  7509. /**
  7510. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7511. */
  7512. scalingDeterminant: number;
  7513. private _infiniteDistance;
  7514. /**
  7515. * Gets or sets the distance of the object to max, often used by skybox
  7516. */
  7517. infiniteDistance: boolean;
  7518. /**
  7519. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7520. * By default the system will update normals to compensate
  7521. */
  7522. ignoreNonUniformScaling: boolean;
  7523. /**
  7524. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7525. */
  7526. reIntegrateRotationIntoRotationQuaternion: boolean;
  7527. /** @hidden */
  7528. _poseMatrix: Nullable<Matrix>;
  7529. /** @hidden */
  7530. _localMatrix: Matrix;
  7531. private _usePivotMatrix;
  7532. private _absolutePosition;
  7533. private _pivotMatrix;
  7534. private _pivotMatrixInverse;
  7535. protected _postMultiplyPivotMatrix: boolean;
  7536. protected _isWorldMatrixFrozen: boolean;
  7537. /** @hidden */
  7538. _indexInSceneTransformNodesArray: number;
  7539. /**
  7540. * An event triggered after the world matrix is updated
  7541. */
  7542. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7543. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7544. /**
  7545. * Gets a string identifying the name of the class
  7546. * @returns "TransformNode" string
  7547. */
  7548. getClassName(): string;
  7549. /**
  7550. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7551. */
  7552. position: Vector3;
  7553. /**
  7554. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7555. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7556. */
  7557. rotation: Vector3;
  7558. /**
  7559. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7560. */
  7561. scaling: Vector3;
  7562. /**
  7563. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7564. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7565. */
  7566. rotationQuaternion: Nullable<Quaternion>;
  7567. /**
  7568. * The forward direction of that transform in world space.
  7569. */
  7570. readonly forward: Vector3;
  7571. /**
  7572. * The up direction of that transform in world space.
  7573. */
  7574. readonly up: Vector3;
  7575. /**
  7576. * The right direction of that transform in world space.
  7577. */
  7578. readonly right: Vector3;
  7579. /**
  7580. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7581. * @param matrix the matrix to copy the pose from
  7582. * @returns this TransformNode.
  7583. */
  7584. updatePoseMatrix(matrix: Matrix): TransformNode;
  7585. /**
  7586. * Returns the mesh Pose matrix.
  7587. * @returns the pose matrix
  7588. */
  7589. getPoseMatrix(): Matrix;
  7590. /** @hidden */
  7591. _isSynchronized(): boolean;
  7592. /** @hidden */
  7593. _initCache(): void;
  7594. /**
  7595. * Flag the transform node as dirty (Forcing it to update everything)
  7596. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7597. * @returns this transform node
  7598. */
  7599. markAsDirty(property: string): TransformNode;
  7600. /**
  7601. * Returns the current mesh absolute position.
  7602. * Returns a Vector3.
  7603. */
  7604. readonly absolutePosition: Vector3;
  7605. /**
  7606. * Sets a new matrix to apply before all other transformation
  7607. * @param matrix defines the transform matrix
  7608. * @returns the current TransformNode
  7609. */
  7610. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7611. /**
  7612. * Sets a new pivot matrix to the current node
  7613. * @param matrix defines the new pivot matrix to use
  7614. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7615. * @returns the current TransformNode
  7616. */
  7617. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7618. /**
  7619. * Returns the mesh pivot matrix.
  7620. * Default : Identity.
  7621. * @returns the matrix
  7622. */
  7623. getPivotMatrix(): Matrix;
  7624. /**
  7625. * Prevents the World matrix to be computed any longer.
  7626. * @returns the TransformNode.
  7627. */
  7628. freezeWorldMatrix(): TransformNode;
  7629. /**
  7630. * Allows back the World matrix computation.
  7631. * @returns the TransformNode.
  7632. */
  7633. unfreezeWorldMatrix(): this;
  7634. /**
  7635. * True if the World matrix has been frozen.
  7636. */
  7637. readonly isWorldMatrixFrozen: boolean;
  7638. /**
  7639. * Retuns the mesh absolute position in the World.
  7640. * @returns a Vector3.
  7641. */
  7642. getAbsolutePosition(): Vector3;
  7643. /**
  7644. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7645. * @param absolutePosition the absolute position to set
  7646. * @returns the TransformNode.
  7647. */
  7648. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7649. /**
  7650. * Sets the mesh position in its local space.
  7651. * @param vector3 the position to set in localspace
  7652. * @returns the TransformNode.
  7653. */
  7654. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7655. /**
  7656. * Returns the mesh position in the local space from the current World matrix values.
  7657. * @returns a new Vector3.
  7658. */
  7659. getPositionExpressedInLocalSpace(): Vector3;
  7660. /**
  7661. * Translates the mesh along the passed Vector3 in its local space.
  7662. * @param vector3 the distance to translate in localspace
  7663. * @returns the TransformNode.
  7664. */
  7665. locallyTranslate(vector3: Vector3): TransformNode;
  7666. private static _lookAtVectorCache;
  7667. /**
  7668. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7669. * @param targetPoint the position (must be in same space as current mesh) to look at
  7670. * @param yawCor optional yaw (y-axis) correction in radians
  7671. * @param pitchCor optional pitch (x-axis) correction in radians
  7672. * @param rollCor optional roll (z-axis) correction in radians
  7673. * @param space the choosen space of the target
  7674. * @returns the TransformNode.
  7675. */
  7676. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7677. /**
  7678. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7679. * This Vector3 is expressed in the World space.
  7680. * @param localAxis axis to rotate
  7681. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7682. */
  7683. getDirection(localAxis: Vector3): Vector3;
  7684. /**
  7685. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7686. * localAxis is expressed in the mesh local space.
  7687. * result is computed in the Wordl space from the mesh World matrix.
  7688. * @param localAxis axis to rotate
  7689. * @param result the resulting transformnode
  7690. * @returns this TransformNode.
  7691. */
  7692. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7693. /**
  7694. * Sets this transform node rotation to the given local axis.
  7695. * @param localAxis the axis in local space
  7696. * @param yawCor optional yaw (y-axis) correction in radians
  7697. * @param pitchCor optional pitch (x-axis) correction in radians
  7698. * @param rollCor optional roll (z-axis) correction in radians
  7699. * @returns this TransformNode
  7700. */
  7701. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7702. /**
  7703. * Sets a new pivot point to the current node
  7704. * @param point defines the new pivot point to use
  7705. * @param space defines if the point is in world or local space (local by default)
  7706. * @returns the current TransformNode
  7707. */
  7708. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7709. /**
  7710. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7711. * @returns the pivot point
  7712. */
  7713. getPivotPoint(): Vector3;
  7714. /**
  7715. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7716. * @param result the vector3 to store the result
  7717. * @returns this TransformNode.
  7718. */
  7719. getPivotPointToRef(result: Vector3): TransformNode;
  7720. /**
  7721. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7722. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7723. */
  7724. getAbsolutePivotPoint(): Vector3;
  7725. /**
  7726. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7727. * @param result vector3 to store the result
  7728. * @returns this TransformNode.
  7729. */
  7730. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7731. /**
  7732. * Defines the passed node as the parent of the current node.
  7733. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7734. * @see https://doc.babylonjs.com/how_to/parenting
  7735. * @param node the node ot set as the parent
  7736. * @returns this TransformNode.
  7737. */
  7738. setParent(node: Nullable<Node>): TransformNode;
  7739. private _nonUniformScaling;
  7740. /**
  7741. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7742. */
  7743. readonly nonUniformScaling: boolean;
  7744. /** @hidden */
  7745. _updateNonUniformScalingState(value: boolean): boolean;
  7746. /**
  7747. * Attach the current TransformNode to another TransformNode associated with a bone
  7748. * @param bone Bone affecting the TransformNode
  7749. * @param affectedTransformNode TransformNode associated with the bone
  7750. * @returns this object
  7751. */
  7752. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7753. /**
  7754. * Detach the transform node if its associated with a bone
  7755. * @returns this object
  7756. */
  7757. detachFromBone(): TransformNode;
  7758. private static _rotationAxisCache;
  7759. /**
  7760. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7761. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7762. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7763. * The passed axis is also normalized.
  7764. * @param axis the axis to rotate around
  7765. * @param amount the amount to rotate in radians
  7766. * @param space Space to rotate in (Default: local)
  7767. * @returns the TransformNode.
  7768. */
  7769. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7770. /**
  7771. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7772. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7773. * The passed axis is also normalized. .
  7774. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7775. * @param point the point to rotate around
  7776. * @param axis the axis to rotate around
  7777. * @param amount the amount to rotate in radians
  7778. * @returns the TransformNode
  7779. */
  7780. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7781. /**
  7782. * Translates the mesh along the axis vector for the passed distance in the given space.
  7783. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7784. * @param axis the axis to translate in
  7785. * @param distance the distance to translate
  7786. * @param space Space to rotate in (Default: local)
  7787. * @returns the TransformNode.
  7788. */
  7789. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7790. /**
  7791. * Adds a rotation step to the mesh current rotation.
  7792. * x, y, z are Euler angles expressed in radians.
  7793. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7794. * This means this rotation is made in the mesh local space only.
  7795. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7796. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7797. * ```javascript
  7798. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7799. * ```
  7800. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7801. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7802. * @param x Rotation to add
  7803. * @param y Rotation to add
  7804. * @param z Rotation to add
  7805. * @returns the TransformNode.
  7806. */
  7807. addRotation(x: number, y: number, z: number): TransformNode;
  7808. /**
  7809. * @hidden
  7810. */
  7811. protected _getEffectiveParent(): Nullable<Node>;
  7812. /**
  7813. * Computes the world matrix of the node
  7814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7815. * @returns the world matrix
  7816. */
  7817. computeWorldMatrix(force?: boolean): Matrix;
  7818. protected _afterComputeWorldMatrix(): void;
  7819. /**
  7820. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7821. * @param func callback function to add
  7822. *
  7823. * @returns the TransformNode.
  7824. */
  7825. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7826. /**
  7827. * Removes a registered callback function.
  7828. * @param func callback function to remove
  7829. * @returns the TransformNode.
  7830. */
  7831. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7832. /**
  7833. * Gets the position of the current mesh in camera space
  7834. * @param camera defines the camera to use
  7835. * @returns a position
  7836. */
  7837. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7838. /**
  7839. * Returns the distance from the mesh to the active camera
  7840. * @param camera defines the camera to use
  7841. * @returns the distance
  7842. */
  7843. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7844. /**
  7845. * Clone the current transform node
  7846. * @param name Name of the new clone
  7847. * @param newParent New parent for the clone
  7848. * @param doNotCloneChildren Do not clone children hierarchy
  7849. * @returns the new transform node
  7850. */
  7851. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7852. /**
  7853. * Serializes the objects information.
  7854. * @param currentSerializationObject defines the object to serialize in
  7855. * @returns the serialized object
  7856. */
  7857. serialize(currentSerializationObject?: any): any;
  7858. /**
  7859. * Returns a new TransformNode object parsed from the source provided.
  7860. * @param parsedTransformNode is the source.
  7861. * @param scene the scne the object belongs to
  7862. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7863. * @returns a new TransformNode object parsed from the source provided.
  7864. */
  7865. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7866. /**
  7867. * Get all child-transformNodes of this node
  7868. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7869. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7870. * @returns an array of TransformNode
  7871. */
  7872. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7873. /**
  7874. * Releases resources associated with this transform node.
  7875. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7876. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7877. */
  7878. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Class used to override all child animations of a given target
  7884. */
  7885. export class AnimationPropertiesOverride {
  7886. /**
  7887. * Gets or sets a value indicating if animation blending must be used
  7888. */
  7889. enableBlending: boolean;
  7890. /**
  7891. * Gets or sets the blending speed to use when enableBlending is true
  7892. */
  7893. blendingSpeed: number;
  7894. /**
  7895. * Gets or sets the default loop mode to use
  7896. */
  7897. loopMode: number;
  7898. }
  7899. }
  7900. declare module BABYLON {
  7901. /**
  7902. * Class used to store bone information
  7903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7904. */
  7905. export class Bone extends Node {
  7906. /**
  7907. * defines the bone name
  7908. */
  7909. name: string;
  7910. private static _tmpVecs;
  7911. private static _tmpQuat;
  7912. private static _tmpMats;
  7913. /**
  7914. * Gets the list of child bones
  7915. */
  7916. children: Bone[];
  7917. /** Gets the animations associated with this bone */
  7918. animations: Animation[];
  7919. /**
  7920. * Gets or sets bone length
  7921. */
  7922. length: number;
  7923. /**
  7924. * @hidden Internal only
  7925. * Set this value to map this bone to a different index in the transform matrices
  7926. * Set this value to -1 to exclude the bone from the transform matrices
  7927. */
  7928. _index: Nullable<number>;
  7929. private _skeleton;
  7930. private _localMatrix;
  7931. private _restPose;
  7932. private _baseMatrix;
  7933. private _absoluteTransform;
  7934. private _invertedAbsoluteTransform;
  7935. private _parent;
  7936. private _scalingDeterminant;
  7937. private _worldTransform;
  7938. private _localScaling;
  7939. private _localRotation;
  7940. private _localPosition;
  7941. private _needToDecompose;
  7942. private _needToCompose;
  7943. /** @hidden */
  7944. _linkedTransformNode: Nullable<TransformNode>;
  7945. /** @hidden */
  7946. /** @hidden */
  7947. _matrix: Matrix;
  7948. /**
  7949. * Create a new bone
  7950. * @param name defines the bone name
  7951. * @param skeleton defines the parent skeleton
  7952. * @param parentBone defines the parent (can be null if the bone is the root)
  7953. * @param localMatrix defines the local matrix
  7954. * @param restPose defines the rest pose matrix
  7955. * @param baseMatrix defines the base matrix
  7956. * @param index defines index of the bone in the hiearchy
  7957. */
  7958. constructor(
  7959. /**
  7960. * defines the bone name
  7961. */
  7962. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7963. /**
  7964. * Gets the current object class name.
  7965. * @return the class name
  7966. */
  7967. getClassName(): string;
  7968. /**
  7969. * Gets the parent skeleton
  7970. * @returns a skeleton
  7971. */
  7972. getSkeleton(): Skeleton;
  7973. /**
  7974. * Gets parent bone
  7975. * @returns a bone or null if the bone is the root of the bone hierarchy
  7976. */
  7977. getParent(): Nullable<Bone>;
  7978. /**
  7979. * Returns an array containing the root bones
  7980. * @returns an array containing the root bones
  7981. */
  7982. getChildren(): Array<Bone>;
  7983. /**
  7984. * Sets the parent bone
  7985. * @param parent defines the parent (can be null if the bone is the root)
  7986. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7987. */
  7988. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7989. /**
  7990. * Gets the local matrix
  7991. * @returns a matrix
  7992. */
  7993. getLocalMatrix(): Matrix;
  7994. /**
  7995. * Gets the base matrix (initial matrix which remains unchanged)
  7996. * @returns a matrix
  7997. */
  7998. getBaseMatrix(): Matrix;
  7999. /**
  8000. * Gets the rest pose matrix
  8001. * @returns a matrix
  8002. */
  8003. getRestPose(): Matrix;
  8004. /**
  8005. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8006. */
  8007. getWorldMatrix(): Matrix;
  8008. /**
  8009. * Sets the local matrix to rest pose matrix
  8010. */
  8011. returnToRest(): void;
  8012. /**
  8013. * Gets the inverse of the absolute transform matrix.
  8014. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8015. * @returns a matrix
  8016. */
  8017. getInvertedAbsoluteTransform(): Matrix;
  8018. /**
  8019. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8020. * @returns a matrix
  8021. */
  8022. getAbsoluteTransform(): Matrix;
  8023. /**
  8024. * Links with the given transform node.
  8025. * The local matrix of this bone is copied from the transform node every frame.
  8026. * @param transformNode defines the transform node to link to
  8027. */
  8028. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8029. /** Gets or sets current position (in local space) */
  8030. position: Vector3;
  8031. /** Gets or sets current rotation (in local space) */
  8032. rotation: Vector3;
  8033. /** Gets or sets current rotation quaternion (in local space) */
  8034. rotationQuaternion: Quaternion;
  8035. /** Gets or sets current scaling (in local space) */
  8036. scaling: Vector3;
  8037. /**
  8038. * Gets the animation properties override
  8039. */
  8040. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8041. private _decompose;
  8042. private _compose;
  8043. /**
  8044. * Update the base and local matrices
  8045. * @param matrix defines the new base or local matrix
  8046. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8047. * @param updateLocalMatrix defines if the local matrix should be updated
  8048. */
  8049. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8050. /** @hidden */
  8051. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8052. /**
  8053. * Flag the bone as dirty (Forcing it to update everything)
  8054. */
  8055. markAsDirty(): void;
  8056. private _markAsDirtyAndCompose;
  8057. private _markAsDirtyAndDecompose;
  8058. /**
  8059. * Translate the bone in local or world space
  8060. * @param vec The amount to translate the bone
  8061. * @param space The space that the translation is in
  8062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8063. */
  8064. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8065. /**
  8066. * Set the postion of the bone in local or world space
  8067. * @param position The position to set the bone
  8068. * @param space The space that the position is in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Set the absolute position of the bone (world space)
  8074. * @param position The position to set the bone
  8075. * @param mesh The mesh that this bone is attached to
  8076. */
  8077. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8078. /**
  8079. * Scale the bone on the x, y and z axes (in local space)
  8080. * @param x The amount to scale the bone on the x axis
  8081. * @param y The amount to scale the bone on the y axis
  8082. * @param z The amount to scale the bone on the z axis
  8083. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8084. */
  8085. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8086. /**
  8087. * Set the bone scaling in local space
  8088. * @param scale defines the scaling vector
  8089. */
  8090. setScale(scale: Vector3): void;
  8091. /**
  8092. * Gets the current scaling in local space
  8093. * @returns the current scaling vector
  8094. */
  8095. getScale(): Vector3;
  8096. /**
  8097. * Gets the current scaling in local space and stores it in a target vector
  8098. * @param result defines the target vector
  8099. */
  8100. getScaleToRef(result: Vector3): void;
  8101. /**
  8102. * Set the yaw, pitch, and roll of the bone in local or world space
  8103. * @param yaw The rotation of the bone on the y axis
  8104. * @param pitch The rotation of the bone on the x axis
  8105. * @param roll The rotation of the bone on the z axis
  8106. * @param space The space that the axes of rotation are in
  8107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8108. */
  8109. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8110. /**
  8111. * Add a rotation to the bone on an axis in local or world space
  8112. * @param axis The axis to rotate the bone on
  8113. * @param amount The amount to rotate the bone
  8114. * @param space The space that the axis is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation of the bone to a particular axis angle in local or world space
  8120. * @param axis The axis to rotate the bone on
  8121. * @param angle The angle that the bone should be rotated to
  8122. * @param space The space that the axis is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8126. /**
  8127. * Set the euler rotation of the bone in local of world space
  8128. * @param rotation The euler rotation that the bone should be set to
  8129. * @param space The space that the rotation is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the quaternion rotation of the bone in local of world space
  8135. * @param quat The quaternion rotation that the bone should be set to
  8136. * @param space The space that the rotation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the rotation matrix of the bone in local of world space
  8142. * @param rotMat The rotation matrix that the bone should be set to
  8143. * @param space The space that the rotation is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8147. private _rotateWithMatrix;
  8148. private _getNegativeRotationToRef;
  8149. /**
  8150. * Get the position of the bone in local or world space
  8151. * @param space The space that the returned position is in
  8152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8153. * @returns The position of the bone
  8154. */
  8155. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8156. /**
  8157. * Copy the position of the bone to a vector3 in local or world space
  8158. * @param space The space that the returned position is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @param result The vector3 to copy the position to
  8161. */
  8162. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8163. /**
  8164. * Get the absolute position of the bone (world space)
  8165. * @param mesh The mesh that this bone is attached to
  8166. * @returns The absolute position of the bone
  8167. */
  8168. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8169. /**
  8170. * Copy the absolute position of the bone (world space) to the result param
  8171. * @param mesh The mesh that this bone is attached to
  8172. * @param result The vector3 to copy the absolute position to
  8173. */
  8174. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8175. /**
  8176. * Compute the absolute transforms of this bone and its children
  8177. */
  8178. computeAbsoluteTransforms(): void;
  8179. /**
  8180. * Get the world direction from an axis that is in the local space of the bone
  8181. * @param localAxis The local direction that is used to compute the world direction
  8182. * @param mesh The mesh that this bone is attached to
  8183. * @returns The world direction
  8184. */
  8185. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8186. /**
  8187. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8188. * @param localAxis The local direction that is used to compute the world direction
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @param result The vector3 that the world direction will be copied to
  8191. */
  8192. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8193. /**
  8194. * Get the euler rotation of the bone in local or world space
  8195. * @param space The space that the rotation should be in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. * @returns The euler rotation
  8198. */
  8199. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8200. /**
  8201. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @param result The vector3 that the rotation should be copied to
  8205. */
  8206. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8207. /**
  8208. * Get the quaternion rotation of the bone in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @returns The quaternion rotation
  8212. */
  8213. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8214. /**
  8215. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8216. * @param space The space that the rotation should be in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. * @param result The quaternion that the rotation should be copied to
  8219. */
  8220. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8221. /**
  8222. * Get the rotation matrix of the bone in local or world space
  8223. * @param space The space that the rotation should be in
  8224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8225. * @returns The rotation matrix
  8226. */
  8227. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8228. /**
  8229. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8230. * @param space The space that the rotation should be in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @param result The quaternion that the rotation should be copied to
  8233. */
  8234. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8235. /**
  8236. * Get the world position of a point that is in the local space of the bone
  8237. * @param position The local position
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @returns The world position
  8240. */
  8241. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8242. /**
  8243. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8244. * @param position The local position
  8245. * @param mesh The mesh that this bone is attached to
  8246. * @param result The vector3 that the world position should be copied to
  8247. */
  8248. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8249. /**
  8250. * Get the local position of a point that is in world space
  8251. * @param position The world position
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The local position
  8254. */
  8255. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Get the local position of a point that is in world space and copy it to the result param
  8258. * @param position The world position
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the local position should be copied to
  8261. */
  8262. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. }
  8264. }
  8265. declare module BABYLON {
  8266. /**
  8267. * Enum that determines the text-wrapping mode to use.
  8268. */
  8269. export enum InspectableType {
  8270. /**
  8271. * Checkbox for booleans
  8272. */
  8273. Checkbox = 0,
  8274. /**
  8275. * Sliders for numbers
  8276. */
  8277. Slider = 1,
  8278. /**
  8279. * Vector3
  8280. */
  8281. Vector3 = 2,
  8282. /**
  8283. * Quaternions
  8284. */
  8285. Quaternion = 3,
  8286. /**
  8287. * Color3
  8288. */
  8289. Color3 = 4
  8290. }
  8291. /**
  8292. * Interface used to define custom inspectable properties.
  8293. * This interface is used by the inspector to display custom property grids
  8294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8295. */
  8296. export interface IInspectable {
  8297. /**
  8298. * Gets the label to display
  8299. */
  8300. label: string;
  8301. /**
  8302. * Gets the name of the property to edit
  8303. */
  8304. propertyName: string;
  8305. /**
  8306. * Gets the type of the editor to use
  8307. */
  8308. type: InspectableType;
  8309. /**
  8310. * Gets the minimum value of the property when using in "slider" mode
  8311. */
  8312. min?: number;
  8313. /**
  8314. * Gets the maximum value of the property when using in "slider" mode
  8315. */
  8316. max?: number;
  8317. /**
  8318. * Gets the setp to use when using in "slider" mode
  8319. */
  8320. step?: number;
  8321. }
  8322. }
  8323. declare module BABYLON {
  8324. /**
  8325. * Class for creating a cube texture
  8326. */
  8327. export class CubeTexture extends BaseTexture {
  8328. private _delayedOnLoad;
  8329. /**
  8330. * The url of the texture
  8331. */
  8332. url: string;
  8333. /**
  8334. * Gets or sets the center of the bounding box associated with the cube texture.
  8335. * It must define where the camera used to render the texture was set
  8336. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8337. */
  8338. boundingBoxPosition: Vector3;
  8339. private _boundingBoxSize;
  8340. /**
  8341. * Gets or sets the size of the bounding box associated with the cube texture
  8342. * When defined, the cubemap will switch to local mode
  8343. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8344. * @example https://www.babylonjs-playground.com/#RNASML
  8345. */
  8346. /**
  8347. * Returns the bounding box size
  8348. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8349. */
  8350. boundingBoxSize: Vector3;
  8351. protected _rotationY: number;
  8352. /**
  8353. * Sets texture matrix rotation angle around Y axis in radians.
  8354. */
  8355. /**
  8356. * Gets texture matrix rotation angle around Y axis radians.
  8357. */
  8358. rotationY: number;
  8359. /**
  8360. * Are mip maps generated for this texture or not.
  8361. */
  8362. readonly noMipmap: boolean;
  8363. private _noMipmap;
  8364. private _files;
  8365. private _extensions;
  8366. private _textureMatrix;
  8367. private _format;
  8368. private _createPolynomials;
  8369. /** @hidden */
  8370. _prefiltered: boolean;
  8371. /**
  8372. * Creates a cube texture from an array of image urls
  8373. * @param files defines an array of image urls
  8374. * @param scene defines the hosting scene
  8375. * @param noMipmap specifies if mip maps are not used
  8376. * @returns a cube texture
  8377. */
  8378. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8379. /**
  8380. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8381. * @param url defines the url of the prefiltered texture
  8382. * @param scene defines the scene the texture is attached to
  8383. * @param forcedExtension defines the extension of the file if different from the url
  8384. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8385. * @return the prefiltered texture
  8386. */
  8387. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8388. /**
  8389. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8390. * as prefiltered data.
  8391. * @param rootUrl defines the url of the texture or the root name of the six images
  8392. * @param scene defines the scene the texture is attached to
  8393. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8394. * @param noMipmap defines if mipmaps should be created or not
  8395. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8396. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8397. * @param onError defines a callback triggered in case of error during load
  8398. * @param format defines the internal format to use for the texture once loaded
  8399. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8400. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8401. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8402. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8403. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8404. * @return the cube texture
  8405. */
  8406. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8407. /**
  8408. * Get the current class name of the texture useful for serialization or dynamic coding.
  8409. * @returns "CubeTexture"
  8410. */
  8411. getClassName(): string;
  8412. /**
  8413. * Update the url (and optional buffer) of this texture if url was null during construction.
  8414. * @param url the url of the texture
  8415. * @param forcedExtension defines the extension to use
  8416. * @param onLoad callback called when the texture is loaded (defaults to null)
  8417. */
  8418. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8419. /**
  8420. * Delays loading of the cube texture
  8421. * @param forcedExtension defines the extension to use
  8422. */
  8423. delayLoad(forcedExtension?: string): void;
  8424. /**
  8425. * Returns the reflection texture matrix
  8426. * @returns the reflection texture matrix
  8427. */
  8428. getReflectionTextureMatrix(): Matrix;
  8429. /**
  8430. * Sets the reflection texture matrix
  8431. * @param value Reflection texture matrix
  8432. */
  8433. setReflectionTextureMatrix(value: Matrix): void;
  8434. /**
  8435. * Parses text to create a cube texture
  8436. * @param parsedTexture define the serialized text to read from
  8437. * @param scene defines the hosting scene
  8438. * @param rootUrl defines the root url of the cube texture
  8439. * @returns a cube texture
  8440. */
  8441. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8442. /**
  8443. * Makes a clone, or deep copy, of the cube texture
  8444. * @returns a new cube texture
  8445. */
  8446. clone(): CubeTexture;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. /**
  8458. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8459. * This is the base of the follow, arc rotate cameras and Free camera
  8460. * @see http://doc.babylonjs.com/features/cameras
  8461. */
  8462. export class TargetCamera extends Camera {
  8463. private static _RigCamTransformMatrix;
  8464. private static _TargetTransformMatrix;
  8465. private static _TargetFocalPoint;
  8466. /**
  8467. * Define the current direction the camera is moving to
  8468. */
  8469. cameraDirection: Vector3;
  8470. /**
  8471. * Define the current rotation the camera is rotating to
  8472. */
  8473. cameraRotation: Vector2;
  8474. /**
  8475. * When set, the up vector of the camera will be updated by the rotation of the camera
  8476. */
  8477. updateUpVectorFromRotation: boolean;
  8478. private _tmpQuaternion;
  8479. /**
  8480. * Define the current rotation of the camera
  8481. */
  8482. rotation: Vector3;
  8483. /**
  8484. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8485. */
  8486. rotationQuaternion: Quaternion;
  8487. /**
  8488. * Define the current speed of the camera
  8489. */
  8490. speed: number;
  8491. /**
  8492. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8493. * around all axis.
  8494. */
  8495. noRotationConstraint: boolean;
  8496. /**
  8497. * Define the current target of the camera as an object or a position.
  8498. */
  8499. lockedTarget: any;
  8500. /** @hidden */
  8501. _currentTarget: Vector3;
  8502. /** @hidden */
  8503. _initialFocalDistance: number;
  8504. /** @hidden */
  8505. _viewMatrix: Matrix;
  8506. /** @hidden */
  8507. _camMatrix: Matrix;
  8508. /** @hidden */
  8509. _cameraTransformMatrix: Matrix;
  8510. /** @hidden */
  8511. _cameraRotationMatrix: Matrix;
  8512. /** @hidden */
  8513. _referencePoint: Vector3;
  8514. /** @hidden */
  8515. _transformedReferencePoint: Vector3;
  8516. protected _globalCurrentTarget: Vector3;
  8517. protected _globalCurrentUpVector: Vector3;
  8518. /** @hidden */
  8519. _reset: () => void;
  8520. private _defaultUp;
  8521. /**
  8522. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8523. * This is the base of the follow, arc rotate cameras and Free camera
  8524. * @see http://doc.babylonjs.com/features/cameras
  8525. * @param name Defines the name of the camera in the scene
  8526. * @param position Defines the start position of the camera in the scene
  8527. * @param scene Defines the scene the camera belongs to
  8528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8529. */
  8530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8531. /**
  8532. * Gets the position in front of the camera at a given distance.
  8533. * @param distance The distance from the camera we want the position to be
  8534. * @returns the position
  8535. */
  8536. getFrontPosition(distance: number): Vector3;
  8537. /** @hidden */
  8538. _getLockedTargetPosition(): Nullable<Vector3>;
  8539. private _storedPosition;
  8540. private _storedRotation;
  8541. private _storedRotationQuaternion;
  8542. /**
  8543. * Store current camera state of the camera (fov, position, rotation, etc..)
  8544. * @returns the camera
  8545. */
  8546. storeState(): Camera;
  8547. /**
  8548. * Restored camera state. You must call storeState() first
  8549. * @returns whether it was successful or not
  8550. * @hidden
  8551. */
  8552. _restoreStateValues(): boolean;
  8553. /** @hidden */
  8554. _initCache(): void;
  8555. /** @hidden */
  8556. _updateCache(ignoreParentClass?: boolean): void;
  8557. /** @hidden */
  8558. _isSynchronizedViewMatrix(): boolean;
  8559. /** @hidden */
  8560. _computeLocalCameraSpeed(): number;
  8561. /**
  8562. * Defines the target the camera should look at.
  8563. * This will automatically adapt alpha beta and radius to fit within the new target.
  8564. * @param target Defines the new target as a Vector or a mesh
  8565. */
  8566. setTarget(target: Vector3): void;
  8567. /**
  8568. * Return the current target position of the camera. This value is expressed in local space.
  8569. * @returns the target position
  8570. */
  8571. getTarget(): Vector3;
  8572. /** @hidden */
  8573. _decideIfNeedsToMove(): boolean;
  8574. /** @hidden */
  8575. _updatePosition(): void;
  8576. /** @hidden */
  8577. _checkInputs(): void;
  8578. protected _updateCameraRotationMatrix(): void;
  8579. /**
  8580. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8581. * @returns the current camera
  8582. */
  8583. private _rotateUpVectorWithCameraRotationMatrix;
  8584. private _cachedRotationZ;
  8585. private _cachedQuaternionRotationZ;
  8586. /** @hidden */
  8587. _getViewMatrix(): Matrix;
  8588. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8589. /**
  8590. * @hidden
  8591. */
  8592. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8593. /**
  8594. * @hidden
  8595. */
  8596. _updateRigCameras(): void;
  8597. private _getRigCamPositionAndTarget;
  8598. /**
  8599. * Gets the current object class name.
  8600. * @return the class name
  8601. */
  8602. getClassName(): string;
  8603. }
  8604. }
  8605. declare module BABYLON {
  8606. /**
  8607. * @ignore
  8608. * This is a list of all the different input types that are available in the application.
  8609. * Fo instance: ArcRotateCameraGamepadInput...
  8610. */
  8611. export var CameraInputTypes: {};
  8612. /**
  8613. * This is the contract to implement in order to create a new input class.
  8614. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8615. */
  8616. export interface ICameraInput<TCamera extends Camera> {
  8617. /**
  8618. * Defines the camera the input is attached to.
  8619. */
  8620. camera: Nullable<TCamera>;
  8621. /**
  8622. * Gets the class name of the current intput.
  8623. * @returns the class name
  8624. */
  8625. getClassName(): string;
  8626. /**
  8627. * Get the friendly name associated with the input class.
  8628. * @returns the input friendly name
  8629. */
  8630. getSimpleName(): string;
  8631. /**
  8632. * Attach the input controls to a specific dom element to get the input from.
  8633. * @param element Defines the element the controls should be listened from
  8634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8635. */
  8636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8637. /**
  8638. * Detach the current controls from the specified dom element.
  8639. * @param element Defines the element to stop listening the inputs from
  8640. */
  8641. detachControl(element: Nullable<HTMLElement>): void;
  8642. /**
  8643. * Update the current camera state depending on the inputs that have been used this frame.
  8644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8645. */
  8646. checkInputs?: () => void;
  8647. }
  8648. /**
  8649. * Represents a map of input types to input instance or input index to input instance.
  8650. */
  8651. export interface CameraInputsMap<TCamera extends Camera> {
  8652. /**
  8653. * Accessor to the input by input type.
  8654. */
  8655. [name: string]: ICameraInput<TCamera>;
  8656. /**
  8657. * Accessor to the input by input index.
  8658. */
  8659. [idx: number]: ICameraInput<TCamera>;
  8660. }
  8661. /**
  8662. * This represents the input manager used within a camera.
  8663. * It helps dealing with all the different kind of input attached to a camera.
  8664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8665. */
  8666. export class CameraInputsManager<TCamera extends Camera> {
  8667. /**
  8668. * Defines the list of inputs attahed to the camera.
  8669. */
  8670. attached: CameraInputsMap<TCamera>;
  8671. /**
  8672. * Defines the dom element the camera is collecting inputs from.
  8673. * This is null if the controls have not been attached.
  8674. */
  8675. attachedElement: Nullable<HTMLElement>;
  8676. /**
  8677. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8678. */
  8679. noPreventDefault: boolean;
  8680. /**
  8681. * Defined the camera the input manager belongs to.
  8682. */
  8683. camera: TCamera;
  8684. /**
  8685. * Update the current camera state depending on the inputs that have been used this frame.
  8686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8687. */
  8688. checkInputs: () => void;
  8689. /**
  8690. * Instantiate a new Camera Input Manager.
  8691. * @param camera Defines the camera the input manager blongs to
  8692. */
  8693. constructor(camera: TCamera);
  8694. /**
  8695. * Add an input method to a camera
  8696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8697. * @param input camera input method
  8698. */
  8699. add(input: ICameraInput<TCamera>): void;
  8700. /**
  8701. * Remove a specific input method from a camera
  8702. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8703. * @param inputToRemove camera input method
  8704. */
  8705. remove(inputToRemove: ICameraInput<TCamera>): void;
  8706. /**
  8707. * Remove a specific input type from a camera
  8708. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8709. * @param inputType the type of the input to remove
  8710. */
  8711. removeByType(inputType: string): void;
  8712. private _addCheckInputs;
  8713. /**
  8714. * Attach the input controls to the currently attached dom element to listen the events from.
  8715. * @param input Defines the input to attach
  8716. */
  8717. attachInput(input: ICameraInput<TCamera>): void;
  8718. /**
  8719. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8720. * @param element Defines the dom element to collect the events from
  8721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8722. */
  8723. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8724. /**
  8725. * Detach the current manager inputs controls from a specific dom element.
  8726. * @param element Defines the dom element to collect the events from
  8727. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8728. */
  8729. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8730. /**
  8731. * Rebuild the dynamic inputCheck function from the current list of
  8732. * defined inputs in the manager.
  8733. */
  8734. rebuildInputCheck(): void;
  8735. /**
  8736. * Remove all attached input methods from a camera
  8737. */
  8738. clear(): void;
  8739. /**
  8740. * Serialize the current input manager attached to a camera.
  8741. * This ensures than once parsed,
  8742. * the input associated to the camera will be identical to the current ones
  8743. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8744. */
  8745. serialize(serializedCamera: any): void;
  8746. /**
  8747. * Parses an input manager serialized JSON to restore the previous list of inputs
  8748. * and states associated to a camera.
  8749. * @param parsedCamera Defines the JSON to parse
  8750. */
  8751. parse(parsedCamera: any): void;
  8752. }
  8753. }
  8754. declare module BABYLON {
  8755. /**
  8756. * Gather the list of keyboard event types as constants.
  8757. */
  8758. export class KeyboardEventTypes {
  8759. /**
  8760. * The keydown event is fired when a key becomes active (pressed).
  8761. */
  8762. static readonly KEYDOWN: number;
  8763. /**
  8764. * The keyup event is fired when a key has been released.
  8765. */
  8766. static readonly KEYUP: number;
  8767. }
  8768. /**
  8769. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8770. */
  8771. export class KeyboardInfo {
  8772. /**
  8773. * Defines the type of event (KeyboardEventTypes)
  8774. */
  8775. type: number;
  8776. /**
  8777. * Defines the related dom event
  8778. */
  8779. event: KeyboardEvent;
  8780. /**
  8781. * Instantiates a new keyboard info.
  8782. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8783. * @param type Defines the type of event (KeyboardEventTypes)
  8784. * @param event Defines the related dom event
  8785. */
  8786. constructor(
  8787. /**
  8788. * Defines the type of event (KeyboardEventTypes)
  8789. */
  8790. type: number,
  8791. /**
  8792. * Defines the related dom event
  8793. */
  8794. event: KeyboardEvent);
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8798. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8799. */
  8800. export class KeyboardInfoPre extends KeyboardInfo {
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number;
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent;
  8809. /**
  8810. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8811. */
  8812. skipOnPointerObservable: boolean;
  8813. /**
  8814. * Instantiates a new keyboard pre info.
  8815. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. }
  8830. declare module BABYLON {
  8831. /**
  8832. * Manage the keyboard inputs to control the movement of a free camera.
  8833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8834. */
  8835. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8836. /**
  8837. * Defines the camera the input is attached to.
  8838. */
  8839. camera: FreeCamera;
  8840. /**
  8841. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8842. */
  8843. keysUp: number[];
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8846. */
  8847. keysDown: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8850. */
  8851. keysLeft: number[];
  8852. /**
  8853. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8854. */
  8855. keysRight: number[];
  8856. private _keys;
  8857. private _onCanvasBlurObserver;
  8858. private _onKeyboardObserver;
  8859. private _engine;
  8860. private _scene;
  8861. /**
  8862. * Attach the input controls to a specific dom element to get the input from.
  8863. * @param element Defines the element the controls should be listened from
  8864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8865. */
  8866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8867. /**
  8868. * Detach the current controls from the specified dom element.
  8869. * @param element Defines the element to stop listening the inputs from
  8870. */
  8871. detachControl(element: Nullable<HTMLElement>): void;
  8872. /**
  8873. * Update the current camera state depending on the inputs that have been used this frame.
  8874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8875. */
  8876. checkInputs(): void;
  8877. /**
  8878. * Gets the class name of the current intput.
  8879. * @returns the class name
  8880. */
  8881. getClassName(): string;
  8882. /** @hidden */
  8883. _onLostFocus(): void;
  8884. /**
  8885. * Get the friendly name associated with the input class.
  8886. * @returns the input friendly name
  8887. */
  8888. getSimpleName(): string;
  8889. }
  8890. }
  8891. declare module BABYLON {
  8892. /**
  8893. * Interface describing all the common properties and methods a shadow light needs to implement.
  8894. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8895. * as well as binding the different shadow properties to the effects.
  8896. */
  8897. export interface IShadowLight extends Light {
  8898. /**
  8899. * The light id in the scene (used in scene.findLighById for instance)
  8900. */
  8901. id: string;
  8902. /**
  8903. * The position the shdow will be casted from.
  8904. */
  8905. position: Vector3;
  8906. /**
  8907. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8908. */
  8909. direction: Vector3;
  8910. /**
  8911. * The transformed position. Position of the light in world space taking parenting in account.
  8912. */
  8913. transformedPosition: Vector3;
  8914. /**
  8915. * The transformed direction. Direction of the light in world space taking parenting in account.
  8916. */
  8917. transformedDirection: Vector3;
  8918. /**
  8919. * The friendly name of the light in the scene.
  8920. */
  8921. name: string;
  8922. /**
  8923. * Defines the shadow projection clipping minimum z value.
  8924. */
  8925. shadowMinZ: number;
  8926. /**
  8927. * Defines the shadow projection clipping maximum z value.
  8928. */
  8929. shadowMaxZ: number;
  8930. /**
  8931. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8932. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8933. */
  8934. computeTransformedInformation(): boolean;
  8935. /**
  8936. * Gets the scene the light belongs to.
  8937. * @returns The scene
  8938. */
  8939. getScene(): Scene;
  8940. /**
  8941. * Callback defining a custom Projection Matrix Builder.
  8942. * This can be used to override the default projection matrix computation.
  8943. */
  8944. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8945. /**
  8946. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8947. * @param matrix The materix to updated with the projection information
  8948. * @param viewMatrix The transform matrix of the light
  8949. * @param renderList The list of mesh to render in the map
  8950. * @returns The current light
  8951. */
  8952. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8953. /**
  8954. * Gets the current depth scale used in ESM.
  8955. * @returns The scale
  8956. */
  8957. getDepthScale(): number;
  8958. /**
  8959. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8960. * @returns true if a cube texture needs to be use
  8961. */
  8962. needCube(): boolean;
  8963. /**
  8964. * Detects if the projection matrix requires to be recomputed this frame.
  8965. * @returns true if it requires to be recomputed otherwise, false.
  8966. */
  8967. needProjectionMatrixCompute(): boolean;
  8968. /**
  8969. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8970. */
  8971. forceProjectionMatrixCompute(): void;
  8972. /**
  8973. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8974. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8975. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8976. */
  8977. getShadowDirection(faceIndex?: number): Vector3;
  8978. /**
  8979. * Gets the minZ used for shadow according to both the scene and the light.
  8980. * @param activeCamera The camera we are returning the min for
  8981. * @returns the depth min z
  8982. */
  8983. getDepthMinZ(activeCamera: Camera): number;
  8984. /**
  8985. * Gets the maxZ used for shadow according to both the scene and the light.
  8986. * @param activeCamera The camera we are returning the max for
  8987. * @returns the depth max z
  8988. */
  8989. getDepthMaxZ(activeCamera: Camera): number;
  8990. }
  8991. /**
  8992. * Base implementation IShadowLight
  8993. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8994. */
  8995. export abstract class ShadowLight extends Light implements IShadowLight {
  8996. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8997. protected _position: Vector3;
  8998. protected _setPosition(value: Vector3): void;
  8999. /**
  9000. * Sets the position the shadow will be casted from. Also use as the light position for both
  9001. * point and spot lights.
  9002. */
  9003. /**
  9004. * Sets the position the shadow will be casted from. Also use as the light position for both
  9005. * point and spot lights.
  9006. */
  9007. position: Vector3;
  9008. protected _direction: Vector3;
  9009. protected _setDirection(value: Vector3): void;
  9010. /**
  9011. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9012. * Also use as the light direction on spot and directional lights.
  9013. */
  9014. /**
  9015. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9016. * Also use as the light direction on spot and directional lights.
  9017. */
  9018. direction: Vector3;
  9019. private _shadowMinZ;
  9020. /**
  9021. * Gets the shadow projection clipping minimum z value.
  9022. */
  9023. /**
  9024. * Sets the shadow projection clipping minimum z value.
  9025. */
  9026. shadowMinZ: number;
  9027. private _shadowMaxZ;
  9028. /**
  9029. * Sets the shadow projection clipping maximum z value.
  9030. */
  9031. /**
  9032. * Gets the shadow projection clipping maximum z value.
  9033. */
  9034. shadowMaxZ: number;
  9035. /**
  9036. * Callback defining a custom Projection Matrix Builder.
  9037. * This can be used to override the default projection matrix computation.
  9038. */
  9039. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9040. /**
  9041. * The transformed position. Position of the light in world space taking parenting in account.
  9042. */
  9043. transformedPosition: Vector3;
  9044. /**
  9045. * The transformed direction. Direction of the light in world space taking parenting in account.
  9046. */
  9047. transformedDirection: Vector3;
  9048. private _needProjectionMatrixCompute;
  9049. /**
  9050. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9051. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9052. */
  9053. computeTransformedInformation(): boolean;
  9054. /**
  9055. * Return the depth scale used for the shadow map.
  9056. * @returns the depth scale.
  9057. */
  9058. getDepthScale(): number;
  9059. /**
  9060. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9061. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9062. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9063. */
  9064. getShadowDirection(faceIndex?: number): Vector3;
  9065. /**
  9066. * Returns the ShadowLight absolute position in the World.
  9067. * @returns the position vector in world space
  9068. */
  9069. getAbsolutePosition(): Vector3;
  9070. /**
  9071. * Sets the ShadowLight direction toward the passed target.
  9072. * @param target The point to target in local space
  9073. * @returns the updated ShadowLight direction
  9074. */
  9075. setDirectionToTarget(target: Vector3): Vector3;
  9076. /**
  9077. * Returns the light rotation in euler definition.
  9078. * @returns the x y z rotation in local space.
  9079. */
  9080. getRotation(): Vector3;
  9081. /**
  9082. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9083. * @returns true if a cube texture needs to be use
  9084. */
  9085. needCube(): boolean;
  9086. /**
  9087. * Detects if the projection matrix requires to be recomputed this frame.
  9088. * @returns true if it requires to be recomputed otherwise, false.
  9089. */
  9090. needProjectionMatrixCompute(): boolean;
  9091. /**
  9092. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9093. */
  9094. forceProjectionMatrixCompute(): void;
  9095. /** @hidden */
  9096. _initCache(): void;
  9097. /** @hidden */
  9098. _isSynchronized(): boolean;
  9099. /**
  9100. * Computes the world matrix of the node
  9101. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9102. * @returns the world matrix
  9103. */
  9104. computeWorldMatrix(force?: boolean): Matrix;
  9105. /**
  9106. * Gets the minZ used for shadow according to both the scene and the light.
  9107. * @param activeCamera The camera we are returning the min for
  9108. * @returns the depth min z
  9109. */
  9110. getDepthMinZ(activeCamera: Camera): number;
  9111. /**
  9112. * Gets the maxZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the max for
  9114. * @returns the depth max z
  9115. */
  9116. getDepthMaxZ(activeCamera: Camera): number;
  9117. /**
  9118. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9119. * @param matrix The materix to updated with the projection information
  9120. * @param viewMatrix The transform matrix of the light
  9121. * @param renderList The list of mesh to render in the map
  9122. * @returns The current light
  9123. */
  9124. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9125. }
  9126. }
  9127. declare module BABYLON {
  9128. /**
  9129. * "Static Class" containing the most commonly used helper while dealing with material for
  9130. * rendering purpose.
  9131. *
  9132. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9133. *
  9134. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9135. */
  9136. export class MaterialHelper {
  9137. /**
  9138. * Bind the current view position to an effect.
  9139. * @param effect The effect to be bound
  9140. * @param scene The scene the eyes position is used from
  9141. */
  9142. static BindEyePosition(effect: Effect, scene: Scene): void;
  9143. /**
  9144. * Helps preparing the defines values about the UVs in used in the effect.
  9145. * UVs are shared as much as we can accross channels in the shaders.
  9146. * @param texture The texture we are preparing the UVs for
  9147. * @param defines The defines to update
  9148. * @param key The channel key "diffuse", "specular"... used in the shader
  9149. */
  9150. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9151. /**
  9152. * Binds a texture matrix value to its corrsponding uniform
  9153. * @param texture The texture to bind the matrix for
  9154. * @param uniformBuffer The uniform buffer receivin the data
  9155. * @param key The channel key "diffuse", "specular"... used in the shader
  9156. */
  9157. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9158. /**
  9159. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9160. * @param mesh defines the current mesh
  9161. * @param scene defines the current scene
  9162. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9163. * @param pointsCloud defines if point cloud rendering has to be turned on
  9164. * @param fogEnabled defines if fog has to be turned on
  9165. * @param alphaTest defines if alpha testing has to be turned on
  9166. * @param defines defines the current list of defines
  9167. */
  9168. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9169. /**
  9170. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9171. * @param scene defines the current scene
  9172. * @param engine defines the current engine
  9173. * @param defines specifies the list of active defines
  9174. * @param useInstances defines if instances have to be turned on
  9175. * @param useClipPlane defines if clip plane have to be turned on
  9176. */
  9177. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9178. /**
  9179. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9180. * @param mesh The mesh containing the geometry data we will draw
  9181. * @param defines The defines to update
  9182. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9183. * @param useBones Precise whether bones should be used or not (override mesh info)
  9184. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9185. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9186. * @returns false if defines are considered not dirty and have not been checked
  9187. */
  9188. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9189. /**
  9190. * Prepares the defines related to multiview
  9191. * @param scene The scene we are intending to draw
  9192. * @param defines The defines to update
  9193. */
  9194. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param defines The defines to update
  9200. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9201. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9202. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9203. * @returns true if normals will be required for the rest of the effect
  9204. */
  9205. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9208. * that won t be acctive due to defines being turned off.
  9209. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9210. * @param samplersList The samplers list
  9211. * @param defines The defines helping in the list generation
  9212. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9213. */
  9214. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9215. /**
  9216. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9217. * @param defines The defines to update while falling back
  9218. * @param fallbacks The authorized effect fallbacks
  9219. * @param maxSimultaneousLights The maximum number of lights allowed
  9220. * @param rank the current rank of the Effect
  9221. * @returns The newly affected rank
  9222. */
  9223. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9224. /**
  9225. * Prepares the list of attributes required for morph targets according to the effect defines.
  9226. * @param attribs The current list of supported attribs
  9227. * @param mesh The mesh to prepare the morph targets attributes for
  9228. * @param defines The current Defines of the effect
  9229. */
  9230. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9231. /**
  9232. * Prepares the list of attributes required for bones according to the effect defines.
  9233. * @param attribs The current list of supported attribs
  9234. * @param mesh The mesh to prepare the bones attributes for
  9235. * @param defines The current Defines of the effect
  9236. * @param fallbacks The current efffect fallback strategy
  9237. */
  9238. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9239. /**
  9240. * Prepares the list of attributes required for instances according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param defines The current Defines of the effect
  9243. */
  9244. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9245. /**
  9246. * Binds the light shadow information to the effect for the given mesh.
  9247. * @param light The light containing the generator
  9248. * @param scene The scene the lights belongs to
  9249. * @param mesh The mesh we are binding the information to render
  9250. * @param lightIndex The light index in the effect used to render the mesh
  9251. * @param effect The effect we are binding the data to
  9252. */
  9253. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9254. /**
  9255. * Binds the light information to the effect.
  9256. * @param light The light containing the generator
  9257. * @param effect The effect we are binding the data to
  9258. * @param lightIndex The light index in the effect used to render
  9259. */
  9260. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9261. /**
  9262. * Binds the lights information from the scene to the effect for the given mesh.
  9263. * @param scene The scene the lights belongs to
  9264. * @param mesh The mesh we are binding the information to render
  9265. * @param effect The effect we are binding the data to
  9266. * @param defines The generated defines for the effect
  9267. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9268. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9269. */
  9270. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9271. private static _tempFogColor;
  9272. /**
  9273. * Binds the fog information from the scene to the effect for the given mesh.
  9274. * @param scene The scene the lights belongs to
  9275. * @param mesh The mesh we are binding the information to render
  9276. * @param effect The effect we are binding the data to
  9277. * @param linearSpace Defines if the fog effect is applied in linear space
  9278. */
  9279. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9280. /**
  9281. * Binds the bones information from the mesh to the effect.
  9282. * @param mesh The mesh we are binding the information to render
  9283. * @param effect The effect we are binding the data to
  9284. */
  9285. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9286. /**
  9287. * Binds the morph targets information from the mesh to the effect.
  9288. * @param abstractMesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. */
  9291. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9292. /**
  9293. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9294. * @param defines The generated defines used in the effect
  9295. * @param effect The effect we are binding the data to
  9296. * @param scene The scene we are willing to render with logarithmic scale for
  9297. */
  9298. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9299. /**
  9300. * Binds the clip plane information from the scene to the effect.
  9301. * @param scene The scene the clip plane information are extracted from
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindClipPlane(effect: Effect, scene: Scene): void;
  9305. }
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var kernelBlurVaryingDeclaration: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var kernelBlurFragment: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var kernelBlurFragment2: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var kernelBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var kernelBlurVertex: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var kernelBlurVertexShader: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /**
  9351. * The Blur Post Process which blurs an image based on a kernel and direction.
  9352. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9353. */
  9354. export class BlurPostProcess extends PostProcess {
  9355. /** The direction in which to blur the image. */
  9356. direction: Vector2;
  9357. private blockCompilation;
  9358. protected _kernel: number;
  9359. protected _idealKernel: number;
  9360. protected _packedFloat: boolean;
  9361. private _staticDefines;
  9362. /**
  9363. * Sets the length in pixels of the blur sample region
  9364. */
  9365. /**
  9366. * Gets the length in pixels of the blur sample region
  9367. */
  9368. kernel: number;
  9369. /**
  9370. * Sets wether or not the blur needs to unpack/repack floats
  9371. */
  9372. /**
  9373. * Gets wether or not the blur is unpacking/repacking floats
  9374. */
  9375. packedFloat: boolean;
  9376. /**
  9377. * Creates a new instance BlurPostProcess
  9378. * @param name The name of the effect.
  9379. * @param direction The direction in which to blur the image.
  9380. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9381. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9382. * @param camera The camera to apply the render pass to.
  9383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9384. * @param engine The engine which the post process will be applied. (default: current engine)
  9385. * @param reusable If the post process can be reused on the same frame. (default: false)
  9386. * @param textureType Type of textures used when performing the post process. (default: 0)
  9387. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9388. */
  9389. constructor(name: string,
  9390. /** The direction in which to blur the image. */
  9391. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9392. /**
  9393. * Updates the effect with the current post process compile time values and recompiles the shader.
  9394. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9395. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9396. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9397. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9398. * @param onCompiled Called when the shader has been compiled.
  9399. * @param onError Called if there is an error when compiling a shader.
  9400. */
  9401. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9402. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9403. /**
  9404. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9405. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9406. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9407. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9408. * The gaps between physical kernels are compensated for in the weighting of the samples
  9409. * @param idealKernel Ideal blur kernel.
  9410. * @return Nearest best kernel.
  9411. */
  9412. protected _nearestBestKernel(idealKernel: number): number;
  9413. /**
  9414. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9415. * @param x The point on the Gaussian distribution to sample.
  9416. * @return the value of the Gaussian function at x.
  9417. */
  9418. protected _gaussianWeight(x: number): number;
  9419. /**
  9420. * Generates a string that can be used as a floating point number in GLSL.
  9421. * @param x Value to print.
  9422. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9423. * @return GLSL float string.
  9424. */
  9425. protected _glslFloat(x: number, decimalFigures?: number): string;
  9426. }
  9427. }
  9428. declare module BABYLON {
  9429. /** @hidden */
  9430. export var shadowMapPixelShader: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module BABYLON {
  9436. /** @hidden */
  9437. export var bonesDeclaration: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module BABYLON {
  9443. /** @hidden */
  9444. export var morphTargetsVertexGlobalDeclaration: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module BABYLON {
  9450. /** @hidden */
  9451. export var morphTargetsVertexDeclaration: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module BABYLON {
  9457. /** @hidden */
  9458. export var instancesDeclaration: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module BABYLON {
  9464. /** @hidden */
  9465. export var helperFunctions: {
  9466. name: string;
  9467. shader: string;
  9468. };
  9469. }
  9470. declare module BABYLON {
  9471. /** @hidden */
  9472. export var morphTargetsVertex: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module BABYLON {
  9478. /** @hidden */
  9479. export var instancesVertex: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var bonesVertex: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var shadowMapVertexShader: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /** @hidden */
  9500. export var depthBoxBlurPixelShader: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module BABYLON {
  9506. /**
  9507. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9508. */
  9509. export interface ICustomShaderOptions {
  9510. /**
  9511. * Gets or sets the custom shader name to use
  9512. */
  9513. shaderName: string;
  9514. /**
  9515. * The list of attribute names used in the shader
  9516. */
  9517. attributes?: string[];
  9518. /**
  9519. * The list of unifrom names used in the shader
  9520. */
  9521. uniforms?: string[];
  9522. /**
  9523. * The list of sampler names used in the shader
  9524. */
  9525. samplers?: string[];
  9526. /**
  9527. * The list of defines used in the shader
  9528. */
  9529. defines?: string[];
  9530. }
  9531. /**
  9532. * Interface to implement to create a shadow generator compatible with BJS.
  9533. */
  9534. export interface IShadowGenerator {
  9535. /**
  9536. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9537. * @returns The render target texture if present otherwise, null
  9538. */
  9539. getShadowMap(): Nullable<RenderTargetTexture>;
  9540. /**
  9541. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9542. * @returns The render target texture if the shadow map is present otherwise, null
  9543. */
  9544. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9545. /**
  9546. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9547. * @param subMesh The submesh we want to render in the shadow map
  9548. * @param useInstances Defines wether will draw in the map using instances
  9549. * @returns true if ready otherwise, false
  9550. */
  9551. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9552. /**
  9553. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9554. * @param defines Defines of the material we want to update
  9555. * @param lightIndex Index of the light in the enabled light list of the material
  9556. */
  9557. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9558. /**
  9559. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9560. * defined in the generator but impacting the effect).
  9561. * It implies the unifroms available on the materials are the standard BJS ones.
  9562. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9563. * @param effect The effect we are binfing the information for
  9564. */
  9565. bindShadowLight(lightIndex: string, effect: Effect): void;
  9566. /**
  9567. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9568. * (eq to shadow prjection matrix * light transform matrix)
  9569. * @returns The transform matrix used to create the shadow map
  9570. */
  9571. getTransformMatrix(): Matrix;
  9572. /**
  9573. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9574. * Cube and 2D textures for instance.
  9575. */
  9576. recreateShadowMap(): void;
  9577. /**
  9578. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9579. * @param onCompiled Callback triggered at the and of the effects compilation
  9580. * @param options Sets of optional options forcing the compilation with different modes
  9581. */
  9582. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9583. useInstances: boolean;
  9584. }>): void;
  9585. /**
  9586. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9587. * @param options Sets of optional options forcing the compilation with different modes
  9588. * @returns A promise that resolves when the compilation completes
  9589. */
  9590. forceCompilationAsync(options?: Partial<{
  9591. useInstances: boolean;
  9592. }>): Promise<void>;
  9593. /**
  9594. * Serializes the shadow generator setup to a json object.
  9595. * @returns The serialized JSON object
  9596. */
  9597. serialize(): any;
  9598. /**
  9599. * Disposes the Shadow map and related Textures and effects.
  9600. */
  9601. dispose(): void;
  9602. }
  9603. /**
  9604. * Default implementation IShadowGenerator.
  9605. * This is the main object responsible of generating shadows in the framework.
  9606. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9607. */
  9608. export class ShadowGenerator implements IShadowGenerator {
  9609. /**
  9610. * Shadow generator mode None: no filtering applied.
  9611. */
  9612. static readonly FILTER_NONE: number;
  9613. /**
  9614. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9615. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9616. */
  9617. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9618. /**
  9619. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9620. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9621. */
  9622. static readonly FILTER_POISSONSAMPLING: number;
  9623. /**
  9624. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9626. */
  9627. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9628. /**
  9629. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9630. * edge artifacts on steep falloff.
  9631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9632. */
  9633. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9634. /**
  9635. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9636. * edge artifacts on steep falloff.
  9637. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9638. */
  9639. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9640. /**
  9641. * Shadow generator mode PCF: Percentage Closer Filtering
  9642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9643. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9644. */
  9645. static readonly FILTER_PCF: number;
  9646. /**
  9647. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9648. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9649. * Contact Hardening
  9650. */
  9651. static readonly FILTER_PCSS: number;
  9652. /**
  9653. * Reserved for PCF and PCSS
  9654. * Highest Quality.
  9655. *
  9656. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9657. *
  9658. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9659. */
  9660. static readonly QUALITY_HIGH: number;
  9661. /**
  9662. * Reserved for PCF and PCSS
  9663. * Good tradeoff for quality/perf cross devices
  9664. *
  9665. * Execute PCF on a 3*3 kernel.
  9666. *
  9667. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9668. */
  9669. static readonly QUALITY_MEDIUM: number;
  9670. /**
  9671. * Reserved for PCF and PCSS
  9672. * The lowest quality but the fastest.
  9673. *
  9674. * Execute PCF on a 1*1 kernel.
  9675. *
  9676. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9677. */
  9678. static readonly QUALITY_LOW: number;
  9679. /** Gets or sets the custom shader name to use */
  9680. customShaderOptions: ICustomShaderOptions;
  9681. /**
  9682. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9683. */
  9684. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9685. /**
  9686. * Observable triggered before a mesh is rendered in the shadow map.
  9687. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9688. */
  9689. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9690. private _bias;
  9691. /**
  9692. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9693. */
  9694. /**
  9695. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9696. */
  9697. bias: number;
  9698. private _normalBias;
  9699. /**
  9700. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9701. */
  9702. /**
  9703. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9704. */
  9705. normalBias: number;
  9706. private _blurBoxOffset;
  9707. /**
  9708. * Gets the blur box offset: offset applied during the blur pass.
  9709. * Only useful if useKernelBlur = false
  9710. */
  9711. /**
  9712. * Sets the blur box offset: offset applied during the blur pass.
  9713. * Only useful if useKernelBlur = false
  9714. */
  9715. blurBoxOffset: number;
  9716. private _blurScale;
  9717. /**
  9718. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9719. * 2 means half of the size.
  9720. */
  9721. /**
  9722. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9723. * 2 means half of the size.
  9724. */
  9725. blurScale: number;
  9726. private _blurKernel;
  9727. /**
  9728. * Gets the blur kernel: kernel size of the blur pass.
  9729. * Only useful if useKernelBlur = true
  9730. */
  9731. /**
  9732. * Sets the blur kernel: kernel size of the blur pass.
  9733. * Only useful if useKernelBlur = true
  9734. */
  9735. blurKernel: number;
  9736. private _useKernelBlur;
  9737. /**
  9738. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9739. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9740. */
  9741. /**
  9742. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9743. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9744. */
  9745. useKernelBlur: boolean;
  9746. private _depthScale;
  9747. /**
  9748. * Gets the depth scale used in ESM mode.
  9749. */
  9750. /**
  9751. * Sets the depth scale used in ESM mode.
  9752. * This can override the scale stored on the light.
  9753. */
  9754. depthScale: number;
  9755. private _filter;
  9756. /**
  9757. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9758. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9759. */
  9760. /**
  9761. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9762. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9763. */
  9764. filter: number;
  9765. /**
  9766. * Gets if the current filter is set to Poisson Sampling.
  9767. */
  9768. /**
  9769. * Sets the current filter to Poisson Sampling.
  9770. */
  9771. usePoissonSampling: boolean;
  9772. /**
  9773. * Gets if the current filter is set to ESM.
  9774. */
  9775. /**
  9776. * Sets the current filter is to ESM.
  9777. */
  9778. useExponentialShadowMap: boolean;
  9779. /**
  9780. * Gets if the current filter is set to filtered ESM.
  9781. */
  9782. /**
  9783. * Gets if the current filter is set to filtered ESM.
  9784. */
  9785. useBlurExponentialShadowMap: boolean;
  9786. /**
  9787. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9788. * exponential to prevent steep falloff artifacts).
  9789. */
  9790. /**
  9791. * Sets the current filter to "close ESM" (using the inverse of the
  9792. * exponential to prevent steep falloff artifacts).
  9793. */
  9794. useCloseExponentialShadowMap: boolean;
  9795. /**
  9796. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9797. * exponential to prevent steep falloff artifacts).
  9798. */
  9799. /**
  9800. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9801. * exponential to prevent steep falloff artifacts).
  9802. */
  9803. useBlurCloseExponentialShadowMap: boolean;
  9804. /**
  9805. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9806. */
  9807. /**
  9808. * Sets the current filter to "PCF" (percentage closer filtering).
  9809. */
  9810. usePercentageCloserFiltering: boolean;
  9811. private _filteringQuality;
  9812. /**
  9813. * Gets the PCF or PCSS Quality.
  9814. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9815. */
  9816. /**
  9817. * Sets the PCF or PCSS Quality.
  9818. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9819. */
  9820. filteringQuality: number;
  9821. /**
  9822. * Gets if the current filter is set to "PCSS" (contact hardening).
  9823. */
  9824. /**
  9825. * Sets the current filter to "PCSS" (contact hardening).
  9826. */
  9827. useContactHardeningShadow: boolean;
  9828. private _contactHardeningLightSizeUVRatio;
  9829. /**
  9830. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9831. * Using a ratio helps keeping shape stability independently of the map size.
  9832. *
  9833. * It does not account for the light projection as it was having too much
  9834. * instability during the light setup or during light position changes.
  9835. *
  9836. * Only valid if useContactHardeningShadow is true.
  9837. */
  9838. /**
  9839. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9840. * Using a ratio helps keeping shape stability independently of the map size.
  9841. *
  9842. * It does not account for the light projection as it was having too much
  9843. * instability during the light setup or during light position changes.
  9844. *
  9845. * Only valid if useContactHardeningShadow is true.
  9846. */
  9847. contactHardeningLightSizeUVRatio: number;
  9848. private _darkness;
  9849. /**
  9850. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9851. * 0 means strongest and 1 would means no shadow.
  9852. * @returns the darkness.
  9853. */
  9854. getDarkness(): number;
  9855. /**
  9856. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9857. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9858. * @returns the shadow generator allowing fluent coding.
  9859. */
  9860. setDarkness(darkness: number): ShadowGenerator;
  9861. private _transparencyShadow;
  9862. /**
  9863. * Sets the ability to have transparent shadow (boolean).
  9864. * @param transparent True if transparent else False
  9865. * @returns the shadow generator allowing fluent coding
  9866. */
  9867. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9868. private _shadowMap;
  9869. private _shadowMap2;
  9870. /**
  9871. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9872. * @returns The render target texture if present otherwise, null
  9873. */
  9874. getShadowMap(): Nullable<RenderTargetTexture>;
  9875. /**
  9876. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9877. * @returns The render target texture if the shadow map is present otherwise, null
  9878. */
  9879. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9880. /**
  9881. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9882. * @param mesh Mesh to add
  9883. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9884. * @returns the Shadow Generator itself
  9885. */
  9886. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9887. /**
  9888. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9889. * @param mesh Mesh to remove
  9890. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9891. * @returns the Shadow Generator itself
  9892. */
  9893. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9894. /**
  9895. * Controls the extent to which the shadows fade out at the edge of the frustum
  9896. * Used only by directionals and spots
  9897. */
  9898. frustumEdgeFalloff: number;
  9899. private _light;
  9900. /**
  9901. * Returns the associated light object.
  9902. * @returns the light generating the shadow
  9903. */
  9904. getLight(): IShadowLight;
  9905. /**
  9906. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9907. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9908. * It might on the other hand introduce peter panning.
  9909. */
  9910. forceBackFacesOnly: boolean;
  9911. private _scene;
  9912. private _lightDirection;
  9913. private _effect;
  9914. private _viewMatrix;
  9915. private _projectionMatrix;
  9916. private _transformMatrix;
  9917. private _cachedPosition;
  9918. private _cachedDirection;
  9919. private _cachedDefines;
  9920. private _currentRenderID;
  9921. private _boxBlurPostprocess;
  9922. private _kernelBlurXPostprocess;
  9923. private _kernelBlurYPostprocess;
  9924. private _blurPostProcesses;
  9925. private _mapSize;
  9926. private _currentFaceIndex;
  9927. private _currentFaceIndexCache;
  9928. private _textureType;
  9929. private _defaultTextureMatrix;
  9930. /** @hidden */
  9931. static _SceneComponentInitialization: (scene: Scene) => void;
  9932. /**
  9933. * Creates a ShadowGenerator object.
  9934. * A ShadowGenerator is the required tool to use the shadows.
  9935. * Each light casting shadows needs to use its own ShadowGenerator.
  9936. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9937. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9938. * @param light The light object generating the shadows.
  9939. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9940. */
  9941. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9942. private _initializeGenerator;
  9943. private _initializeShadowMap;
  9944. private _initializeBlurRTTAndPostProcesses;
  9945. private _renderForShadowMap;
  9946. private _renderSubMeshForShadowMap;
  9947. private _applyFilterValues;
  9948. /**
  9949. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9950. * @param onCompiled Callback triggered at the and of the effects compilation
  9951. * @param options Sets of optional options forcing the compilation with different modes
  9952. */
  9953. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9954. useInstances: boolean;
  9955. }>): void;
  9956. /**
  9957. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9958. * @param options Sets of optional options forcing the compilation with different modes
  9959. * @returns A promise that resolves when the compilation completes
  9960. */
  9961. forceCompilationAsync(options?: Partial<{
  9962. useInstances: boolean;
  9963. }>): Promise<void>;
  9964. /**
  9965. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9966. * @param subMesh The submesh we want to render in the shadow map
  9967. * @param useInstances Defines wether will draw in the map using instances
  9968. * @returns true if ready otherwise, false
  9969. */
  9970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9971. /**
  9972. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9973. * @param defines Defines of the material we want to update
  9974. * @param lightIndex Index of the light in the enabled light list of the material
  9975. */
  9976. prepareDefines(defines: any, lightIndex: number): void;
  9977. /**
  9978. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9979. * defined in the generator but impacting the effect).
  9980. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9981. * @param effect The effect we are binfing the information for
  9982. */
  9983. bindShadowLight(lightIndex: string, effect: Effect): void;
  9984. /**
  9985. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9986. * (eq to shadow prjection matrix * light transform matrix)
  9987. * @returns The transform matrix used to create the shadow map
  9988. */
  9989. getTransformMatrix(): Matrix;
  9990. /**
  9991. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9992. * Cube and 2D textures for instance.
  9993. */
  9994. recreateShadowMap(): void;
  9995. private _disposeBlurPostProcesses;
  9996. private _disposeRTTandPostProcesses;
  9997. /**
  9998. * Disposes the ShadowGenerator.
  9999. * Returns nothing.
  10000. */
  10001. dispose(): void;
  10002. /**
  10003. * Serializes the shadow generator setup to a json object.
  10004. * @returns The serialized JSON object
  10005. */
  10006. serialize(): any;
  10007. /**
  10008. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10009. * @param parsedShadowGenerator The JSON object to parse
  10010. * @param scene The scene to create the shadow map for
  10011. * @returns The parsed shadow generator
  10012. */
  10013. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10014. }
  10015. }
  10016. declare module BABYLON {
  10017. /**
  10018. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10019. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10020. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  10021. */
  10022. export abstract class Light extends Node {
  10023. /**
  10024. * Falloff Default: light is falling off following the material specification:
  10025. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10026. */
  10027. static readonly FALLOFF_DEFAULT: number;
  10028. /**
  10029. * Falloff Physical: light is falling off following the inverse squared distance law.
  10030. */
  10031. static readonly FALLOFF_PHYSICAL: number;
  10032. /**
  10033. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10034. * to enhance interoperability with other engines.
  10035. */
  10036. static readonly FALLOFF_GLTF: number;
  10037. /**
  10038. * Falloff Standard: light is falling off like in the standard material
  10039. * to enhance interoperability with other materials.
  10040. */
  10041. static readonly FALLOFF_STANDARD: number;
  10042. /**
  10043. * If every light affecting the material is in this lightmapMode,
  10044. * material.lightmapTexture adds or multiplies
  10045. * (depends on material.useLightmapAsShadowmap)
  10046. * after every other light calculations.
  10047. */
  10048. static readonly LIGHTMAP_DEFAULT: number;
  10049. /**
  10050. * material.lightmapTexture as only diffuse lighting from this light
  10051. * adds only specular lighting from this light
  10052. * adds dynamic shadows
  10053. */
  10054. static readonly LIGHTMAP_SPECULAR: number;
  10055. /**
  10056. * material.lightmapTexture as only lighting
  10057. * no light calculation from this light
  10058. * only adds dynamic shadows from this light
  10059. */
  10060. static readonly LIGHTMAP_SHADOWSONLY: number;
  10061. /**
  10062. * Each light type uses the default quantity according to its type:
  10063. * point/spot lights use luminous intensity
  10064. * directional lights use illuminance
  10065. */
  10066. static readonly INTENSITYMODE_AUTOMATIC: number;
  10067. /**
  10068. * lumen (lm)
  10069. */
  10070. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10071. /**
  10072. * candela (lm/sr)
  10073. */
  10074. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10075. /**
  10076. * lux (lm/m^2)
  10077. */
  10078. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10079. /**
  10080. * nit (cd/m^2)
  10081. */
  10082. static readonly INTENSITYMODE_LUMINANCE: number;
  10083. /**
  10084. * Light type const id of the point light.
  10085. */
  10086. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10087. /**
  10088. * Light type const id of the directional light.
  10089. */
  10090. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10091. /**
  10092. * Light type const id of the spot light.
  10093. */
  10094. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10095. /**
  10096. * Light type const id of the hemispheric light.
  10097. */
  10098. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10099. /**
  10100. * Diffuse gives the basic color to an object.
  10101. */
  10102. diffuse: Color3;
  10103. /**
  10104. * Specular produces a highlight color on an object.
  10105. * Note: This is note affecting PBR materials.
  10106. */
  10107. specular: Color3;
  10108. /**
  10109. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10110. * falling off base on range or angle.
  10111. * This can be set to any values in Light.FALLOFF_x.
  10112. *
  10113. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10114. * other types of materials.
  10115. */
  10116. falloffType: number;
  10117. /**
  10118. * Strength of the light.
  10119. * Note: By default it is define in the framework own unit.
  10120. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10121. */
  10122. intensity: number;
  10123. private _range;
  10124. protected _inverseSquaredRange: number;
  10125. /**
  10126. * Defines how far from the source the light is impacting in scene units.
  10127. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10128. */
  10129. /**
  10130. * Defines how far from the source the light is impacting in scene units.
  10131. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10132. */
  10133. range: number;
  10134. /**
  10135. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10136. * of light.
  10137. */
  10138. private _photometricScale;
  10139. private _intensityMode;
  10140. /**
  10141. * Gets the photometric scale used to interpret the intensity.
  10142. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10143. */
  10144. /**
  10145. * Sets the photometric scale used to interpret the intensity.
  10146. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10147. */
  10148. intensityMode: number;
  10149. private _radius;
  10150. /**
  10151. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10152. */
  10153. /**
  10154. * sets the light radius used by PBR Materials to simulate soft area lights.
  10155. */
  10156. radius: number;
  10157. private _renderPriority;
  10158. /**
  10159. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10160. * exceeding the number allowed of the materials.
  10161. */
  10162. renderPriority: number;
  10163. private _shadowEnabled;
  10164. /**
  10165. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10166. * the current shadow generator.
  10167. */
  10168. /**
  10169. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10170. * the current shadow generator.
  10171. */
  10172. shadowEnabled: boolean;
  10173. private _includedOnlyMeshes;
  10174. /**
  10175. * Gets the only meshes impacted by this light.
  10176. */
  10177. /**
  10178. * Sets the only meshes impacted by this light.
  10179. */
  10180. includedOnlyMeshes: AbstractMesh[];
  10181. private _excludedMeshes;
  10182. /**
  10183. * Gets the meshes not impacted by this light.
  10184. */
  10185. /**
  10186. * Sets the meshes not impacted by this light.
  10187. */
  10188. excludedMeshes: AbstractMesh[];
  10189. private _excludeWithLayerMask;
  10190. /**
  10191. * Gets the layer id use to find what meshes are not impacted by the light.
  10192. * Inactive if 0
  10193. */
  10194. /**
  10195. * Sets the layer id use to find what meshes are not impacted by the light.
  10196. * Inactive if 0
  10197. */
  10198. excludeWithLayerMask: number;
  10199. private _includeOnlyWithLayerMask;
  10200. /**
  10201. * Gets the layer id use to find what meshes are impacted by the light.
  10202. * Inactive if 0
  10203. */
  10204. /**
  10205. * Sets the layer id use to find what meshes are impacted by the light.
  10206. * Inactive if 0
  10207. */
  10208. includeOnlyWithLayerMask: number;
  10209. private _lightmapMode;
  10210. /**
  10211. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10212. */
  10213. /**
  10214. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10215. */
  10216. lightmapMode: number;
  10217. /**
  10218. * Shadow generator associted to the light.
  10219. * @hidden Internal use only.
  10220. */
  10221. _shadowGenerator: Nullable<IShadowGenerator>;
  10222. /**
  10223. * @hidden Internal use only.
  10224. */
  10225. _excludedMeshesIds: string[];
  10226. /**
  10227. * @hidden Internal use only.
  10228. */
  10229. _includedOnlyMeshesIds: string[];
  10230. /**
  10231. * The current light unifom buffer.
  10232. * @hidden Internal use only.
  10233. */
  10234. _uniformBuffer: UniformBuffer;
  10235. /**
  10236. * Creates a Light object in the scene.
  10237. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10238. * @param name The firendly name of the light
  10239. * @param scene The scene the light belongs too
  10240. */
  10241. constructor(name: string, scene: Scene);
  10242. protected abstract _buildUniformLayout(): void;
  10243. /**
  10244. * Sets the passed Effect "effect" with the Light information.
  10245. * @param effect The effect to update
  10246. * @param lightIndex The index of the light in the effect to update
  10247. * @returns The light
  10248. */
  10249. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10250. /**
  10251. * Returns the string "Light".
  10252. * @returns the class name
  10253. */
  10254. getClassName(): string;
  10255. /** @hidden */
  10256. readonly _isLight: boolean;
  10257. /**
  10258. * Converts the light information to a readable string for debug purpose.
  10259. * @param fullDetails Supports for multiple levels of logging within scene loading
  10260. * @returns the human readable light info
  10261. */
  10262. toString(fullDetails?: boolean): string;
  10263. /** @hidden */
  10264. protected _syncParentEnabledState(): void;
  10265. /**
  10266. * Set the enabled state of this node.
  10267. * @param value - the new enabled state
  10268. */
  10269. setEnabled(value: boolean): void;
  10270. /**
  10271. * Returns the Light associated shadow generator if any.
  10272. * @return the associated shadow generator.
  10273. */
  10274. getShadowGenerator(): Nullable<IShadowGenerator>;
  10275. /**
  10276. * Returns a Vector3, the absolute light position in the World.
  10277. * @returns the world space position of the light
  10278. */
  10279. getAbsolutePosition(): Vector3;
  10280. /**
  10281. * Specifies if the light will affect the passed mesh.
  10282. * @param mesh The mesh to test against the light
  10283. * @return true the mesh is affected otherwise, false.
  10284. */
  10285. canAffectMesh(mesh: AbstractMesh): boolean;
  10286. /**
  10287. * Sort function to order lights for rendering.
  10288. * @param a First Light object to compare to second.
  10289. * @param b Second Light object to compare first.
  10290. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10291. */
  10292. static CompareLightsPriority(a: Light, b: Light): number;
  10293. /**
  10294. * Releases resources associated with this node.
  10295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10297. */
  10298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10299. /**
  10300. * Returns the light type ID (integer).
  10301. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10302. */
  10303. getTypeID(): number;
  10304. /**
  10305. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10306. * @returns the scaled intensity in intensity mode unit
  10307. */
  10308. getScaledIntensity(): number;
  10309. /**
  10310. * Returns a new Light object, named "name", from the current one.
  10311. * @param name The name of the cloned light
  10312. * @returns the new created light
  10313. */
  10314. clone(name: string): Nullable<Light>;
  10315. /**
  10316. * Serializes the current light into a Serialization object.
  10317. * @returns the serialized object.
  10318. */
  10319. serialize(): any;
  10320. /**
  10321. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10322. * This new light is named "name" and added to the passed scene.
  10323. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10324. * @param name The friendly name of the light
  10325. * @param scene The scene the new light will belong to
  10326. * @returns the constructor function
  10327. */
  10328. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10329. /**
  10330. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10331. * @param parsedLight The JSON representation of the light
  10332. * @param scene The scene to create the parsed light in
  10333. * @returns the created light after parsing
  10334. */
  10335. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10336. private _hookArrayForExcluded;
  10337. private _hookArrayForIncludedOnly;
  10338. private _resyncMeshes;
  10339. /**
  10340. * Forces the meshes to update their light related information in their rendering used effects
  10341. * @hidden Internal Use Only
  10342. */
  10343. _markMeshesAsLightDirty(): void;
  10344. /**
  10345. * Recomputes the cached photometric scale if needed.
  10346. */
  10347. private _computePhotometricScale;
  10348. /**
  10349. * Returns the Photometric Scale according to the light type and intensity mode.
  10350. */
  10351. private _getPhotometricScale;
  10352. /**
  10353. * Reorder the light in the scene according to their defined priority.
  10354. * @hidden Internal Use Only
  10355. */
  10356. _reorderLightsInScene(): void;
  10357. /**
  10358. * Prepares the list of defines specific to the light type.
  10359. * @param defines the list of defines
  10360. * @param lightIndex defines the index of the light for the effect
  10361. */
  10362. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10363. }
  10364. }
  10365. declare module BABYLON {
  10366. /**
  10367. * Interface used to define Action
  10368. */
  10369. export interface IAction {
  10370. /**
  10371. * Trigger for the action
  10372. */
  10373. trigger: number;
  10374. /** Options of the trigger */
  10375. triggerOptions: any;
  10376. /**
  10377. * Gets the trigger parameters
  10378. * @returns the trigger parameters
  10379. */
  10380. getTriggerParameter(): any;
  10381. /**
  10382. * Internal only - executes current action event
  10383. * @hidden
  10384. */
  10385. _executeCurrent(evt?: ActionEvent): void;
  10386. /**
  10387. * Serialize placeholder for child classes
  10388. * @param parent of child
  10389. * @returns the serialized object
  10390. */
  10391. serialize(parent: any): any;
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. _prepare(): void;
  10397. /**
  10398. * Internal only - manager for action
  10399. * @hidden
  10400. */
  10401. _actionManager: AbstractActionManager;
  10402. }
  10403. /**
  10404. * The action to be carried out following a trigger
  10405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10406. */
  10407. export class Action implements IAction {
  10408. /** the trigger, with or without parameters, for the action */
  10409. triggerOptions: any;
  10410. /**
  10411. * Trigger for the action
  10412. */
  10413. trigger: number;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. private _nextActiveAction;
  10420. private _child;
  10421. private _condition?;
  10422. private _triggerParameter;
  10423. /**
  10424. * An event triggered prior to action being executed.
  10425. */
  10426. onBeforeExecuteObservable: Observable<Action>;
  10427. /**
  10428. * Creates a new Action
  10429. * @param triggerOptions the trigger, with or without parameters, for the action
  10430. * @param condition an optional determinant of action
  10431. */
  10432. constructor(
  10433. /** the trigger, with or without parameters, for the action */
  10434. triggerOptions: any, condition?: Condition);
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. _prepare(): void;
  10440. /**
  10441. * Gets the trigger parameters
  10442. * @returns the trigger parameters
  10443. */
  10444. getTriggerParameter(): any;
  10445. /**
  10446. * Internal only - executes current action event
  10447. * @hidden
  10448. */
  10449. _executeCurrent(evt?: ActionEvent): void;
  10450. /**
  10451. * Execute placeholder for child classes
  10452. * @param evt optional action event
  10453. */
  10454. execute(evt?: ActionEvent): void;
  10455. /**
  10456. * Skips to next active action
  10457. */
  10458. skipToNextActiveAction(): void;
  10459. /**
  10460. * Adds action to chain of actions, may be a DoNothingAction
  10461. * @param action defines the next action to execute
  10462. * @returns The action passed in
  10463. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10464. */
  10465. then(action: Action): Action;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. _getProperty(propertyPath: string): string;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. _getEffectiveTarget(target: any, propertyPath: string): any;
  10476. /**
  10477. * Serialize placeholder for child classes
  10478. * @param parent of child
  10479. * @returns the serialized object
  10480. */
  10481. serialize(parent: any): any;
  10482. /**
  10483. * Internal only called by serialize
  10484. * @hidden
  10485. */
  10486. protected _serialize(serializedAction: any, parent?: any): any;
  10487. /**
  10488. * Internal only
  10489. * @hidden
  10490. */
  10491. static _SerializeValueAsString: (value: any) => string;
  10492. /**
  10493. * Internal only
  10494. * @hidden
  10495. */
  10496. static _GetTargetProperty: (target: Scene | Node) => {
  10497. name: string;
  10498. targetType: string;
  10499. value: string;
  10500. };
  10501. }
  10502. }
  10503. declare module BABYLON {
  10504. /**
  10505. * A Condition applied to an Action
  10506. */
  10507. export class Condition {
  10508. /**
  10509. * Internal only - manager for action
  10510. * @hidden
  10511. */
  10512. _actionManager: ActionManager;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _evaluationId: number;
  10518. /**
  10519. * Internal only
  10520. * @hidden
  10521. */
  10522. _currentResult: boolean;
  10523. /**
  10524. * Creates a new Condition
  10525. * @param actionManager the manager of the action the condition is applied to
  10526. */
  10527. constructor(actionManager: ActionManager);
  10528. /**
  10529. * Check if the current condition is valid
  10530. * @returns a boolean
  10531. */
  10532. isValid(): boolean;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getProperty(propertyPath: string): string;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. _getEffectiveTarget(target: any, propertyPath: string): any;
  10543. /**
  10544. * Serialize placeholder for child classes
  10545. * @returns the serialized object
  10546. */
  10547. serialize(): any;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. protected _serialize(serializedCondition: any): any;
  10553. }
  10554. /**
  10555. * Defines specific conditional operators as extensions of Condition
  10556. */
  10557. export class ValueCondition extends Condition {
  10558. /** path to specify the property of the target the conditional operator uses */
  10559. propertyPath: string;
  10560. /** the value compared by the conditional operator against the current value of the property */
  10561. value: any;
  10562. /** the conditional operator, default ValueCondition.IsEqual */
  10563. operator: number;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsEqual;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsDifferent;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsGreater;
  10579. /**
  10580. * Internal only
  10581. * @hidden
  10582. */
  10583. private static _IsLesser;
  10584. /**
  10585. * returns the number for IsEqual
  10586. */
  10587. static readonly IsEqual: number;
  10588. /**
  10589. * Returns the number for IsDifferent
  10590. */
  10591. static readonly IsDifferent: number;
  10592. /**
  10593. * Returns the number for IsGreater
  10594. */
  10595. static readonly IsGreater: number;
  10596. /**
  10597. * Returns the number for IsLesser
  10598. */
  10599. static readonly IsLesser: number;
  10600. /**
  10601. * Internal only The action manager for the condition
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _target;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _effectiveTarget;
  10615. /**
  10616. * Internal only
  10617. * @hidden
  10618. */
  10619. private _property;
  10620. /**
  10621. * Creates a new ValueCondition
  10622. * @param actionManager manager for the action the condition applies to
  10623. * @param target for the action
  10624. * @param propertyPath path to specify the property of the target the conditional operator uses
  10625. * @param value the value compared by the conditional operator against the current value of the property
  10626. * @param operator the conditional operator, default ValueCondition.IsEqual
  10627. */
  10628. constructor(actionManager: ActionManager, target: any,
  10629. /** path to specify the property of the target the conditional operator uses */
  10630. propertyPath: string,
  10631. /** the value compared by the conditional operator against the current value of the property */
  10632. value: any,
  10633. /** the conditional operator, default ValueCondition.IsEqual */
  10634. operator?: number);
  10635. /**
  10636. * Compares the given value with the property value for the specified conditional operator
  10637. * @returns the result of the comparison
  10638. */
  10639. isValid(): boolean;
  10640. /**
  10641. * Serialize the ValueCondition into a JSON compatible object
  10642. * @returns serialization object
  10643. */
  10644. serialize(): any;
  10645. /**
  10646. * Gets the name of the conditional operator for the ValueCondition
  10647. * @param operator the conditional operator
  10648. * @returns the name
  10649. */
  10650. static GetOperatorName(operator: number): string;
  10651. }
  10652. /**
  10653. * Defines a predicate condition as an extension of Condition
  10654. */
  10655. export class PredicateCondition extends Condition {
  10656. /** defines the predicate function used to validate the condition */
  10657. predicate: () => boolean;
  10658. /**
  10659. * Internal only - manager for action
  10660. * @hidden
  10661. */
  10662. _actionManager: ActionManager;
  10663. /**
  10664. * Creates a new PredicateCondition
  10665. * @param actionManager manager for the action the condition applies to
  10666. * @param predicate defines the predicate function used to validate the condition
  10667. */
  10668. constructor(actionManager: ActionManager,
  10669. /** defines the predicate function used to validate the condition */
  10670. predicate: () => boolean);
  10671. /**
  10672. * @returns the validity of the predicate condition
  10673. */
  10674. isValid(): boolean;
  10675. }
  10676. /**
  10677. * Defines a state condition as an extension of Condition
  10678. */
  10679. export class StateCondition extends Condition {
  10680. /** Value to compare with target state */
  10681. value: string;
  10682. /**
  10683. * Internal only - manager for action
  10684. * @hidden
  10685. */
  10686. _actionManager: ActionManager;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. private _target;
  10692. /**
  10693. * Creates a new StateCondition
  10694. * @param actionManager manager for the action the condition applies to
  10695. * @param target of the condition
  10696. * @param value to compare with target state
  10697. */
  10698. constructor(actionManager: ActionManager, target: any,
  10699. /** Value to compare with target state */
  10700. value: string);
  10701. /**
  10702. * Gets a boolean indicating if the current condition is met
  10703. * @returns the validity of the state
  10704. */
  10705. isValid(): boolean;
  10706. /**
  10707. * Serialize the StateCondition into a JSON compatible object
  10708. * @returns serialization object
  10709. */
  10710. serialize(): any;
  10711. }
  10712. }
  10713. declare module BABYLON {
  10714. /**
  10715. * This defines an action responsible to toggle a boolean once triggered.
  10716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10717. */
  10718. export class SwitchBooleanAction extends Action {
  10719. /**
  10720. * The path to the boolean property in the target object
  10721. */
  10722. propertyPath: string;
  10723. private _target;
  10724. private _effectiveTarget;
  10725. private _property;
  10726. /**
  10727. * Instantiate the action
  10728. * @param triggerOptions defines the trigger options
  10729. * @param target defines the object containing the boolean
  10730. * @param propertyPath defines the path to the boolean property in the target object
  10731. * @param condition defines the trigger related conditions
  10732. */
  10733. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10734. /** @hidden */
  10735. _prepare(): void;
  10736. /**
  10737. * Execute the action toggle the boolean value.
  10738. */
  10739. execute(): void;
  10740. /**
  10741. * Serializes the actions and its related information.
  10742. * @param parent defines the object to serialize in
  10743. * @returns the serialized object
  10744. */
  10745. serialize(parent: any): any;
  10746. }
  10747. /**
  10748. * This defines an action responsible to set a the state field of the target
  10749. * to a desired value once triggered.
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10751. */
  10752. export class SetStateAction extends Action {
  10753. /**
  10754. * The value to store in the state field.
  10755. */
  10756. value: string;
  10757. private _target;
  10758. /**
  10759. * Instantiate the action
  10760. * @param triggerOptions defines the trigger options
  10761. * @param target defines the object containing the state property
  10762. * @param value defines the value to store in the state field
  10763. * @param condition defines the trigger related conditions
  10764. */
  10765. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10766. /**
  10767. * Execute the action and store the value on the target state property.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set a property of the target
  10779. * to a desired value once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class SetValueAction extends Action {
  10783. /**
  10784. * The path of the property to set in the target.
  10785. */
  10786. propertyPath: string;
  10787. /**
  10788. * The value to set in the property
  10789. */
  10790. value: any;
  10791. private _target;
  10792. private _effectiveTarget;
  10793. private _property;
  10794. /**
  10795. * Instantiate the action
  10796. * @param triggerOptions defines the trigger options
  10797. * @param target defines the object containing the property
  10798. * @param propertyPath defines the path of the property to set in the target
  10799. * @param value defines the value to set in the property
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10803. /** @hidden */
  10804. _prepare(): void;
  10805. /**
  10806. * Execute the action and set the targetted property to the desired value.
  10807. */
  10808. execute(): void;
  10809. /**
  10810. * Serializes the actions and its related information.
  10811. * @param parent defines the object to serialize in
  10812. * @returns the serialized object
  10813. */
  10814. serialize(parent: any): any;
  10815. }
  10816. /**
  10817. * This defines an action responsible to increment the target value
  10818. * to a desired value once triggered.
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10820. */
  10821. export class IncrementValueAction extends Action {
  10822. /**
  10823. * The path of the property to increment in the target.
  10824. */
  10825. propertyPath: string;
  10826. /**
  10827. * The value we should increment the property by.
  10828. */
  10829. value: any;
  10830. private _target;
  10831. private _effectiveTarget;
  10832. private _property;
  10833. /**
  10834. * Instantiate the action
  10835. * @param triggerOptions defines the trigger options
  10836. * @param target defines the object containing the property
  10837. * @param propertyPath defines the path of the property to increment in the target
  10838. * @param value defines the value value we should increment the property by
  10839. * @param condition defines the trigger related conditions
  10840. */
  10841. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10842. /** @hidden */
  10843. _prepare(): void;
  10844. /**
  10845. * Execute the action and increment the target of the value amount.
  10846. */
  10847. execute(): void;
  10848. /**
  10849. * Serializes the actions and its related information.
  10850. * @param parent defines the object to serialize in
  10851. * @returns the serialized object
  10852. */
  10853. serialize(parent: any): any;
  10854. }
  10855. /**
  10856. * This defines an action responsible to start an animation once triggered.
  10857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10858. */
  10859. export class PlayAnimationAction extends Action {
  10860. /**
  10861. * Where the animation should start (animation frame)
  10862. */
  10863. from: number;
  10864. /**
  10865. * Where the animation should stop (animation frame)
  10866. */
  10867. to: number;
  10868. /**
  10869. * Define if the animation should loop or stop after the first play.
  10870. */
  10871. loop?: boolean;
  10872. private _target;
  10873. /**
  10874. * Instantiate the action
  10875. * @param triggerOptions defines the trigger options
  10876. * @param target defines the target animation or animation name
  10877. * @param from defines from where the animation should start (animation frame)
  10878. * @param end defines where the animation should stop (animation frame)
  10879. * @param loop defines if the animation should loop or stop after the first play
  10880. * @param condition defines the trigger related conditions
  10881. */
  10882. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10883. /** @hidden */
  10884. _prepare(): void;
  10885. /**
  10886. * Execute the action and play the animation.
  10887. */
  10888. execute(): void;
  10889. /**
  10890. * Serializes the actions and its related information.
  10891. * @param parent defines the object to serialize in
  10892. * @returns the serialized object
  10893. */
  10894. serialize(parent: any): any;
  10895. }
  10896. /**
  10897. * This defines an action responsible to stop an animation once triggered.
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10899. */
  10900. export class StopAnimationAction extends Action {
  10901. private _target;
  10902. /**
  10903. * Instantiate the action
  10904. * @param triggerOptions defines the trigger options
  10905. * @param target defines the target animation or animation name
  10906. * @param condition defines the trigger related conditions
  10907. */
  10908. constructor(triggerOptions: any, target: any, condition?: Condition);
  10909. /** @hidden */
  10910. _prepare(): void;
  10911. /**
  10912. * Execute the action and stop the animation.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible that does nothing once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class DoNothingAction extends Action {
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param condition defines the trigger related conditions
  10931. */
  10932. constructor(triggerOptions?: any, condition?: Condition);
  10933. /**
  10934. * Execute the action and do nothing.
  10935. */
  10936. execute(): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. /**
  10945. * This defines an action responsible to trigger several actions once triggered.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class CombineAction extends Action {
  10949. /**
  10950. * The list of aggregated animations to run.
  10951. */
  10952. children: Action[];
  10953. /**
  10954. * Instantiate the action
  10955. * @param triggerOptions defines the trigger options
  10956. * @param children defines the list of aggregated animations to run
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10960. /** @hidden */
  10961. _prepare(): void;
  10962. /**
  10963. * Execute the action and executes all the aggregated actions.
  10964. */
  10965. execute(evt: ActionEvent): void;
  10966. /**
  10967. * Serializes the actions and its related information.
  10968. * @param parent defines the object to serialize in
  10969. * @returns the serialized object
  10970. */
  10971. serialize(parent: any): any;
  10972. }
  10973. /**
  10974. * This defines an action responsible to run code (external event) once triggered.
  10975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10976. */
  10977. export class ExecuteCodeAction extends Action {
  10978. /**
  10979. * The callback function to run.
  10980. */
  10981. func: (evt: ActionEvent) => void;
  10982. /**
  10983. * Instantiate the action
  10984. * @param triggerOptions defines the trigger options
  10985. * @param func defines the callback function to run
  10986. * @param condition defines the trigger related conditions
  10987. */
  10988. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10989. /**
  10990. * Execute the action and run the attached code.
  10991. */
  10992. execute(evt: ActionEvent): void;
  10993. }
  10994. /**
  10995. * This defines an action responsible to set the parent property of the target once triggered.
  10996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10997. */
  10998. export class SetParentAction extends Action {
  10999. private _parent;
  11000. private _target;
  11001. /**
  11002. * Instantiate the action
  11003. * @param triggerOptions defines the trigger options
  11004. * @param target defines the target containing the parent property
  11005. * @param parent defines from where the animation should start (animation frame)
  11006. * @param condition defines the trigger related conditions
  11007. */
  11008. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11009. /** @hidden */
  11010. _prepare(): void;
  11011. /**
  11012. * Execute the action and set the parent property.
  11013. */
  11014. execute(): void;
  11015. /**
  11016. * Serializes the actions and its related information.
  11017. * @param parent defines the object to serialize in
  11018. * @returns the serialized object
  11019. */
  11020. serialize(parent: any): any;
  11021. }
  11022. }
  11023. declare module BABYLON {
  11024. /**
  11025. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11026. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11028. */
  11029. export class ActionManager extends AbstractActionManager {
  11030. /**
  11031. * Nothing
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly NothingTrigger: number;
  11035. /**
  11036. * On pick
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnPickTrigger: number;
  11040. /**
  11041. * On left pick
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnLeftPickTrigger: number;
  11045. /**
  11046. * On right pick
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnRightPickTrigger: number;
  11050. /**
  11051. * On center pick
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnCenterPickTrigger: number;
  11055. /**
  11056. * On pick down
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickDownTrigger: number;
  11060. /**
  11061. * On double pick
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnDoublePickTrigger: number;
  11065. /**
  11066. * On pick up
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPickUpTrigger: number;
  11070. /**
  11071. * On pick out.
  11072. * This trigger will only be raised if you also declared a OnPickDown
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickOutTrigger: number;
  11076. /**
  11077. * On long press
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnLongPressTrigger: number;
  11081. /**
  11082. * On pointer over
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPointerOverTrigger: number;
  11086. /**
  11087. * On pointer out
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPointerOutTrigger: number;
  11091. /**
  11092. * On every frame
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnEveryFrameTrigger: number;
  11096. /**
  11097. * On intersection enter
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnIntersectionEnterTrigger: number;
  11101. /**
  11102. * On intersection exit
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnIntersectionExitTrigger: number;
  11106. /**
  11107. * On key down
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnKeyDownTrigger: number;
  11111. /**
  11112. * On key up
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnKeyUpTrigger: number;
  11116. private _scene;
  11117. /**
  11118. * Creates a new action manager
  11119. * @param scene defines the hosting scene
  11120. */
  11121. constructor(scene: Scene);
  11122. /**
  11123. * Releases all associated resources
  11124. */
  11125. dispose(): void;
  11126. /**
  11127. * Gets hosting scene
  11128. * @returns the hosting scene
  11129. */
  11130. getScene(): Scene;
  11131. /**
  11132. * Does this action manager handles actions of any of the given triggers
  11133. * @param triggers defines the triggers to be tested
  11134. * @return a boolean indicating whether one (or more) of the triggers is handled
  11135. */
  11136. hasSpecificTriggers(triggers: number[]): boolean;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11139. * speed.
  11140. * @param triggerA defines the trigger to be tested
  11141. * @param triggerB defines the trigger to be tested
  11142. * @return a boolean indicating whether one (or more) of the triggers is handled
  11143. */
  11144. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11145. /**
  11146. * Does this action manager handles actions of a given trigger
  11147. * @param trigger defines the trigger to be tested
  11148. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11149. * @return whether the trigger is handled
  11150. */
  11151. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11152. /**
  11153. * Does this action manager has pointer triggers
  11154. */
  11155. readonly hasPointerTriggers: boolean;
  11156. /**
  11157. * Does this action manager has pick triggers
  11158. */
  11159. readonly hasPickTriggers: boolean;
  11160. /**
  11161. * Registers an action to this action manager
  11162. * @param action defines the action to be registered
  11163. * @return the action amended (prepared) after registration
  11164. */
  11165. registerAction(action: IAction): Nullable<IAction>;
  11166. /**
  11167. * Unregisters an action to this action manager
  11168. * @param action defines the action to be unregistered
  11169. * @return a boolean indicating whether the action has been unregistered
  11170. */
  11171. unregisterAction(action: IAction): Boolean;
  11172. /**
  11173. * Process a specific trigger
  11174. * @param trigger defines the trigger to process
  11175. * @param evt defines the event details to be processed
  11176. */
  11177. processTrigger(trigger: number, evt?: IActionEvent): void;
  11178. /** @hidden */
  11179. _getEffectiveTarget(target: any, propertyPath: string): any;
  11180. /** @hidden */
  11181. _getProperty(propertyPath: string): string;
  11182. /**
  11183. * Serialize this manager to a JSON object
  11184. * @param name defines the property name to store this manager
  11185. * @returns a JSON representation of this manager
  11186. */
  11187. serialize(name: string): any;
  11188. /**
  11189. * Creates a new ActionManager from a JSON data
  11190. * @param parsedActions defines the JSON data to read from
  11191. * @param object defines the hosting mesh
  11192. * @param scene defines the hosting scene
  11193. */
  11194. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11195. /**
  11196. * Get a trigger name by index
  11197. * @param trigger defines the trigger index
  11198. * @returns a trigger name
  11199. */
  11200. static GetTriggerName(trigger: number): string;
  11201. }
  11202. }
  11203. declare module BABYLON {
  11204. /**
  11205. * Class representing a ray with position and direction
  11206. */
  11207. export class Ray {
  11208. /** origin point */
  11209. origin: Vector3;
  11210. /** direction */
  11211. direction: Vector3;
  11212. /** length of the ray */
  11213. length: number;
  11214. private static readonly TmpVector3;
  11215. private _tmpRay;
  11216. /**
  11217. * Creates a new ray
  11218. * @param origin origin point
  11219. * @param direction direction
  11220. * @param length length of the ray
  11221. */
  11222. constructor(
  11223. /** origin point */
  11224. origin: Vector3,
  11225. /** direction */
  11226. direction: Vector3,
  11227. /** length of the ray */
  11228. length?: number);
  11229. /**
  11230. * Checks if the ray intersects a box
  11231. * @param minimum bound of the box
  11232. * @param maximum bound of the box
  11233. * @param intersectionTreshold extra extend to be added to the box in all direction
  11234. * @returns if the box was hit
  11235. */
  11236. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11237. /**
  11238. * Checks if the ray intersects a box
  11239. * @param box the bounding box to check
  11240. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11241. * @returns if the box was hit
  11242. */
  11243. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11244. /**
  11245. * If the ray hits a sphere
  11246. * @param sphere the bounding sphere to check
  11247. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11248. * @returns true if it hits the sphere
  11249. */
  11250. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11251. /**
  11252. * If the ray hits a triange
  11253. * @param vertex0 triangle vertex
  11254. * @param vertex1 triangle vertex
  11255. * @param vertex2 triangle vertex
  11256. * @returns intersection information if hit
  11257. */
  11258. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11259. /**
  11260. * Checks if ray intersects a plane
  11261. * @param plane the plane to check
  11262. * @returns the distance away it was hit
  11263. */
  11264. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11265. /**
  11266. * Checks if ray intersects a mesh
  11267. * @param mesh the mesh to check
  11268. * @param fastCheck if only the bounding box should checked
  11269. * @returns picking info of the intersecton
  11270. */
  11271. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11272. /**
  11273. * Checks if ray intersects a mesh
  11274. * @param meshes the meshes to check
  11275. * @param fastCheck if only the bounding box should checked
  11276. * @param results array to store result in
  11277. * @returns Array of picking infos
  11278. */
  11279. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11280. private _comparePickingInfo;
  11281. private static smallnum;
  11282. private static rayl;
  11283. /**
  11284. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11285. * @param sega the first point of the segment to test the intersection against
  11286. * @param segb the second point of the segment to test the intersection against
  11287. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11288. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11289. */
  11290. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11291. /**
  11292. * Update the ray from viewport position
  11293. * @param x position
  11294. * @param y y position
  11295. * @param viewportWidth viewport width
  11296. * @param viewportHeight viewport height
  11297. * @param world world matrix
  11298. * @param view view matrix
  11299. * @param projection projection matrix
  11300. * @returns this ray updated
  11301. */
  11302. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11303. /**
  11304. * Creates a ray with origin and direction of 0,0,0
  11305. * @returns the new ray
  11306. */
  11307. static Zero(): Ray;
  11308. /**
  11309. * Creates a new ray from screen space and viewport
  11310. * @param x position
  11311. * @param y y position
  11312. * @param viewportWidth viewport width
  11313. * @param viewportHeight viewport height
  11314. * @param world world matrix
  11315. * @param view view matrix
  11316. * @param projection projection matrix
  11317. * @returns new ray
  11318. */
  11319. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11320. /**
  11321. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11322. * transformed to the given world matrix.
  11323. * @param origin The origin point
  11324. * @param end The end point
  11325. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11326. * @returns the new ray
  11327. */
  11328. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11329. /**
  11330. * Transforms a ray by a matrix
  11331. * @param ray ray to transform
  11332. * @param matrix matrix to apply
  11333. * @returns the resulting new ray
  11334. */
  11335. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11336. /**
  11337. * Transforms a ray by a matrix
  11338. * @param ray ray to transform
  11339. * @param matrix matrix to apply
  11340. * @param result ray to store result in
  11341. */
  11342. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11343. /**
  11344. * Unproject a ray from screen space to object space
  11345. * @param sourceX defines the screen space x coordinate to use
  11346. * @param sourceY defines the screen space y coordinate to use
  11347. * @param viewportWidth defines the current width of the viewport
  11348. * @param viewportHeight defines the current height of the viewport
  11349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11350. * @param view defines the view matrix to use
  11351. * @param projection defines the projection matrix to use
  11352. */
  11353. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11354. }
  11355. /**
  11356. * Type used to define predicate used to select faces when a mesh intersection is detected
  11357. */
  11358. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. declare module BABYLON {
  11373. /**
  11374. * Groups all the scene component constants in one place to ease maintenance.
  11375. * @hidden
  11376. */
  11377. export class SceneComponentConstants {
  11378. static readonly NAME_EFFECTLAYER: string;
  11379. static readonly NAME_LAYER: string;
  11380. static readonly NAME_LENSFLARESYSTEM: string;
  11381. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11382. static readonly NAME_PARTICLESYSTEM: string;
  11383. static readonly NAME_GAMEPAD: string;
  11384. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11385. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11386. static readonly NAME_DEPTHRENDERER: string;
  11387. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11388. static readonly NAME_SPRITE: string;
  11389. static readonly NAME_OUTLINERENDERER: string;
  11390. static readonly NAME_PROCEDURALTEXTURE: string;
  11391. static readonly NAME_SHADOWGENERATOR: string;
  11392. static readonly NAME_OCTREE: string;
  11393. static readonly NAME_PHYSICSENGINE: string;
  11394. static readonly NAME_AUDIO: string;
  11395. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11396. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11397. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11398. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11400. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11401. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11402. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11403. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11404. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11405. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11406. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11407. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11408. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11409. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11410. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11411. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11412. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11414. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11415. static readonly STEP_AFTERRENDER_AUDIO: number;
  11416. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11417. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11420. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11421. static readonly STEP_POINTERMOVE_SPRITE: number;
  11422. static readonly STEP_POINTERDOWN_SPRITE: number;
  11423. static readonly STEP_POINTERUP_SPRITE: number;
  11424. }
  11425. /**
  11426. * This represents a scene component.
  11427. *
  11428. * This is used to decouple the dependency the scene is having on the different workloads like
  11429. * layers, post processes...
  11430. */
  11431. export interface ISceneComponent {
  11432. /**
  11433. * The name of the component. Each component must have a unique name.
  11434. */
  11435. name: string;
  11436. /**
  11437. * The scene the component belongs to.
  11438. */
  11439. scene: Scene;
  11440. /**
  11441. * Register the component to one instance of a scene.
  11442. */
  11443. register(): void;
  11444. /**
  11445. * Rebuilds the elements related to this component in case of
  11446. * context lost for instance.
  11447. */
  11448. rebuild(): void;
  11449. /**
  11450. * Disposes the component and the associated ressources.
  11451. */
  11452. dispose(): void;
  11453. }
  11454. /**
  11455. * This represents a SERIALIZABLE scene component.
  11456. *
  11457. * This extends Scene Component to add Serialization methods on top.
  11458. */
  11459. export interface ISceneSerializableComponent extends ISceneComponent {
  11460. /**
  11461. * Adds all the element from the container to the scene
  11462. * @param container the container holding the elements
  11463. */
  11464. addFromContainer(container: AbstractScene): void;
  11465. /**
  11466. * Removes all the elements in the container from the scene
  11467. * @param container contains the elements to remove
  11468. * @param dispose if the removed element should be disposed (default: false)
  11469. */
  11470. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11471. /**
  11472. * Serializes the component data to the specified json object
  11473. * @param serializationObject The object to serialize to
  11474. */
  11475. serialize(serializationObject: any): void;
  11476. }
  11477. /**
  11478. * Strong typing of a Mesh related stage step action
  11479. */
  11480. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11481. /**
  11482. * Strong typing of a Evaluate Sub Mesh related stage step action
  11483. */
  11484. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11485. /**
  11486. * Strong typing of a Active Mesh related stage step action
  11487. */
  11488. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11489. /**
  11490. * Strong typing of a Camera related stage step action
  11491. */
  11492. export type CameraStageAction = (camera: Camera) => void;
  11493. /**
  11494. * Strong typing of a Camera Frame buffer related stage step action
  11495. */
  11496. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11497. /**
  11498. * Strong typing of a Render Target related stage step action
  11499. */
  11500. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11501. /**
  11502. * Strong typing of a RenderingGroup related stage step action
  11503. */
  11504. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11505. /**
  11506. * Strong typing of a Mesh Render related stage step action
  11507. */
  11508. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11509. /**
  11510. * Strong typing of a simple stage step action
  11511. */
  11512. export type SimpleStageAction = () => void;
  11513. /**
  11514. * Strong typing of a render target action.
  11515. */
  11516. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11517. /**
  11518. * Strong typing of a pointer move action.
  11519. */
  11520. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11521. /**
  11522. * Strong typing of a pointer up/down action.
  11523. */
  11524. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11525. /**
  11526. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11527. * @hidden
  11528. */
  11529. export class Stage<T extends Function> extends Array<{
  11530. index: number;
  11531. component: ISceneComponent;
  11532. action: T;
  11533. }> {
  11534. /**
  11535. * Hide ctor from the rest of the world.
  11536. * @param items The items to add.
  11537. */
  11538. private constructor();
  11539. /**
  11540. * Creates a new Stage.
  11541. * @returns A new instance of a Stage
  11542. */
  11543. static Create<T extends Function>(): Stage<T>;
  11544. /**
  11545. * Registers a step in an ordered way in the targeted stage.
  11546. * @param index Defines the position to register the step in
  11547. * @param component Defines the component attached to the step
  11548. * @param action Defines the action to launch during the step
  11549. */
  11550. registerStep(index: number, component: ISceneComponent, action: T): void;
  11551. /**
  11552. * Clears all the steps from the stage.
  11553. */
  11554. clear(): void;
  11555. }
  11556. }
  11557. declare module BABYLON {
  11558. interface Scene {
  11559. /** @hidden */
  11560. _pointerOverSprite: Nullable<Sprite>;
  11561. /** @hidden */
  11562. _pickedDownSprite: Nullable<Sprite>;
  11563. /** @hidden */
  11564. _tempSpritePickingRay: Nullable<Ray>;
  11565. /**
  11566. * All of the sprite managers added to this scene
  11567. * @see http://doc.babylonjs.com/babylon101/sprites
  11568. */
  11569. spriteManagers: Array<ISpriteManager>;
  11570. /**
  11571. * An event triggered when sprites rendering is about to start
  11572. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11573. */
  11574. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11575. /**
  11576. * An event triggered when sprites rendering is done
  11577. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11578. */
  11579. onAfterSpritesRenderingObservable: Observable<Scene>;
  11580. /** @hidden */
  11581. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11582. /** Launch a ray to try to pick a sprite in the scene
  11583. * @param x position on screen
  11584. * @param y position on screen
  11585. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11586. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11587. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11588. * @returns a PickingInfo
  11589. */
  11590. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11591. /** Use the given ray to pick a sprite in the scene
  11592. * @param ray The ray (in world space) to use to pick meshes
  11593. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11594. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11595. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11596. * @returns a PickingInfo
  11597. */
  11598. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11599. /**
  11600. * Force the sprite under the pointer
  11601. * @param sprite defines the sprite to use
  11602. */
  11603. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11604. /**
  11605. * Gets the sprite under the pointer
  11606. * @returns a Sprite or null if no sprite is under the pointer
  11607. */
  11608. getPointerOverSprite(): Nullable<Sprite>;
  11609. }
  11610. /**
  11611. * Defines the sprite scene component responsible to manage sprites
  11612. * in a given scene.
  11613. */
  11614. export class SpriteSceneComponent implements ISceneComponent {
  11615. /**
  11616. * The component name helpfull to identify the component in the list of scene components.
  11617. */
  11618. readonly name: string;
  11619. /**
  11620. * The scene the component belongs to.
  11621. */
  11622. scene: Scene;
  11623. /** @hidden */
  11624. private _spritePredicate;
  11625. /**
  11626. * Creates a new instance of the component for the given scene
  11627. * @param scene Defines the scene to register the component in
  11628. */
  11629. constructor(scene: Scene);
  11630. /**
  11631. * Registers the component in a given scene
  11632. */
  11633. register(): void;
  11634. /**
  11635. * Rebuilds the elements related to this component in case of
  11636. * context lost for instance.
  11637. */
  11638. rebuild(): void;
  11639. /**
  11640. * Disposes the component and the associated ressources.
  11641. */
  11642. dispose(): void;
  11643. private _pickSpriteButKeepRay;
  11644. private _pointerMove;
  11645. private _pointerDown;
  11646. private _pointerUp;
  11647. }
  11648. }
  11649. declare module BABYLON {
  11650. /** @hidden */
  11651. export var fogFragmentDeclaration: {
  11652. name: string;
  11653. shader: string;
  11654. };
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var fogFragment: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /** @hidden */
  11665. export var spritesPixelShader: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module BABYLON {
  11671. /** @hidden */
  11672. export var fogVertexDeclaration: {
  11673. name: string;
  11674. shader: string;
  11675. };
  11676. }
  11677. declare module BABYLON {
  11678. /** @hidden */
  11679. export var spritesVertexShader: {
  11680. name: string;
  11681. shader: string;
  11682. };
  11683. }
  11684. declare module BABYLON {
  11685. /**
  11686. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11687. */
  11688. export interface ISpriteManager extends IDisposable {
  11689. /**
  11690. * Restricts the camera to viewing objects with the same layerMask.
  11691. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11692. */
  11693. layerMask: number;
  11694. /**
  11695. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11696. */
  11697. isPickable: boolean;
  11698. /**
  11699. * Specifies the rendering group id for this mesh (0 by default)
  11700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11701. */
  11702. renderingGroupId: number;
  11703. /**
  11704. * Defines the list of sprites managed by the manager.
  11705. */
  11706. sprites: Array<Sprite>;
  11707. /**
  11708. * Tests the intersection of a sprite with a specific ray.
  11709. * @param ray The ray we are sending to test the collision
  11710. * @param camera The camera space we are sending rays in
  11711. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11712. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11713. * @returns picking info or null.
  11714. */
  11715. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11716. /**
  11717. * Renders the list of sprites on screen.
  11718. */
  11719. render(): void;
  11720. }
  11721. /**
  11722. * Class used to manage multiple sprites on the same spritesheet
  11723. * @see http://doc.babylonjs.com/babylon101/sprites
  11724. */
  11725. export class SpriteManager implements ISpriteManager {
  11726. /** defines the manager's name */
  11727. name: string;
  11728. /** Gets the list of sprites */
  11729. sprites: Sprite[];
  11730. /** Gets or sets the rendering group id (0 by default) */
  11731. renderingGroupId: number;
  11732. /** Gets or sets camera layer mask */
  11733. layerMask: number;
  11734. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11735. fogEnabled: boolean;
  11736. /** Gets or sets a boolean indicating if the sprites are pickable */
  11737. isPickable: boolean;
  11738. /** Defines the default width of a cell in the spritesheet */
  11739. cellWidth: number;
  11740. /** Defines the default height of a cell in the spritesheet */
  11741. cellHeight: number;
  11742. /**
  11743. * An event triggered when the manager is disposed.
  11744. */
  11745. onDisposeObservable: Observable<SpriteManager>;
  11746. private _onDisposeObserver;
  11747. /**
  11748. * Callback called when the manager is disposed
  11749. */
  11750. onDispose: () => void;
  11751. private _capacity;
  11752. private _spriteTexture;
  11753. private _epsilon;
  11754. private _scene;
  11755. private _vertexData;
  11756. private _buffer;
  11757. private _vertexBuffers;
  11758. private _indexBuffer;
  11759. private _effectBase;
  11760. private _effectFog;
  11761. /**
  11762. * Gets or sets the spritesheet texture
  11763. */
  11764. texture: Texture;
  11765. /**
  11766. * Creates a new sprite manager
  11767. * @param name defines the manager's name
  11768. * @param imgUrl defines the sprite sheet url
  11769. * @param capacity defines the maximum allowed number of sprites
  11770. * @param cellSize defines the size of a sprite cell
  11771. * @param scene defines the hosting scene
  11772. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11773. * @param samplingMode defines the smapling mode to use with spritesheet
  11774. */
  11775. constructor(
  11776. /** defines the manager's name */
  11777. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11778. private _appendSpriteVertex;
  11779. /**
  11780. * Intersects the sprites with a ray
  11781. * @param ray defines the ray to intersect with
  11782. * @param camera defines the current active camera
  11783. * @param predicate defines a predicate used to select candidate sprites
  11784. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11785. * @returns null if no hit or a PickingInfo
  11786. */
  11787. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11788. /**
  11789. * Render all child sprites
  11790. */
  11791. render(): void;
  11792. /**
  11793. * Release associated resources
  11794. */
  11795. dispose(): void;
  11796. }
  11797. }
  11798. declare module BABYLON {
  11799. /**
  11800. * Class used to represent a sprite
  11801. * @see http://doc.babylonjs.com/babylon101/sprites
  11802. */
  11803. export class Sprite {
  11804. /** defines the name */
  11805. name: string;
  11806. /** Gets or sets the current world position */
  11807. position: Vector3;
  11808. /** Gets or sets the main color */
  11809. color: Color4;
  11810. /** Gets or sets the width */
  11811. width: number;
  11812. /** Gets or sets the height */
  11813. height: number;
  11814. /** Gets or sets rotation angle */
  11815. angle: number;
  11816. /** Gets or sets the cell index in the sprite sheet */
  11817. cellIndex: number;
  11818. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11819. invertU: number;
  11820. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11821. invertV: number;
  11822. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11823. disposeWhenFinishedAnimating: boolean;
  11824. /** Gets the list of attached animations */
  11825. animations: Animation[];
  11826. /** Gets or sets a boolean indicating if the sprite can be picked */
  11827. isPickable: boolean;
  11828. /**
  11829. * Gets or sets the associated action manager
  11830. */
  11831. actionManager: Nullable<ActionManager>;
  11832. private _animationStarted;
  11833. private _loopAnimation;
  11834. private _fromIndex;
  11835. private _toIndex;
  11836. private _delay;
  11837. private _direction;
  11838. private _manager;
  11839. private _time;
  11840. private _onAnimationEnd;
  11841. /**
  11842. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11843. */
  11844. isVisible: boolean;
  11845. /**
  11846. * Gets or sets the sprite size
  11847. */
  11848. size: number;
  11849. /**
  11850. * Creates a new Sprite
  11851. * @param name defines the name
  11852. * @param manager defines the manager
  11853. */
  11854. constructor(
  11855. /** defines the name */
  11856. name: string, manager: ISpriteManager);
  11857. /**
  11858. * Starts an animation
  11859. * @param from defines the initial key
  11860. * @param to defines the end key
  11861. * @param loop defines if the animation must loop
  11862. * @param delay defines the start delay (in ms)
  11863. * @param onAnimationEnd defines a callback to call when animation ends
  11864. */
  11865. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11866. /** Stops current animation (if any) */
  11867. stopAnimation(): void;
  11868. /** @hidden */
  11869. _animate(deltaTime: number): void;
  11870. /** Release associated resources */
  11871. dispose(): void;
  11872. }
  11873. }
  11874. declare module BABYLON {
  11875. /**
  11876. * Information about the result of picking within a scene
  11877. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11878. */
  11879. export class PickingInfo {
  11880. /** @hidden */
  11881. _pickingUnavailable: boolean;
  11882. /**
  11883. * If the pick collided with an object
  11884. */
  11885. hit: boolean;
  11886. /**
  11887. * Distance away where the pick collided
  11888. */
  11889. distance: number;
  11890. /**
  11891. * The location of pick collision
  11892. */
  11893. pickedPoint: Nullable<Vector3>;
  11894. /**
  11895. * The mesh corresponding the the pick collision
  11896. */
  11897. pickedMesh: Nullable<AbstractMesh>;
  11898. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11899. bu: number;
  11900. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11901. bv: number;
  11902. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11903. faceId: number;
  11904. /** Id of the the submesh that was picked */
  11905. subMeshId: number;
  11906. /** If a sprite was picked, this will be the sprite the pick collided with */
  11907. pickedSprite: Nullable<Sprite>;
  11908. /**
  11909. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11910. */
  11911. originMesh: Nullable<AbstractMesh>;
  11912. /**
  11913. * The ray that was used to perform the picking.
  11914. */
  11915. ray: Nullable<Ray>;
  11916. /**
  11917. * Gets the normal correspodning to the face the pick collided with
  11918. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11919. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11920. * @returns The normal correspodning to the face the pick collided with
  11921. */
  11922. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11923. /**
  11924. * Gets the texture coordinates of where the pick occured
  11925. * @returns the vector containing the coordnates of the texture
  11926. */
  11927. getTextureCoordinates(): Nullable<Vector2>;
  11928. }
  11929. }
  11930. declare module BABYLON {
  11931. /**
  11932. * Gather the list of pointer event types as constants.
  11933. */
  11934. export class PointerEventTypes {
  11935. /**
  11936. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11937. */
  11938. static readonly POINTERDOWN: number;
  11939. /**
  11940. * The pointerup event is fired when a pointer is no longer active.
  11941. */
  11942. static readonly POINTERUP: number;
  11943. /**
  11944. * The pointermove event is fired when a pointer changes coordinates.
  11945. */
  11946. static readonly POINTERMOVE: number;
  11947. /**
  11948. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11949. */
  11950. static readonly POINTERWHEEL: number;
  11951. /**
  11952. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11953. */
  11954. static readonly POINTERPICK: number;
  11955. /**
  11956. * The pointertap event is fired when a the object has been touched and released without drag.
  11957. */
  11958. static readonly POINTERTAP: number;
  11959. /**
  11960. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11961. */
  11962. static readonly POINTERDOUBLETAP: number;
  11963. }
  11964. /**
  11965. * Base class of pointer info types.
  11966. */
  11967. export class PointerInfoBase {
  11968. /**
  11969. * Defines the type of event (PointerEventTypes)
  11970. */
  11971. type: number;
  11972. /**
  11973. * Defines the related dom event
  11974. */
  11975. event: PointerEvent | MouseWheelEvent;
  11976. /**
  11977. * Instantiates the base class of pointers info.
  11978. * @param type Defines the type of event (PointerEventTypes)
  11979. * @param event Defines the related dom event
  11980. */
  11981. constructor(
  11982. /**
  11983. * Defines the type of event (PointerEventTypes)
  11984. */
  11985. type: number,
  11986. /**
  11987. * Defines the related dom event
  11988. */
  11989. event: PointerEvent | MouseWheelEvent);
  11990. }
  11991. /**
  11992. * This class is used to store pointer related info for the onPrePointerObservable event.
  11993. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11994. */
  11995. export class PointerInfoPre extends PointerInfoBase {
  11996. /**
  11997. * Ray from a pointer if availible (eg. 6dof controller)
  11998. */
  11999. ray: Nullable<Ray>;
  12000. /**
  12001. * Defines the local position of the pointer on the canvas.
  12002. */
  12003. localPosition: Vector2;
  12004. /**
  12005. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12006. */
  12007. skipOnPointerObservable: boolean;
  12008. /**
  12009. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12010. * @param type Defines the type of event (PointerEventTypes)
  12011. * @param event Defines the related dom event
  12012. * @param localX Defines the local x coordinates of the pointer when the event occured
  12013. * @param localY Defines the local y coordinates of the pointer when the event occured
  12014. */
  12015. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12016. }
  12017. /**
  12018. * This type contains all the data related to a pointer event in Babylon.js.
  12019. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12020. */
  12021. export class PointerInfo extends PointerInfoBase {
  12022. /**
  12023. * Defines the picking info associated to the info (if any)\
  12024. */
  12025. pickInfo: Nullable<PickingInfo>;
  12026. /**
  12027. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12028. * @param type Defines the type of event (PointerEventTypes)
  12029. * @param event Defines the related dom event
  12030. * @param pickInfo Defines the picking info associated to the info (if any)\
  12031. */
  12032. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12033. /**
  12034. * Defines the picking info associated to the info (if any)\
  12035. */
  12036. pickInfo: Nullable<PickingInfo>);
  12037. }
  12038. /**
  12039. * Data relating to a touch event on the screen.
  12040. */
  12041. export interface PointerTouch {
  12042. /**
  12043. * X coordinate of touch.
  12044. */
  12045. x: number;
  12046. /**
  12047. * Y coordinate of touch.
  12048. */
  12049. y: number;
  12050. /**
  12051. * Id of touch. Unique for each finger.
  12052. */
  12053. pointerId: number;
  12054. /**
  12055. * Event type passed from DOM.
  12056. */
  12057. type: any;
  12058. }
  12059. }
  12060. declare module BABYLON {
  12061. /**
  12062. * Manage the mouse inputs to control the movement of a free camera.
  12063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12064. */
  12065. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12066. /**
  12067. * Define if touch is enabled in the mouse input
  12068. */
  12069. touchEnabled: boolean;
  12070. /**
  12071. * Defines the camera the input is attached to.
  12072. */
  12073. camera: FreeCamera;
  12074. /**
  12075. * Defines the buttons associated with the input to handle camera move.
  12076. */
  12077. buttons: number[];
  12078. /**
  12079. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12080. */
  12081. angularSensibility: number;
  12082. private _pointerInput;
  12083. private _onMouseMove;
  12084. private _observer;
  12085. private previousPosition;
  12086. /**
  12087. * Observable for when a pointer move event occurs containing the move offset
  12088. */
  12089. onPointerMovedObservable: Observable<{
  12090. offsetX: number;
  12091. offsetY: number;
  12092. }>;
  12093. /**
  12094. * @hidden
  12095. * If the camera should be rotated automatically based on pointer movement
  12096. */
  12097. _allowCameraRotation: boolean;
  12098. /**
  12099. * Manage the mouse inputs to control the movement of a free camera.
  12100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12101. * @param touchEnabled Defines if touch is enabled or not
  12102. */
  12103. constructor(
  12104. /**
  12105. * Define if touch is enabled in the mouse input
  12106. */
  12107. touchEnabled?: boolean);
  12108. /**
  12109. * Attach the input controls to a specific dom element to get the input from.
  12110. * @param element Defines the element the controls should be listened from
  12111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12112. */
  12113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12114. /**
  12115. * Called on JS contextmenu event.
  12116. * Override this method to provide functionality.
  12117. */
  12118. protected onContextMenu(evt: PointerEvent): void;
  12119. /**
  12120. * Detach the current controls from the specified dom element.
  12121. * @param element Defines the element to stop listening the inputs from
  12122. */
  12123. detachControl(element: Nullable<HTMLElement>): void;
  12124. /**
  12125. * Gets the class name of the current intput.
  12126. * @returns the class name
  12127. */
  12128. getClassName(): string;
  12129. /**
  12130. * Get the friendly name associated with the input class.
  12131. * @returns the input friendly name
  12132. */
  12133. getSimpleName(): string;
  12134. }
  12135. }
  12136. declare module BABYLON {
  12137. /**
  12138. * Manage the touch inputs to control the movement of a free camera.
  12139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12140. */
  12141. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12142. /**
  12143. * Defines the camera the input is attached to.
  12144. */
  12145. camera: FreeCamera;
  12146. /**
  12147. * Defines the touch sensibility for rotation.
  12148. * The higher the faster.
  12149. */
  12150. touchAngularSensibility: number;
  12151. /**
  12152. * Defines the touch sensibility for move.
  12153. * The higher the faster.
  12154. */
  12155. touchMoveSensibility: number;
  12156. private _offsetX;
  12157. private _offsetY;
  12158. private _pointerPressed;
  12159. private _pointerInput;
  12160. private _observer;
  12161. private _onLostFocus;
  12162. /**
  12163. * Attach the input controls to a specific dom element to get the input from.
  12164. * @param element Defines the element the controls should be listened from
  12165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12166. */
  12167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12168. /**
  12169. * Detach the current controls from the specified dom element.
  12170. * @param element Defines the element to stop listening the inputs from
  12171. */
  12172. detachControl(element: Nullable<HTMLElement>): void;
  12173. /**
  12174. * Update the current camera state depending on the inputs that have been used this frame.
  12175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12176. */
  12177. checkInputs(): void;
  12178. /**
  12179. * Gets the class name of the current intput.
  12180. * @returns the class name
  12181. */
  12182. getClassName(): string;
  12183. /**
  12184. * Get the friendly name associated with the input class.
  12185. * @returns the input friendly name
  12186. */
  12187. getSimpleName(): string;
  12188. }
  12189. }
  12190. declare module BABYLON {
  12191. /**
  12192. * Default Inputs manager for the FreeCamera.
  12193. * It groups all the default supported inputs for ease of use.
  12194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12195. */
  12196. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12197. /**
  12198. * @hidden
  12199. */
  12200. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12201. /**
  12202. * @hidden
  12203. */
  12204. _mouseInput: Nullable<FreeCameraMouseInput>;
  12205. /**
  12206. * Instantiates a new FreeCameraInputsManager.
  12207. * @param camera Defines the camera the inputs belong to
  12208. */
  12209. constructor(camera: FreeCamera);
  12210. /**
  12211. * Add keyboard input support to the input manager.
  12212. * @returns the current input manager
  12213. */
  12214. addKeyboard(): FreeCameraInputsManager;
  12215. /**
  12216. * Add mouse input support to the input manager.
  12217. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12218. * @returns the current input manager
  12219. */
  12220. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12221. /**
  12222. * Removes the mouse input support from the manager
  12223. * @returns the current input manager
  12224. */
  12225. removeMouse(): FreeCameraInputsManager;
  12226. /**
  12227. * Add touch input support to the input manager.
  12228. * @returns the current input manager
  12229. */
  12230. addTouch(): FreeCameraInputsManager;
  12231. }
  12232. }
  12233. declare module BABYLON {
  12234. /**
  12235. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12236. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12238. */
  12239. export class FreeCamera extends TargetCamera {
  12240. /**
  12241. * Define the collision ellipsoid of the camera.
  12242. * This is helpful to simulate a camera body like the player body around the camera
  12243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12244. */
  12245. ellipsoid: Vector3;
  12246. /**
  12247. * Define an offset for the position of the ellipsoid around the camera.
  12248. * This can be helpful to determine the center of the body near the gravity center of the body
  12249. * instead of its head.
  12250. */
  12251. ellipsoidOffset: Vector3;
  12252. /**
  12253. * Enable or disable collisions of the camera with the rest of the scene objects.
  12254. */
  12255. checkCollisions: boolean;
  12256. /**
  12257. * Enable or disable gravity on the camera.
  12258. */
  12259. applyGravity: boolean;
  12260. /**
  12261. * Define the input manager associated to the camera.
  12262. */
  12263. inputs: FreeCameraInputsManager;
  12264. /**
  12265. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12266. * Higher values reduce sensitivity.
  12267. */
  12268. /**
  12269. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12270. * Higher values reduce sensitivity.
  12271. */
  12272. angularSensibility: number;
  12273. /**
  12274. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12275. */
  12276. keysUp: number[];
  12277. /**
  12278. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12279. */
  12280. keysDown: number[];
  12281. /**
  12282. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12283. */
  12284. keysLeft: number[];
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12287. */
  12288. keysRight: number[];
  12289. /**
  12290. * Event raised when the camera collide with a mesh in the scene.
  12291. */
  12292. onCollide: (collidedMesh: AbstractMesh) => void;
  12293. private _collider;
  12294. private _needMoveForGravity;
  12295. private _oldPosition;
  12296. private _diffPosition;
  12297. private _newPosition;
  12298. /** @hidden */
  12299. _localDirection: Vector3;
  12300. /** @hidden */
  12301. _transformedDirection: Vector3;
  12302. /**
  12303. * Instantiates a Free Camera.
  12304. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12305. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12307. * @param name Define the name of the camera in the scene
  12308. * @param position Define the start position of the camera in the scene
  12309. * @param scene Define the scene the camera belongs to
  12310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12311. */
  12312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12313. /**
  12314. * Attached controls to the current camera.
  12315. * @param element Defines the element the controls should be listened from
  12316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12317. */
  12318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12319. /**
  12320. * Detach the current controls from the camera.
  12321. * The camera will stop reacting to inputs.
  12322. * @param element Defines the element to stop listening the inputs from
  12323. */
  12324. detachControl(element: HTMLElement): void;
  12325. private _collisionMask;
  12326. /**
  12327. * Define a collision mask to limit the list of object the camera can collide with
  12328. */
  12329. collisionMask: number;
  12330. /** @hidden */
  12331. _collideWithWorld(displacement: Vector3): void;
  12332. private _onCollisionPositionChange;
  12333. /** @hidden */
  12334. _checkInputs(): void;
  12335. /** @hidden */
  12336. _decideIfNeedsToMove(): boolean;
  12337. /** @hidden */
  12338. _updatePosition(): void;
  12339. /**
  12340. * Destroy the camera and release the current resources hold by it.
  12341. */
  12342. dispose(): void;
  12343. /**
  12344. * Gets the current object class name.
  12345. * @return the class name
  12346. */
  12347. getClassName(): string;
  12348. }
  12349. }
  12350. declare module BABYLON {
  12351. /**
  12352. * Represents a gamepad control stick position
  12353. */
  12354. export class StickValues {
  12355. /**
  12356. * The x component of the control stick
  12357. */
  12358. x: number;
  12359. /**
  12360. * The y component of the control stick
  12361. */
  12362. y: number;
  12363. /**
  12364. * Initializes the gamepad x and y control stick values
  12365. * @param x The x component of the gamepad control stick value
  12366. * @param y The y component of the gamepad control stick value
  12367. */
  12368. constructor(
  12369. /**
  12370. * The x component of the control stick
  12371. */
  12372. x: number,
  12373. /**
  12374. * The y component of the control stick
  12375. */
  12376. y: number);
  12377. }
  12378. /**
  12379. * An interface which manages callbacks for gamepad button changes
  12380. */
  12381. export interface GamepadButtonChanges {
  12382. /**
  12383. * Called when a gamepad has been changed
  12384. */
  12385. changed: boolean;
  12386. /**
  12387. * Called when a gamepad press event has been triggered
  12388. */
  12389. pressChanged: boolean;
  12390. /**
  12391. * Called when a touch event has been triggered
  12392. */
  12393. touchChanged: boolean;
  12394. /**
  12395. * Called when a value has changed
  12396. */
  12397. valueChanged: boolean;
  12398. }
  12399. /**
  12400. * Represents a gamepad
  12401. */
  12402. export class Gamepad {
  12403. /**
  12404. * The id of the gamepad
  12405. */
  12406. id: string;
  12407. /**
  12408. * The index of the gamepad
  12409. */
  12410. index: number;
  12411. /**
  12412. * The browser gamepad
  12413. */
  12414. browserGamepad: any;
  12415. /**
  12416. * Specifies what type of gamepad this represents
  12417. */
  12418. type: number;
  12419. private _leftStick;
  12420. private _rightStick;
  12421. /** @hidden */
  12422. _isConnected: boolean;
  12423. private _leftStickAxisX;
  12424. private _leftStickAxisY;
  12425. private _rightStickAxisX;
  12426. private _rightStickAxisY;
  12427. /**
  12428. * Triggered when the left control stick has been changed
  12429. */
  12430. private _onleftstickchanged;
  12431. /**
  12432. * Triggered when the right control stick has been changed
  12433. */
  12434. private _onrightstickchanged;
  12435. /**
  12436. * Represents a gamepad controller
  12437. */
  12438. static GAMEPAD: number;
  12439. /**
  12440. * Represents a generic controller
  12441. */
  12442. static GENERIC: number;
  12443. /**
  12444. * Represents an XBox controller
  12445. */
  12446. static XBOX: number;
  12447. /**
  12448. * Represents a pose-enabled controller
  12449. */
  12450. static POSE_ENABLED: number;
  12451. /**
  12452. * Specifies whether the left control stick should be Y-inverted
  12453. */
  12454. protected _invertLeftStickY: boolean;
  12455. /**
  12456. * Specifies if the gamepad has been connected
  12457. */
  12458. readonly isConnected: boolean;
  12459. /**
  12460. * Initializes the gamepad
  12461. * @param id The id of the gamepad
  12462. * @param index The index of the gamepad
  12463. * @param browserGamepad The browser gamepad
  12464. * @param leftStickX The x component of the left joystick
  12465. * @param leftStickY The y component of the left joystick
  12466. * @param rightStickX The x component of the right joystick
  12467. * @param rightStickY The y component of the right joystick
  12468. */
  12469. constructor(
  12470. /**
  12471. * The id of the gamepad
  12472. */
  12473. id: string,
  12474. /**
  12475. * The index of the gamepad
  12476. */
  12477. index: number,
  12478. /**
  12479. * The browser gamepad
  12480. */
  12481. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12482. /**
  12483. * Callback triggered when the left joystick has changed
  12484. * @param callback
  12485. */
  12486. onleftstickchanged(callback: (values: StickValues) => void): void;
  12487. /**
  12488. * Callback triggered when the right joystick has changed
  12489. * @param callback
  12490. */
  12491. onrightstickchanged(callback: (values: StickValues) => void): void;
  12492. /**
  12493. * Gets the left joystick
  12494. */
  12495. /**
  12496. * Sets the left joystick values
  12497. */
  12498. leftStick: StickValues;
  12499. /**
  12500. * Gets the right joystick
  12501. */
  12502. /**
  12503. * Sets the right joystick value
  12504. */
  12505. rightStick: StickValues;
  12506. /**
  12507. * Updates the gamepad joystick positions
  12508. */
  12509. update(): void;
  12510. /**
  12511. * Disposes the gamepad
  12512. */
  12513. dispose(): void;
  12514. }
  12515. /**
  12516. * Represents a generic gamepad
  12517. */
  12518. export class GenericPad extends Gamepad {
  12519. private _buttons;
  12520. private _onbuttondown;
  12521. private _onbuttonup;
  12522. /**
  12523. * Observable triggered when a button has been pressed
  12524. */
  12525. onButtonDownObservable: Observable<number>;
  12526. /**
  12527. * Observable triggered when a button has been released
  12528. */
  12529. onButtonUpObservable: Observable<number>;
  12530. /**
  12531. * Callback triggered when a button has been pressed
  12532. * @param callback Called when a button has been pressed
  12533. */
  12534. onbuttondown(callback: (buttonPressed: number) => void): void;
  12535. /**
  12536. * Callback triggered when a button has been released
  12537. * @param callback Called when a button has been released
  12538. */
  12539. onbuttonup(callback: (buttonReleased: number) => void): void;
  12540. /**
  12541. * Initializes the generic gamepad
  12542. * @param id The id of the generic gamepad
  12543. * @param index The index of the generic gamepad
  12544. * @param browserGamepad The browser gamepad
  12545. */
  12546. constructor(id: string, index: number, browserGamepad: any);
  12547. private _setButtonValue;
  12548. /**
  12549. * Updates the generic gamepad
  12550. */
  12551. update(): void;
  12552. /**
  12553. * Disposes the generic gamepad
  12554. */
  12555. dispose(): void;
  12556. }
  12557. }
  12558. declare module BABYLON {
  12559. /**
  12560. * Defines the types of pose enabled controllers that are supported
  12561. */
  12562. export enum PoseEnabledControllerType {
  12563. /**
  12564. * HTC Vive
  12565. */
  12566. VIVE = 0,
  12567. /**
  12568. * Oculus Rift
  12569. */
  12570. OCULUS = 1,
  12571. /**
  12572. * Windows mixed reality
  12573. */
  12574. WINDOWS = 2,
  12575. /**
  12576. * Samsung gear VR
  12577. */
  12578. GEAR_VR = 3,
  12579. /**
  12580. * Google Daydream
  12581. */
  12582. DAYDREAM = 4,
  12583. /**
  12584. * Generic
  12585. */
  12586. GENERIC = 5
  12587. }
  12588. /**
  12589. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12590. */
  12591. export interface MutableGamepadButton {
  12592. /**
  12593. * Value of the button/trigger
  12594. */
  12595. value: number;
  12596. /**
  12597. * If the button/trigger is currently touched
  12598. */
  12599. touched: boolean;
  12600. /**
  12601. * If the button/trigger is currently pressed
  12602. */
  12603. pressed: boolean;
  12604. }
  12605. /**
  12606. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12607. * @hidden
  12608. */
  12609. export interface ExtendedGamepadButton extends GamepadButton {
  12610. /**
  12611. * If the button/trigger is currently pressed
  12612. */
  12613. readonly pressed: boolean;
  12614. /**
  12615. * If the button/trigger is currently touched
  12616. */
  12617. readonly touched: boolean;
  12618. /**
  12619. * Value of the button/trigger
  12620. */
  12621. readonly value: number;
  12622. }
  12623. /** @hidden */
  12624. export interface _GamePadFactory {
  12625. /**
  12626. * Returns wether or not the current gamepad can be created for this type of controller.
  12627. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12628. * @returns true if it can be created, otherwise false
  12629. */
  12630. canCreate(gamepadInfo: any): boolean;
  12631. /**
  12632. * Creates a new instance of the Gamepad.
  12633. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12634. * @returns the new gamepad instance
  12635. */
  12636. create(gamepadInfo: any): Gamepad;
  12637. }
  12638. /**
  12639. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12640. */
  12641. export class PoseEnabledControllerHelper {
  12642. /** @hidden */
  12643. static _ControllerFactories: _GamePadFactory[];
  12644. /** @hidden */
  12645. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12646. /**
  12647. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12648. * @param vrGamepad the gamepad to initialized
  12649. * @returns a vr controller of the type the gamepad identified as
  12650. */
  12651. static InitiateController(vrGamepad: any): Gamepad;
  12652. }
  12653. /**
  12654. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12655. */
  12656. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12657. private _deviceRoomPosition;
  12658. private _deviceRoomRotationQuaternion;
  12659. /**
  12660. * The device position in babylon space
  12661. */
  12662. devicePosition: Vector3;
  12663. /**
  12664. * The device rotation in babylon space
  12665. */
  12666. deviceRotationQuaternion: Quaternion;
  12667. /**
  12668. * The scale factor of the device in babylon space
  12669. */
  12670. deviceScaleFactor: number;
  12671. /**
  12672. * (Likely devicePosition should be used instead) The device position in its room space
  12673. */
  12674. position: Vector3;
  12675. /**
  12676. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12677. */
  12678. rotationQuaternion: Quaternion;
  12679. /**
  12680. * The type of controller (Eg. Windows mixed reality)
  12681. */
  12682. controllerType: PoseEnabledControllerType;
  12683. protected _calculatedPosition: Vector3;
  12684. private _calculatedRotation;
  12685. /**
  12686. * The raw pose from the device
  12687. */
  12688. rawPose: DevicePose;
  12689. private _trackPosition;
  12690. private _maxRotationDistFromHeadset;
  12691. private _draggedRoomRotation;
  12692. /**
  12693. * @hidden
  12694. */
  12695. _disableTrackPosition(fixedPosition: Vector3): void;
  12696. /**
  12697. * Internal, the mesh attached to the controller
  12698. * @hidden
  12699. */
  12700. _mesh: Nullable<AbstractMesh>;
  12701. private _poseControlledCamera;
  12702. private _leftHandSystemQuaternion;
  12703. /**
  12704. * Internal, matrix used to convert room space to babylon space
  12705. * @hidden
  12706. */
  12707. _deviceToWorld: Matrix;
  12708. /**
  12709. * Node to be used when casting a ray from the controller
  12710. * @hidden
  12711. */
  12712. _pointingPoseNode: Nullable<TransformNode>;
  12713. /**
  12714. * Name of the child mesh that can be used to cast a ray from the controller
  12715. */
  12716. static readonly POINTING_POSE: string;
  12717. /**
  12718. * Creates a new PoseEnabledController from a gamepad
  12719. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12720. */
  12721. constructor(browserGamepad: any);
  12722. private _workingMatrix;
  12723. /**
  12724. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12725. */
  12726. update(): void;
  12727. /**
  12728. * Updates only the pose device and mesh without doing any button event checking
  12729. */
  12730. protected _updatePoseAndMesh(): void;
  12731. /**
  12732. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12733. * @param poseData raw pose fromthe device
  12734. */
  12735. updateFromDevice(poseData: DevicePose): void;
  12736. /**
  12737. * @hidden
  12738. */
  12739. _meshAttachedObservable: Observable<AbstractMesh>;
  12740. /**
  12741. * Attaches a mesh to the controller
  12742. * @param mesh the mesh to be attached
  12743. */
  12744. attachToMesh(mesh: AbstractMesh): void;
  12745. /**
  12746. * Attaches the controllers mesh to a camera
  12747. * @param camera the camera the mesh should be attached to
  12748. */
  12749. attachToPoseControlledCamera(camera: TargetCamera): void;
  12750. /**
  12751. * Disposes of the controller
  12752. */
  12753. dispose(): void;
  12754. /**
  12755. * The mesh that is attached to the controller
  12756. */
  12757. readonly mesh: Nullable<AbstractMesh>;
  12758. /**
  12759. * Gets the ray of the controller in the direction the controller is pointing
  12760. * @param length the length the resulting ray should be
  12761. * @returns a ray in the direction the controller is pointing
  12762. */
  12763. getForwardRay(length?: number): Ray;
  12764. }
  12765. }
  12766. declare module BABYLON {
  12767. /**
  12768. * Defines the WebVRController object that represents controllers tracked in 3D space
  12769. */
  12770. export abstract class WebVRController extends PoseEnabledController {
  12771. /**
  12772. * Internal, the default controller model for the controller
  12773. */
  12774. protected _defaultModel: AbstractMesh;
  12775. /**
  12776. * Fired when the trigger state has changed
  12777. */
  12778. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12779. /**
  12780. * Fired when the main button state has changed
  12781. */
  12782. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12783. /**
  12784. * Fired when the secondary button state has changed
  12785. */
  12786. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12787. /**
  12788. * Fired when the pad state has changed
  12789. */
  12790. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12791. /**
  12792. * Fired when controllers stick values have changed
  12793. */
  12794. onPadValuesChangedObservable: Observable<StickValues>;
  12795. /**
  12796. * Array of button availible on the controller
  12797. */
  12798. protected _buttons: Array<MutableGamepadButton>;
  12799. private _onButtonStateChange;
  12800. /**
  12801. * Fired when a controller button's state has changed
  12802. * @param callback the callback containing the button that was modified
  12803. */
  12804. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12805. /**
  12806. * X and Y axis corrisponding to the controllers joystick
  12807. */
  12808. pad: StickValues;
  12809. /**
  12810. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12811. */
  12812. hand: string;
  12813. /**
  12814. * The default controller model for the controller
  12815. */
  12816. readonly defaultModel: AbstractMesh;
  12817. /**
  12818. * Creates a new WebVRController from a gamepad
  12819. * @param vrGamepad the gamepad that the WebVRController should be created from
  12820. */
  12821. constructor(vrGamepad: any);
  12822. /**
  12823. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12824. */
  12825. update(): void;
  12826. /**
  12827. * Function to be called when a button is modified
  12828. */
  12829. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12830. /**
  12831. * Loads a mesh and attaches it to the controller
  12832. * @param scene the scene the mesh should be added to
  12833. * @param meshLoaded callback for when the mesh has been loaded
  12834. */
  12835. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12836. private _setButtonValue;
  12837. private _changes;
  12838. private _checkChanges;
  12839. /**
  12840. * Disposes of th webVRCOntroller
  12841. */
  12842. dispose(): void;
  12843. }
  12844. }
  12845. declare module BABYLON {
  12846. /**
  12847. * The HemisphericLight simulates the ambient environment light,
  12848. * so the passed direction is the light reflection direction, not the incoming direction.
  12849. */
  12850. export class HemisphericLight extends Light {
  12851. /**
  12852. * The groundColor is the light in the opposite direction to the one specified during creation.
  12853. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  12854. */
  12855. groundColor: Color3;
  12856. /**
  12857. * The light reflection direction, not the incoming direction.
  12858. */
  12859. direction: Vector3;
  12860. /**
  12861. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12862. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12863. * The HemisphericLight can't cast shadows.
  12864. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12865. * @param name The friendly name of the light
  12866. * @param direction The direction of the light reflection
  12867. * @param scene The scene the light belongs to
  12868. */
  12869. constructor(name: string, direction: Vector3, scene: Scene);
  12870. protected _buildUniformLayout(): void;
  12871. /**
  12872. * Returns the string "HemisphericLight".
  12873. * @return The class name
  12874. */
  12875. getClassName(): string;
  12876. /**
  12877. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12878. * Returns the updated direction.
  12879. * @param target The target the direction should point to
  12880. * @return The computed direction
  12881. */
  12882. setDirectionToTarget(target: Vector3): Vector3;
  12883. /**
  12884. * Returns the shadow generator associated to the light.
  12885. * @returns Always null for hemispheric lights because it does not support shadows.
  12886. */
  12887. getShadowGenerator(): Nullable<IShadowGenerator>;
  12888. /**
  12889. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12890. * @param effect The effect to update
  12891. * @param lightIndex The index of the light in the effect to update
  12892. * @returns The hemispheric light
  12893. */
  12894. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12895. /**
  12896. * Computes the world matrix of the node
  12897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12898. * @param useWasUpdatedFlag defines a reserved property
  12899. * @returns the world matrix
  12900. */
  12901. computeWorldMatrix(): Matrix;
  12902. /**
  12903. * Returns the integer 3.
  12904. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12905. */
  12906. getTypeID(): number;
  12907. /**
  12908. * Prepares the list of defines specific to the light type.
  12909. * @param defines the list of defines
  12910. * @param lightIndex defines the index of the light for the effect
  12911. */
  12912. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12913. }
  12914. }
  12915. declare module BABYLON {
  12916. /** @hidden */
  12917. export var vrMultiviewToSingleviewPixelShader: {
  12918. name: string;
  12919. shader: string;
  12920. };
  12921. }
  12922. declare module BABYLON {
  12923. /**
  12924. * Renders to multiple views with a single draw call
  12925. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12926. */
  12927. export class MultiviewRenderTarget extends RenderTargetTexture {
  12928. /**
  12929. * Creates a multiview render target
  12930. * @param scene scene used with the render target
  12931. * @param size the size of the render target (used for each view)
  12932. */
  12933. constructor(scene: Scene, size?: number | {
  12934. width: number;
  12935. height: number;
  12936. } | {
  12937. ratio: number;
  12938. });
  12939. /**
  12940. * @hidden
  12941. * @param faceIndex the face index, if its a cube texture
  12942. */
  12943. _bindFrameBuffer(faceIndex?: number): void;
  12944. /**
  12945. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12946. * @returns the view count
  12947. */
  12948. getViewCount(): number;
  12949. }
  12950. }
  12951. declare module BABYLON {
  12952. interface Engine {
  12953. /**
  12954. * Creates a new multiview render target
  12955. * @param width defines the width of the texture
  12956. * @param height defines the height of the texture
  12957. * @returns the created multiview texture
  12958. */
  12959. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12960. /**
  12961. * Binds a multiview framebuffer to be drawn to
  12962. * @param multiviewTexture texture to bind
  12963. */
  12964. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12965. }
  12966. interface Camera {
  12967. /**
  12968. * @hidden
  12969. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12970. */
  12971. _useMultiviewToSingleView: boolean;
  12972. /**
  12973. * @hidden
  12974. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12975. */
  12976. _multiviewTexture: Nullable<RenderTargetTexture>;
  12977. /**
  12978. * @hidden
  12979. * ensures the multiview texture of the camera exists and has the specified width/height
  12980. * @param width height to set on the multiview texture
  12981. * @param height width to set on the multiview texture
  12982. */
  12983. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12984. }
  12985. interface Scene {
  12986. /** @hidden */
  12987. _transformMatrixR: Matrix;
  12988. /** @hidden */
  12989. _multiviewSceneUbo: Nullable<UniformBuffer>;
  12990. /** @hidden */
  12991. _createMultiviewUbo(): void;
  12992. /** @hidden */
  12993. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12994. /** @hidden */
  12995. _renderMultiviewToSingleView(camera: Camera): void;
  12996. }
  12997. }
  12998. declare module BABYLON {
  12999. /**
  13000. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13001. * This will not be used for webXR as it supports displaying texture arrays directly
  13002. */
  13003. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13004. /**
  13005. * Initializes a VRMultiviewToSingleview
  13006. * @param name name of the post process
  13007. * @param camera camera to be applied to
  13008. * @param scaleFactor scaling factor to the size of the output texture
  13009. */
  13010. constructor(name: string, camera: Camera, scaleFactor: number);
  13011. }
  13012. }
  13013. declare module BABYLON {
  13014. /**
  13015. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13016. * IMPORTANT!! The data is right-hand data.
  13017. * @export
  13018. * @interface DevicePose
  13019. */
  13020. export interface DevicePose {
  13021. /**
  13022. * The position of the device, values in array are [x,y,z].
  13023. */
  13024. readonly position: Nullable<Float32Array>;
  13025. /**
  13026. * The linearVelocity of the device, values in array are [x,y,z].
  13027. */
  13028. readonly linearVelocity: Nullable<Float32Array>;
  13029. /**
  13030. * The linearAcceleration of the device, values in array are [x,y,z].
  13031. */
  13032. readonly linearAcceleration: Nullable<Float32Array>;
  13033. /**
  13034. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13035. */
  13036. readonly orientation: Nullable<Float32Array>;
  13037. /**
  13038. * The angularVelocity of the device, values in array are [x,y,z].
  13039. */
  13040. readonly angularVelocity: Nullable<Float32Array>;
  13041. /**
  13042. * The angularAcceleration of the device, values in array are [x,y,z].
  13043. */
  13044. readonly angularAcceleration: Nullable<Float32Array>;
  13045. }
  13046. /**
  13047. * Interface representing a pose controlled object in Babylon.
  13048. * A pose controlled object has both regular pose values as well as pose values
  13049. * from an external device such as a VR head mounted display
  13050. */
  13051. export interface PoseControlled {
  13052. /**
  13053. * The position of the object in babylon space.
  13054. */
  13055. position: Vector3;
  13056. /**
  13057. * The rotation quaternion of the object in babylon space.
  13058. */
  13059. rotationQuaternion: Quaternion;
  13060. /**
  13061. * The position of the device in babylon space.
  13062. */
  13063. devicePosition?: Vector3;
  13064. /**
  13065. * The rotation quaternion of the device in babylon space.
  13066. */
  13067. deviceRotationQuaternion: Quaternion;
  13068. /**
  13069. * The raw pose coming from the device.
  13070. */
  13071. rawPose: Nullable<DevicePose>;
  13072. /**
  13073. * The scale of the device to be used when translating from device space to babylon space.
  13074. */
  13075. deviceScaleFactor: number;
  13076. /**
  13077. * Updates the poseControlled values based on the input device pose.
  13078. * @param poseData the pose data to update the object with
  13079. */
  13080. updateFromDevice(poseData: DevicePose): void;
  13081. }
  13082. /**
  13083. * Set of options to customize the webVRCamera
  13084. */
  13085. export interface WebVROptions {
  13086. /**
  13087. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13088. */
  13089. trackPosition?: boolean;
  13090. /**
  13091. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13092. */
  13093. positionScale?: number;
  13094. /**
  13095. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13096. */
  13097. displayName?: string;
  13098. /**
  13099. * Should the native controller meshes be initialized. (default: true)
  13100. */
  13101. controllerMeshes?: boolean;
  13102. /**
  13103. * Creating a default HemiLight only on controllers. (default: true)
  13104. */
  13105. defaultLightingOnControllers?: boolean;
  13106. /**
  13107. * If you don't want to use the default VR button of the helper. (default: false)
  13108. */
  13109. useCustomVRButton?: boolean;
  13110. /**
  13111. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13112. */
  13113. customVRButton?: HTMLButtonElement;
  13114. /**
  13115. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13116. */
  13117. rayLength?: number;
  13118. /**
  13119. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13120. */
  13121. defaultHeight?: number;
  13122. /**
  13123. * If multiview should be used if availible (default: false)
  13124. */
  13125. useMultiview?: boolean;
  13126. }
  13127. /**
  13128. * This represents a WebVR camera.
  13129. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13130. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13131. */
  13132. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13133. private webVROptions;
  13134. /**
  13135. * @hidden
  13136. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13137. */
  13138. _vrDevice: any;
  13139. /**
  13140. * The rawPose of the vrDevice.
  13141. */
  13142. rawPose: Nullable<DevicePose>;
  13143. private _onVREnabled;
  13144. private _specsVersion;
  13145. private _attached;
  13146. private _frameData;
  13147. protected _descendants: Array<Node>;
  13148. private _deviceRoomPosition;
  13149. /** @hidden */
  13150. _deviceRoomRotationQuaternion: Quaternion;
  13151. private _standingMatrix;
  13152. /**
  13153. * Represents device position in babylon space.
  13154. */
  13155. devicePosition: Vector3;
  13156. /**
  13157. * Represents device rotation in babylon space.
  13158. */
  13159. deviceRotationQuaternion: Quaternion;
  13160. /**
  13161. * The scale of the device to be used when translating from device space to babylon space.
  13162. */
  13163. deviceScaleFactor: number;
  13164. private _deviceToWorld;
  13165. private _worldToDevice;
  13166. /**
  13167. * References to the webVR controllers for the vrDevice.
  13168. */
  13169. controllers: Array<WebVRController>;
  13170. /**
  13171. * Emits an event when a controller is attached.
  13172. */
  13173. onControllersAttachedObservable: Observable<WebVRController[]>;
  13174. /**
  13175. * Emits an event when a controller's mesh has been loaded;
  13176. */
  13177. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13178. /**
  13179. * Emits an event when the HMD's pose has been updated.
  13180. */
  13181. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13182. private _poseSet;
  13183. /**
  13184. * If the rig cameras be used as parent instead of this camera.
  13185. */
  13186. rigParenting: boolean;
  13187. private _lightOnControllers;
  13188. private _defaultHeight?;
  13189. /**
  13190. * Instantiates a WebVRFreeCamera.
  13191. * @param name The name of the WebVRFreeCamera
  13192. * @param position The starting anchor position for the camera
  13193. * @param scene The scene the camera belongs to
  13194. * @param webVROptions a set of customizable options for the webVRCamera
  13195. */
  13196. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13197. /**
  13198. * Gets the device distance from the ground in meters.
  13199. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  13200. */
  13201. deviceDistanceToRoomGround(): number;
  13202. /**
  13203. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13204. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13205. */
  13206. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13207. /**
  13208. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13209. * @returns A promise with a boolean set to if the standing matrix is supported.
  13210. */
  13211. useStandingMatrixAsync(): Promise<boolean>;
  13212. /**
  13213. * Disposes the camera
  13214. */
  13215. dispose(): void;
  13216. /**
  13217. * Gets a vrController by name.
  13218. * @param name The name of the controller to retreive
  13219. * @returns the controller matching the name specified or null if not found
  13220. */
  13221. getControllerByName(name: string): Nullable<WebVRController>;
  13222. private _leftController;
  13223. /**
  13224. * The controller corrisponding to the users left hand.
  13225. */
  13226. readonly leftController: Nullable<WebVRController>;
  13227. private _rightController;
  13228. /**
  13229. * The controller corrisponding to the users right hand.
  13230. */
  13231. readonly rightController: Nullable<WebVRController>;
  13232. /**
  13233. * Casts a ray forward from the vrCamera's gaze.
  13234. * @param length Length of the ray (default: 100)
  13235. * @returns the ray corrisponding to the gaze
  13236. */
  13237. getForwardRay(length?: number): Ray;
  13238. /**
  13239. * @hidden
  13240. * Updates the camera based on device's frame data
  13241. */
  13242. _checkInputs(): void;
  13243. /**
  13244. * Updates the poseControlled values based on the input device pose.
  13245. * @param poseData Pose coming from the device
  13246. */
  13247. updateFromDevice(poseData: DevicePose): void;
  13248. private _htmlElementAttached;
  13249. private _detachIfAttached;
  13250. /**
  13251. * WebVR's attach control will start broadcasting frames to the device.
  13252. * Note that in certain browsers (chrome for example) this function must be called
  13253. * within a user-interaction callback. Example:
  13254. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13255. *
  13256. * @param element html element to attach the vrDevice to
  13257. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13258. */
  13259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13260. /**
  13261. * Detaches the camera from the html element and disables VR
  13262. *
  13263. * @param element html element to detach from
  13264. */
  13265. detachControl(element: HTMLElement): void;
  13266. /**
  13267. * @returns the name of this class
  13268. */
  13269. getClassName(): string;
  13270. /**
  13271. * Calls resetPose on the vrDisplay
  13272. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13273. */
  13274. resetToCurrentRotation(): void;
  13275. /**
  13276. * @hidden
  13277. * Updates the rig cameras (left and right eye)
  13278. */
  13279. _updateRigCameras(): void;
  13280. private _workingVector;
  13281. private _oneVector;
  13282. private _workingMatrix;
  13283. private updateCacheCalled;
  13284. private _correctPositionIfNotTrackPosition;
  13285. /**
  13286. * @hidden
  13287. * Updates the cached values of the camera
  13288. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13289. */
  13290. _updateCache(ignoreParentClass?: boolean): void;
  13291. /**
  13292. * @hidden
  13293. * Get current device position in babylon world
  13294. */
  13295. _computeDevicePosition(): void;
  13296. /**
  13297. * Updates the current device position and rotation in the babylon world
  13298. */
  13299. update(): void;
  13300. /**
  13301. * @hidden
  13302. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13303. * @returns an identity matrix
  13304. */
  13305. _getViewMatrix(): Matrix;
  13306. private _tmpMatrix;
  13307. /**
  13308. * This function is called by the two RIG cameras.
  13309. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13310. * @hidden
  13311. */
  13312. _getWebVRViewMatrix(): Matrix;
  13313. /** @hidden */
  13314. _getWebVRProjectionMatrix(): Matrix;
  13315. private _onGamepadConnectedObserver;
  13316. private _onGamepadDisconnectedObserver;
  13317. private _updateCacheWhenTrackingDisabledObserver;
  13318. /**
  13319. * Initializes the controllers and their meshes
  13320. */
  13321. initControllers(): void;
  13322. }
  13323. }
  13324. declare module BABYLON {
  13325. /**
  13326. * Size options for a post process
  13327. */
  13328. export type PostProcessOptions = {
  13329. width: number;
  13330. height: number;
  13331. };
  13332. /**
  13333. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13334. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13335. */
  13336. export class PostProcess {
  13337. /** Name of the PostProcess. */
  13338. name: string;
  13339. /**
  13340. * Gets or sets the unique id of the post process
  13341. */
  13342. uniqueId: number;
  13343. /**
  13344. * Width of the texture to apply the post process on
  13345. */
  13346. width: number;
  13347. /**
  13348. * Height of the texture to apply the post process on
  13349. */
  13350. height: number;
  13351. /**
  13352. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13353. * @hidden
  13354. */
  13355. _outputTexture: Nullable<InternalTexture>;
  13356. /**
  13357. * Sampling mode used by the shader
  13358. * See https://doc.babylonjs.com/classes/3.1/texture
  13359. */
  13360. renderTargetSamplingMode: number;
  13361. /**
  13362. * Clear color to use when screen clearing
  13363. */
  13364. clearColor: Color4;
  13365. /**
  13366. * If the buffer needs to be cleared before applying the post process. (default: true)
  13367. * Should be set to false if shader will overwrite all previous pixels.
  13368. */
  13369. autoClear: boolean;
  13370. /**
  13371. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13372. */
  13373. alphaMode: number;
  13374. /**
  13375. * Sets the setAlphaBlendConstants of the babylon engine
  13376. */
  13377. alphaConstants: Color4;
  13378. /**
  13379. * Animations to be used for the post processing
  13380. */
  13381. animations: Animation[];
  13382. /**
  13383. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13384. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13385. */
  13386. enablePixelPerfectMode: boolean;
  13387. /**
  13388. * Force the postprocess to be applied without taking in account viewport
  13389. */
  13390. forceFullscreenViewport: boolean;
  13391. /**
  13392. * List of inspectable custom properties (used by the Inspector)
  13393. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13394. */
  13395. inspectableCustomProperties: IInspectable[];
  13396. /**
  13397. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13398. *
  13399. * | Value | Type | Description |
  13400. * | ----- | ----------------------------------- | ----------- |
  13401. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13402. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13403. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13404. *
  13405. */
  13406. scaleMode: number;
  13407. /**
  13408. * Force textures to be a power of two (default: false)
  13409. */
  13410. alwaysForcePOT: boolean;
  13411. private _samples;
  13412. /**
  13413. * Number of sample textures (default: 1)
  13414. */
  13415. samples: number;
  13416. /**
  13417. * Modify the scale of the post process to be the same as the viewport (default: false)
  13418. */
  13419. adaptScaleToCurrentViewport: boolean;
  13420. private _camera;
  13421. private _scene;
  13422. private _engine;
  13423. private _options;
  13424. private _reusable;
  13425. private _textureType;
  13426. /**
  13427. * Smart array of input and output textures for the post process.
  13428. * @hidden
  13429. */
  13430. _textures: SmartArray<InternalTexture>;
  13431. /**
  13432. * The index in _textures that corresponds to the output texture.
  13433. * @hidden
  13434. */
  13435. _currentRenderTextureInd: number;
  13436. private _effect;
  13437. private _samplers;
  13438. private _fragmentUrl;
  13439. private _vertexUrl;
  13440. private _parameters;
  13441. private _scaleRatio;
  13442. protected _indexParameters: any;
  13443. private _shareOutputWithPostProcess;
  13444. private _texelSize;
  13445. private _forcedOutputTexture;
  13446. /**
  13447. * Returns the fragment url or shader name used in the post process.
  13448. * @returns the fragment url or name in the shader store.
  13449. */
  13450. getEffectName(): string;
  13451. /**
  13452. * An event triggered when the postprocess is activated.
  13453. */
  13454. onActivateObservable: Observable<Camera>;
  13455. private _onActivateObserver;
  13456. /**
  13457. * A function that is added to the onActivateObservable
  13458. */
  13459. onActivate: Nullable<(camera: Camera) => void>;
  13460. /**
  13461. * An event triggered when the postprocess changes its size.
  13462. */
  13463. onSizeChangedObservable: Observable<PostProcess>;
  13464. private _onSizeChangedObserver;
  13465. /**
  13466. * A function that is added to the onSizeChangedObservable
  13467. */
  13468. onSizeChanged: (postProcess: PostProcess) => void;
  13469. /**
  13470. * An event triggered when the postprocess applies its effect.
  13471. */
  13472. onApplyObservable: Observable<Effect>;
  13473. private _onApplyObserver;
  13474. /**
  13475. * A function that is added to the onApplyObservable
  13476. */
  13477. onApply: (effect: Effect) => void;
  13478. /**
  13479. * An event triggered before rendering the postprocess
  13480. */
  13481. onBeforeRenderObservable: Observable<Effect>;
  13482. private _onBeforeRenderObserver;
  13483. /**
  13484. * A function that is added to the onBeforeRenderObservable
  13485. */
  13486. onBeforeRender: (effect: Effect) => void;
  13487. /**
  13488. * An event triggered after rendering the postprocess
  13489. */
  13490. onAfterRenderObservable: Observable<Effect>;
  13491. private _onAfterRenderObserver;
  13492. /**
  13493. * A function that is added to the onAfterRenderObservable
  13494. */
  13495. onAfterRender: (efect: Effect) => void;
  13496. /**
  13497. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  13498. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13499. */
  13500. inputTexture: InternalTexture;
  13501. /**
  13502. * Gets the camera which post process is applied to.
  13503. * @returns The camera the post process is applied to.
  13504. */
  13505. getCamera(): Camera;
  13506. /**
  13507. * Gets the texel size of the postprocess.
  13508. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13509. */
  13510. readonly texelSize: Vector2;
  13511. /**
  13512. * Creates a new instance PostProcess
  13513. * @param name The name of the PostProcess.
  13514. * @param fragmentUrl The url of the fragment shader to be used.
  13515. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13516. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13517. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13518. * @param camera The camera to apply the render pass to.
  13519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13520. * @param engine The engine which the post process will be applied. (default: current engine)
  13521. * @param reusable If the post process can be reused on the same frame. (default: false)
  13522. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13523. * @param textureType Type of textures used when performing the post process. (default: 0)
  13524. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13525. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13526. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13527. */
  13528. constructor(
  13529. /** Name of the PostProcess. */
  13530. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  13531. /**
  13532. * Gets a string idenfifying the name of the class
  13533. * @returns "PostProcess" string
  13534. */
  13535. getClassName(): string;
  13536. /**
  13537. * Gets the engine which this post process belongs to.
  13538. * @returns The engine the post process was enabled with.
  13539. */
  13540. getEngine(): Engine;
  13541. /**
  13542. * The effect that is created when initializing the post process.
  13543. * @returns The created effect corrisponding the the postprocess.
  13544. */
  13545. getEffect(): Effect;
  13546. /**
  13547. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13548. * @param postProcess The post process to share the output with.
  13549. * @returns This post process.
  13550. */
  13551. shareOutputWith(postProcess: PostProcess): PostProcess;
  13552. /**
  13553. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13554. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13555. */
  13556. useOwnOutput(): void;
  13557. /**
  13558. * Updates the effect with the current post process compile time values and recompiles the shader.
  13559. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13560. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13561. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13562. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13563. * @param onCompiled Called when the shader has been compiled.
  13564. * @param onError Called if there is an error when compiling a shader.
  13565. */
  13566. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13567. /**
  13568. * The post process is reusable if it can be used multiple times within one frame.
  13569. * @returns If the post process is reusable
  13570. */
  13571. isReusable(): boolean;
  13572. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13573. markTextureDirty(): void;
  13574. /**
  13575. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13576. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  13577. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13578. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13579. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13580. * @returns The target texture that was bound to be written to.
  13581. */
  13582. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13583. /**
  13584. * If the post process is supported.
  13585. */
  13586. readonly isSupported: boolean;
  13587. /**
  13588. * The aspect ratio of the output texture.
  13589. */
  13590. readonly aspectRatio: number;
  13591. /**
  13592. * Get a value indicating if the post-process is ready to be used
  13593. * @returns true if the post-process is ready (shader is compiled)
  13594. */
  13595. isReady(): boolean;
  13596. /**
  13597. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13598. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13599. */
  13600. apply(): Nullable<Effect>;
  13601. private _disposeTextures;
  13602. /**
  13603. * Disposes the post process.
  13604. * @param camera The camera to dispose the post process on.
  13605. */
  13606. dispose(camera?: Camera): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13612. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13613. */
  13614. export class PostProcessManager {
  13615. private _scene;
  13616. private _indexBuffer;
  13617. private _vertexBuffers;
  13618. /**
  13619. * Creates a new instance PostProcess
  13620. * @param scene The scene that the post process is associated with.
  13621. */
  13622. constructor(scene: Scene);
  13623. private _prepareBuffers;
  13624. private _buildIndexBuffer;
  13625. /**
  13626. * Rebuilds the vertex buffers of the manager.
  13627. * @hidden
  13628. */
  13629. _rebuild(): void;
  13630. /**
  13631. * Prepares a frame to be run through a post process.
  13632. * @param sourceTexture The input texture to the post procesess. (default: null)
  13633. * @param postProcesses An array of post processes to be run. (default: null)
  13634. * @returns True if the post processes were able to be run.
  13635. * @hidden
  13636. */
  13637. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13638. /**
  13639. * Manually render a set of post processes to a texture.
  13640. * @param postProcesses An array of post processes to be run.
  13641. * @param targetTexture The target texture to render to.
  13642. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13643. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13644. * @param lodLevel defines which lod of the texture to render to
  13645. */
  13646. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13647. /**
  13648. * Finalize the result of the output of the postprocesses.
  13649. * @param doNotPresent If true the result will not be displayed to the screen.
  13650. * @param targetTexture The target texture to render to.
  13651. * @param faceIndex The index of the face to bind the target texture to.
  13652. * @param postProcesses The array of post processes to render.
  13653. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13654. * @hidden
  13655. */
  13656. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13657. /**
  13658. * Disposes of the post process manager.
  13659. */
  13660. dispose(): void;
  13661. }
  13662. }
  13663. declare module BABYLON {
  13664. interface AbstractScene {
  13665. /**
  13666. * The list of layers (background and foreground) of the scene
  13667. */
  13668. layers: Array<Layer>;
  13669. }
  13670. /**
  13671. * Defines the layer scene component responsible to manage any layers
  13672. * in a given scene.
  13673. */
  13674. export class LayerSceneComponent implements ISceneComponent {
  13675. /**
  13676. * The component name helpfull to identify the component in the list of scene components.
  13677. */
  13678. readonly name: string;
  13679. /**
  13680. * The scene the component belongs to.
  13681. */
  13682. scene: Scene;
  13683. private _engine;
  13684. /**
  13685. * Creates a new instance of the component for the given scene
  13686. * @param scene Defines the scene to register the component in
  13687. */
  13688. constructor(scene: Scene);
  13689. /**
  13690. * Registers the component in a given scene
  13691. */
  13692. register(): void;
  13693. /**
  13694. * Rebuilds the elements related to this component in case of
  13695. * context lost for instance.
  13696. */
  13697. rebuild(): void;
  13698. /**
  13699. * Disposes the component and the associated ressources.
  13700. */
  13701. dispose(): void;
  13702. private _draw;
  13703. private _drawCameraPredicate;
  13704. private _drawCameraBackground;
  13705. private _drawCameraForeground;
  13706. private _drawRenderTargetPredicate;
  13707. private _drawRenderTargetBackground;
  13708. private _drawRenderTargetForeground;
  13709. }
  13710. }
  13711. declare module BABYLON {
  13712. /** @hidden */
  13713. export var layerPixelShader: {
  13714. name: string;
  13715. shader: string;
  13716. };
  13717. }
  13718. declare module BABYLON {
  13719. /** @hidden */
  13720. export var layerVertexShader: {
  13721. name: string;
  13722. shader: string;
  13723. };
  13724. }
  13725. declare module BABYLON {
  13726. /**
  13727. * This represents a full screen 2d layer.
  13728. * This can be useful to display a picture in the background of your scene for instance.
  13729. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13730. */
  13731. export class Layer {
  13732. /**
  13733. * Define the name of the layer.
  13734. */
  13735. name: string;
  13736. /**
  13737. * Define the texture the layer should display.
  13738. */
  13739. texture: Nullable<Texture>;
  13740. /**
  13741. * Is the layer in background or foreground.
  13742. */
  13743. isBackground: boolean;
  13744. /**
  13745. * Define the color of the layer (instead of texture).
  13746. */
  13747. color: Color4;
  13748. /**
  13749. * Define the scale of the layer in order to zoom in out of the texture.
  13750. */
  13751. scale: Vector2;
  13752. /**
  13753. * Define an offset for the layer in order to shift the texture.
  13754. */
  13755. offset: Vector2;
  13756. /**
  13757. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13758. */
  13759. alphaBlendingMode: number;
  13760. /**
  13761. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13762. * Alpha test will not mix with the background color in case of transparency.
  13763. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13764. */
  13765. alphaTest: boolean;
  13766. /**
  13767. * Define a mask to restrict the layer to only some of the scene cameras.
  13768. */
  13769. layerMask: number;
  13770. /**
  13771. * Define the list of render target the layer is visible into.
  13772. */
  13773. renderTargetTextures: RenderTargetTexture[];
  13774. /**
  13775. * Define if the layer is only used in renderTarget or if it also
  13776. * renders in the main frame buffer of the canvas.
  13777. */
  13778. renderOnlyInRenderTargetTextures: boolean;
  13779. private _scene;
  13780. private _vertexBuffers;
  13781. private _indexBuffer;
  13782. private _effect;
  13783. private _alphaTestEffect;
  13784. /**
  13785. * An event triggered when the layer is disposed.
  13786. */
  13787. onDisposeObservable: Observable<Layer>;
  13788. private _onDisposeObserver;
  13789. /**
  13790. * Back compatibility with callback before the onDisposeObservable existed.
  13791. * The set callback will be triggered when the layer has been disposed.
  13792. */
  13793. onDispose: () => void;
  13794. /**
  13795. * An event triggered before rendering the scene
  13796. */
  13797. onBeforeRenderObservable: Observable<Layer>;
  13798. private _onBeforeRenderObserver;
  13799. /**
  13800. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13801. * The set callback will be triggered just before rendering the layer.
  13802. */
  13803. onBeforeRender: () => void;
  13804. /**
  13805. * An event triggered after rendering the scene
  13806. */
  13807. onAfterRenderObservable: Observable<Layer>;
  13808. private _onAfterRenderObserver;
  13809. /**
  13810. * Back compatibility with callback before the onAfterRenderObservable existed.
  13811. * The set callback will be triggered just after rendering the layer.
  13812. */
  13813. onAfterRender: () => void;
  13814. /**
  13815. * Instantiates a new layer.
  13816. * This represents a full screen 2d layer.
  13817. * This can be useful to display a picture in the background of your scene for instance.
  13818. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13819. * @param name Define the name of the layer in the scene
  13820. * @param imgUrl Define the url of the texture to display in the layer
  13821. * @param scene Define the scene the layer belongs to
  13822. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13823. * @param color Defines a color for the layer
  13824. */
  13825. constructor(
  13826. /**
  13827. * Define the name of the layer.
  13828. */
  13829. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13830. private _createIndexBuffer;
  13831. /** @hidden */
  13832. _rebuild(): void;
  13833. /**
  13834. * Renders the layer in the scene.
  13835. */
  13836. render(): void;
  13837. /**
  13838. * Disposes and releases the associated ressources.
  13839. */
  13840. dispose(): void;
  13841. }
  13842. }
  13843. declare module BABYLON {
  13844. interface AbstractScene {
  13845. /**
  13846. * The list of procedural textures added to the scene
  13847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13848. */
  13849. proceduralTextures: Array<ProceduralTexture>;
  13850. }
  13851. /**
  13852. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13853. * in a given scene.
  13854. */
  13855. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13856. /**
  13857. * The component name helpfull to identify the component in the list of scene components.
  13858. */
  13859. readonly name: string;
  13860. /**
  13861. * The scene the component belongs to.
  13862. */
  13863. scene: Scene;
  13864. /**
  13865. * Creates a new instance of the component for the given scene
  13866. * @param scene Defines the scene to register the component in
  13867. */
  13868. constructor(scene: Scene);
  13869. /**
  13870. * Registers the component in a given scene
  13871. */
  13872. register(): void;
  13873. /**
  13874. * Rebuilds the elements related to this component in case of
  13875. * context lost for instance.
  13876. */
  13877. rebuild(): void;
  13878. /**
  13879. * Disposes the component and the associated ressources.
  13880. */
  13881. dispose(): void;
  13882. private _beforeClear;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /** @hidden */
  13887. export var proceduralVertexShader: {
  13888. name: string;
  13889. shader: string;
  13890. };
  13891. }
  13892. declare module BABYLON {
  13893. /**
  13894. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  13895. * This is the base class of any Procedural texture and contains most of the shareable code.
  13896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13897. */
  13898. export class ProceduralTexture extends Texture {
  13899. isCube: boolean;
  13900. /**
  13901. * Define if the texture is enabled or not (disabled texture will not render)
  13902. */
  13903. isEnabled: boolean;
  13904. /**
  13905. * Define if the texture must be cleared before rendering (default is true)
  13906. */
  13907. autoClear: boolean;
  13908. /**
  13909. * Callback called when the texture is generated
  13910. */
  13911. onGenerated: () => void;
  13912. /**
  13913. * Event raised when the texture is generated
  13914. */
  13915. onGeneratedObservable: Observable<ProceduralTexture>;
  13916. /** @hidden */
  13917. _generateMipMaps: boolean;
  13918. /** @hidden **/
  13919. _effect: Effect;
  13920. /** @hidden */
  13921. _textures: {
  13922. [key: string]: Texture;
  13923. };
  13924. private _size;
  13925. private _currentRefreshId;
  13926. private _refreshRate;
  13927. private _vertexBuffers;
  13928. private _indexBuffer;
  13929. private _uniforms;
  13930. private _samplers;
  13931. private _fragment;
  13932. private _floats;
  13933. private _ints;
  13934. private _floatsArrays;
  13935. private _colors3;
  13936. private _colors4;
  13937. private _vectors2;
  13938. private _vectors3;
  13939. private _matrices;
  13940. private _fallbackTexture;
  13941. private _fallbackTextureUsed;
  13942. private _engine;
  13943. private _cachedDefines;
  13944. private _contentUpdateId;
  13945. private _contentData;
  13946. /**
  13947. * Instantiates a new procedural texture.
  13948. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  13949. * This is the base class of any Procedural texture and contains most of the shareable code.
  13950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13951. * @param name Define the name of the texture
  13952. * @param size Define the size of the texture to create
  13953. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13954. * @param scene Define the scene the texture belongs to
  13955. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13956. * @param generateMipMaps Define if the texture should creates mip maps or not
  13957. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13958. */
  13959. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13960. /**
  13961. * The effect that is created when initializing the post process.
  13962. * @returns The created effect corrisponding the the postprocess.
  13963. */
  13964. getEffect(): Effect;
  13965. /**
  13966. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13967. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13968. */
  13969. getContent(): Nullable<ArrayBufferView>;
  13970. private _createIndexBuffer;
  13971. /** @hidden */
  13972. _rebuild(): void;
  13973. /**
  13974. * Resets the texture in order to recreate its associated resources.
  13975. * This can be called in case of context loss
  13976. */
  13977. reset(): void;
  13978. protected _getDefines(): string;
  13979. /**
  13980. * Is the texture ready to be used ? (rendered at least once)
  13981. * @returns true if ready, otherwise, false.
  13982. */
  13983. isReady(): boolean;
  13984. /**
  13985. * Resets the refresh counter of the texture and start bak from scratch.
  13986. * Could be useful to regenerate the texture if it is setup to render only once.
  13987. */
  13988. resetRefreshCounter(): void;
  13989. /**
  13990. * Set the fragment shader to use in order to render the texture.
  13991. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13992. */
  13993. setFragment(fragment: any): void;
  13994. /**
  13995. * Define the refresh rate of the texture or the rendering frequency.
  13996. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13997. */
  13998. refreshRate: number;
  13999. /** @hidden */
  14000. _shouldRender(): boolean;
  14001. /**
  14002. * Get the size the texture is rendering at.
  14003. * @returns the size (texture is always squared)
  14004. */
  14005. getRenderSize(): number;
  14006. /**
  14007. * Resize the texture to new value.
  14008. * @param size Define the new size the texture should have
  14009. * @param generateMipMaps Define whether the new texture should create mip maps
  14010. */
  14011. resize(size: number, generateMipMaps: boolean): void;
  14012. private _checkUniform;
  14013. /**
  14014. * Set a texture in the shader program used to render.
  14015. * @param name Define the name of the uniform samplers as defined in the shader
  14016. * @param texture Define the texture to bind to this sampler
  14017. * @return the texture itself allowing "fluent" like uniform updates
  14018. */
  14019. setTexture(name: string, texture: Texture): ProceduralTexture;
  14020. /**
  14021. * Set a float in the shader.
  14022. * @param name Define the name of the uniform as defined in the shader
  14023. * @param value Define the value to give to the uniform
  14024. * @return the texture itself allowing "fluent" like uniform updates
  14025. */
  14026. setFloat(name: string, value: number): ProceduralTexture;
  14027. /**
  14028. * Set a int in the shader.
  14029. * @param name Define the name of the uniform as defined in the shader
  14030. * @param value Define the value to give to the uniform
  14031. * @return the texture itself allowing "fluent" like uniform updates
  14032. */
  14033. setInt(name: string, value: number): ProceduralTexture;
  14034. /**
  14035. * Set an array of floats in the shader.
  14036. * @param name Define the name of the uniform as defined in the shader
  14037. * @param value Define the value to give to the uniform
  14038. * @return the texture itself allowing "fluent" like uniform updates
  14039. */
  14040. setFloats(name: string, value: number[]): ProceduralTexture;
  14041. /**
  14042. * Set a vec3 in the shader from a Color3.
  14043. * @param name Define the name of the uniform as defined in the shader
  14044. * @param value Define the value to give to the uniform
  14045. * @return the texture itself allowing "fluent" like uniform updates
  14046. */
  14047. setColor3(name: string, value: Color3): ProceduralTexture;
  14048. /**
  14049. * Set a vec4 in the shader from a Color4.
  14050. * @param name Define the name of the uniform as defined in the shader
  14051. * @param value Define the value to give to the uniform
  14052. * @return the texture itself allowing "fluent" like uniform updates
  14053. */
  14054. setColor4(name: string, value: Color4): ProceduralTexture;
  14055. /**
  14056. * Set a vec2 in the shader from a Vector2.
  14057. * @param name Define the name of the uniform as defined in the shader
  14058. * @param value Define the value to give to the uniform
  14059. * @return the texture itself allowing "fluent" like uniform updates
  14060. */
  14061. setVector2(name: string, value: Vector2): ProceduralTexture;
  14062. /**
  14063. * Set a vec3 in the shader from a Vector3.
  14064. * @param name Define the name of the uniform as defined in the shader
  14065. * @param value Define the value to give to the uniform
  14066. * @return the texture itself allowing "fluent" like uniform updates
  14067. */
  14068. setVector3(name: string, value: Vector3): ProceduralTexture;
  14069. /**
  14070. * Set a mat4 in the shader from a MAtrix.
  14071. * @param name Define the name of the uniform as defined in the shader
  14072. * @param value Define the value to give to the uniform
  14073. * @return the texture itself allowing "fluent" like uniform updates
  14074. */
  14075. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14076. /**
  14077. * Render the texture to its associated render target.
  14078. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14079. */
  14080. render(useCameraPostProcess?: boolean): void;
  14081. /**
  14082. * Clone the texture.
  14083. * @returns the cloned texture
  14084. */
  14085. clone(): ProceduralTexture;
  14086. /**
  14087. * Dispose the texture and release its asoociated resources.
  14088. */
  14089. dispose(): void;
  14090. }
  14091. }
  14092. declare module BABYLON {
  14093. /**
  14094. * This represents the base class for particle system in Babylon.
  14095. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14096. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14097. * @example https://doc.babylonjs.com/babylon101/particles
  14098. */
  14099. export class BaseParticleSystem {
  14100. /**
  14101. * Source color is added to the destination color without alpha affecting the result
  14102. */
  14103. static BLENDMODE_ONEONE: number;
  14104. /**
  14105. * Blend current color and particle color using particle’s alpha
  14106. */
  14107. static BLENDMODE_STANDARD: number;
  14108. /**
  14109. * Add current color and particle color multiplied by particle’s alpha
  14110. */
  14111. static BLENDMODE_ADD: number;
  14112. /**
  14113. * Multiply current color with particle color
  14114. */
  14115. static BLENDMODE_MULTIPLY: number;
  14116. /**
  14117. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14118. */
  14119. static BLENDMODE_MULTIPLYADD: number;
  14120. /**
  14121. * List of animations used by the particle system.
  14122. */
  14123. animations: Animation[];
  14124. /**
  14125. * The id of the Particle system.
  14126. */
  14127. id: string;
  14128. /**
  14129. * The friendly name of the Particle system.
  14130. */
  14131. name: string;
  14132. /**
  14133. * The rendering group used by the Particle system to chose when to render.
  14134. */
  14135. renderingGroupId: number;
  14136. /**
  14137. * The emitter represents the Mesh or position we are attaching the particle system to.
  14138. */
  14139. emitter: Nullable<AbstractMesh | Vector3>;
  14140. /**
  14141. * The maximum number of particles to emit per frame
  14142. */
  14143. emitRate: number;
  14144. /**
  14145. * If you want to launch only a few particles at once, that can be done, as well.
  14146. */
  14147. manualEmitCount: number;
  14148. /**
  14149. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14150. */
  14151. updateSpeed: number;
  14152. /**
  14153. * The amount of time the particle system is running (depends of the overall update speed).
  14154. */
  14155. targetStopDuration: number;
  14156. /**
  14157. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14158. */
  14159. disposeOnStop: boolean;
  14160. /**
  14161. * Minimum power of emitting particles.
  14162. */
  14163. minEmitPower: number;
  14164. /**
  14165. * Maximum power of emitting particles.
  14166. */
  14167. maxEmitPower: number;
  14168. /**
  14169. * Minimum life time of emitting particles.
  14170. */
  14171. minLifeTime: number;
  14172. /**
  14173. * Maximum life time of emitting particles.
  14174. */
  14175. maxLifeTime: number;
  14176. /**
  14177. * Minimum Size of emitting particles.
  14178. */
  14179. minSize: number;
  14180. /**
  14181. * Maximum Size of emitting particles.
  14182. */
  14183. maxSize: number;
  14184. /**
  14185. * Minimum scale of emitting particles on X axis.
  14186. */
  14187. minScaleX: number;
  14188. /**
  14189. * Maximum scale of emitting particles on X axis.
  14190. */
  14191. maxScaleX: number;
  14192. /**
  14193. * Minimum scale of emitting particles on Y axis.
  14194. */
  14195. minScaleY: number;
  14196. /**
  14197. * Maximum scale of emitting particles on Y axis.
  14198. */
  14199. maxScaleY: number;
  14200. /**
  14201. * Gets or sets the minimal initial rotation in radians.
  14202. */
  14203. minInitialRotation: number;
  14204. /**
  14205. * Gets or sets the maximal initial rotation in radians.
  14206. */
  14207. maxInitialRotation: number;
  14208. /**
  14209. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14210. */
  14211. minAngularSpeed: number;
  14212. /**
  14213. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14214. */
  14215. maxAngularSpeed: number;
  14216. /**
  14217. * The texture used to render each particle. (this can be a spritesheet)
  14218. */
  14219. particleTexture: Nullable<Texture>;
  14220. /**
  14221. * The layer mask we are rendering the particles through.
  14222. */
  14223. layerMask: number;
  14224. /**
  14225. * This can help using your own shader to render the particle system.
  14226. * The according effect will be created
  14227. */
  14228. customShader: any;
  14229. /**
  14230. * By default particle system starts as soon as they are created. This prevents the
  14231. * automatic start to happen and let you decide when to start emitting particles.
  14232. */
  14233. preventAutoStart: boolean;
  14234. private _noiseTexture;
  14235. /**
  14236. * Gets or sets a texture used to add random noise to particle positions
  14237. */
  14238. noiseTexture: Nullable<ProceduralTexture>;
  14239. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14240. noiseStrength: Vector3;
  14241. /**
  14242. * Callback triggered when the particle animation is ending.
  14243. */
  14244. onAnimationEnd: Nullable<() => void>;
  14245. /**
  14246. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14247. */
  14248. blendMode: number;
  14249. /**
  14250. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14251. * to override the particles.
  14252. */
  14253. forceDepthWrite: boolean;
  14254. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  14255. preWarmCycles: number;
  14256. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14257. preWarmStepOffset: number;
  14258. /**
  14259. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14260. */
  14261. spriteCellChangeSpeed: number;
  14262. /**
  14263. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14264. */
  14265. startSpriteCellID: number;
  14266. /**
  14267. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14268. */
  14269. endSpriteCellID: number;
  14270. /**
  14271. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14272. */
  14273. spriteCellWidth: number;
  14274. /**
  14275. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14276. */
  14277. spriteCellHeight: number;
  14278. /**
  14279. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14280. */
  14281. spriteRandomStartCell: boolean;
  14282. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14283. translationPivot: Vector2;
  14284. /** @hidden */
  14285. protected _isAnimationSheetEnabled: boolean;
  14286. /**
  14287. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14288. */
  14289. beginAnimationOnStart: boolean;
  14290. /**
  14291. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14292. */
  14293. beginAnimationFrom: number;
  14294. /**
  14295. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14296. */
  14297. beginAnimationTo: number;
  14298. /**
  14299. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14300. */
  14301. beginAnimationLoop: boolean;
  14302. /**
  14303. * Gets or sets a world offset applied to all particles
  14304. */
  14305. worldOffset: Vector3;
  14306. /**
  14307. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14308. */
  14309. isAnimationSheetEnabled: boolean;
  14310. /**
  14311. * Get hosting scene
  14312. * @returns the scene
  14313. */
  14314. getScene(): Scene;
  14315. /**
  14316. * You can use gravity if you want to give an orientation to your particles.
  14317. */
  14318. gravity: Vector3;
  14319. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14320. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14321. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14322. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14323. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14324. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14325. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14326. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14327. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14328. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14329. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14330. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14331. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14332. /**
  14333. * Defines the delay in milliseconds before starting the system (0 by default)
  14334. */
  14335. startDelay: number;
  14336. /**
  14337. * Gets the current list of drag gradients.
  14338. * You must use addDragGradient and removeDragGradient to udpate this list
  14339. * @returns the list of drag gradients
  14340. */
  14341. getDragGradients(): Nullable<Array<FactorGradient>>;
  14342. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14343. limitVelocityDamping: number;
  14344. /**
  14345. * Gets the current list of limit velocity gradients.
  14346. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14347. * @returns the list of limit velocity gradients
  14348. */
  14349. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14350. /**
  14351. * Gets the current list of color gradients.
  14352. * You must use addColorGradient and removeColorGradient to udpate this list
  14353. * @returns the list of color gradients
  14354. */
  14355. getColorGradients(): Nullable<Array<ColorGradient>>;
  14356. /**
  14357. * Gets the current list of size gradients.
  14358. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14359. * @returns the list of size gradients
  14360. */
  14361. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of color remap gradients.
  14364. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14365. * @returns the list of color remap gradients
  14366. */
  14367. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Gets the current list of alpha remap gradients.
  14370. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14371. * @returns the list of alpha remap gradients
  14372. */
  14373. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of life time gradients.
  14376. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14377. * @returns the list of life time gradients
  14378. */
  14379. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Gets the current list of angular speed gradients.
  14382. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14383. * @returns the list of angular speed gradients
  14384. */
  14385. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Gets the current list of velocity gradients.
  14388. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14389. * @returns the list of velocity gradients
  14390. */
  14391. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Gets the current list of start size gradients.
  14394. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14395. * @returns the list of start size gradients
  14396. */
  14397. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14398. /**
  14399. * Gets the current list of emit rate gradients.
  14400. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14401. * @returns the list of emit rate gradients
  14402. */
  14403. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14406. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14407. */
  14408. direction1: Vector3;
  14409. /**
  14410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14411. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14412. */
  14413. direction2: Vector3;
  14414. /**
  14415. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14416. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14417. */
  14418. minEmitBox: Vector3;
  14419. /**
  14420. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14421. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14422. */
  14423. maxEmitBox: Vector3;
  14424. /**
  14425. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14426. */
  14427. color1: Color4;
  14428. /**
  14429. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14430. */
  14431. color2: Color4;
  14432. /**
  14433. * Color the particle will have at the end of its lifetime
  14434. */
  14435. colorDead: Color4;
  14436. /**
  14437. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14438. */
  14439. textureMask: Color4;
  14440. /**
  14441. * The particle emitter type defines the emitter used by the particle system.
  14442. * It can be for example box, sphere, or cone...
  14443. */
  14444. particleEmitterType: IParticleEmitterType;
  14445. /** @hidden */
  14446. _isSubEmitter: boolean;
  14447. /**
  14448. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14449. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14450. */
  14451. billboardMode: number;
  14452. protected _isBillboardBased: boolean;
  14453. /**
  14454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14455. */
  14456. isBillboardBased: boolean;
  14457. /**
  14458. * The scene the particle system belongs to.
  14459. */
  14460. protected _scene: Scene;
  14461. /**
  14462. * Local cache of defines for image processing.
  14463. */
  14464. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14465. /**
  14466. * Default configuration related to image processing available in the standard Material.
  14467. */
  14468. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14469. /**
  14470. * Gets the image processing configuration used either in this material.
  14471. */
  14472. /**
  14473. * Sets the Default image processing configuration used either in the this material.
  14474. *
  14475. * If sets to null, the scene one is in use.
  14476. */
  14477. imageProcessingConfiguration: ImageProcessingConfiguration;
  14478. /**
  14479. * Attaches a new image processing configuration to the Standard Material.
  14480. * @param configuration
  14481. */
  14482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14483. /** @hidden */
  14484. protected _reset(): void;
  14485. /** @hidden */
  14486. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14487. /**
  14488. * Instantiates a particle system.
  14489. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14490. * @param name The name of the particle system
  14491. */
  14492. constructor(name: string);
  14493. /**
  14494. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14497. * @returns the emitter
  14498. */
  14499. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14500. /**
  14501. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14502. * @param radius The radius of the hemisphere to emit from
  14503. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14504. * @returns the emitter
  14505. */
  14506. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14507. /**
  14508. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14509. * @param radius The radius of the sphere to emit from
  14510. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14511. * @returns the emitter
  14512. */
  14513. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14514. /**
  14515. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14516. * @param radius The radius of the sphere to emit from
  14517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14519. * @returns the emitter
  14520. */
  14521. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14522. /**
  14523. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14524. * @param radius The radius of the emission cylinder
  14525. * @param height The height of the emission cylinder
  14526. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14527. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14528. * @returns the emitter
  14529. */
  14530. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14531. /**
  14532. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14533. * @param radius The radius of the cylinder to emit from
  14534. * @param height The height of the emission cylinder
  14535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14538. * @returns the emitter
  14539. */
  14540. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14541. /**
  14542. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14543. * @param radius The radius of the cone to emit from
  14544. * @param angle The base angle of the cone
  14545. * @returns the emitter
  14546. */
  14547. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14548. /**
  14549. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14552. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14553. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14554. * @returns the emitter
  14555. */
  14556. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14557. }
  14558. }
  14559. declare module BABYLON {
  14560. /**
  14561. * Type of sub emitter
  14562. */
  14563. export enum SubEmitterType {
  14564. /**
  14565. * Attached to the particle over it's lifetime
  14566. */
  14567. ATTACHED = 0,
  14568. /**
  14569. * Created when the particle dies
  14570. */
  14571. END = 1
  14572. }
  14573. /**
  14574. * Sub emitter class used to emit particles from an existing particle
  14575. */
  14576. export class SubEmitter {
  14577. /**
  14578. * the particle system to be used by the sub emitter
  14579. */
  14580. particleSystem: ParticleSystem;
  14581. /**
  14582. * Type of the submitter (Default: END)
  14583. */
  14584. type: SubEmitterType;
  14585. /**
  14586. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  14587. * Note: This only is supported when using an emitter of type Mesh
  14588. */
  14589. inheritDirection: boolean;
  14590. /**
  14591. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14592. */
  14593. inheritedVelocityAmount: number;
  14594. /**
  14595. * Creates a sub emitter
  14596. * @param particleSystem the particle system to be used by the sub emitter
  14597. */
  14598. constructor(
  14599. /**
  14600. * the particle system to be used by the sub emitter
  14601. */
  14602. particleSystem: ParticleSystem);
  14603. /**
  14604. * Clones the sub emitter
  14605. * @returns the cloned sub emitter
  14606. */
  14607. clone(): SubEmitter;
  14608. /**
  14609. * Serialize current object to a JSON object
  14610. * @returns the serialized object
  14611. */
  14612. serialize(): any;
  14613. /** @hidden */
  14614. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14615. /**
  14616. * Creates a new SubEmitter from a serialized JSON version
  14617. * @param serializationObject defines the JSON object to read from
  14618. * @param scene defines the hosting scene
  14619. * @param rootUrl defines the rootUrl for data loading
  14620. * @returns a new SubEmitter
  14621. */
  14622. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14623. /** Release associated resources */
  14624. dispose(): void;
  14625. }
  14626. }
  14627. declare module BABYLON {
  14628. /** @hidden */
  14629. export var clipPlaneFragmentDeclaration: {
  14630. name: string;
  14631. shader: string;
  14632. };
  14633. }
  14634. declare module BABYLON {
  14635. /** @hidden */
  14636. export var imageProcessingDeclaration: {
  14637. name: string;
  14638. shader: string;
  14639. };
  14640. }
  14641. declare module BABYLON {
  14642. /** @hidden */
  14643. export var imageProcessingFunctions: {
  14644. name: string;
  14645. shader: string;
  14646. };
  14647. }
  14648. declare module BABYLON {
  14649. /** @hidden */
  14650. export var clipPlaneFragment: {
  14651. name: string;
  14652. shader: string;
  14653. };
  14654. }
  14655. declare module BABYLON {
  14656. /** @hidden */
  14657. export var particlesPixelShader: {
  14658. name: string;
  14659. shader: string;
  14660. };
  14661. }
  14662. declare module BABYLON {
  14663. /** @hidden */
  14664. export var clipPlaneVertexDeclaration: {
  14665. name: string;
  14666. shader: string;
  14667. };
  14668. }
  14669. declare module BABYLON {
  14670. /** @hidden */
  14671. export var clipPlaneVertex: {
  14672. name: string;
  14673. shader: string;
  14674. };
  14675. }
  14676. declare module BABYLON {
  14677. /** @hidden */
  14678. export var particlesVertexShader: {
  14679. name: string;
  14680. shader: string;
  14681. };
  14682. }
  14683. declare module BABYLON {
  14684. /**
  14685. * This represents a particle system in Babylon.
  14686. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14687. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14688. * @example https://doc.babylonjs.com/babylon101/particles
  14689. */
  14690. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14691. /**
  14692. * Billboard mode will only apply to Y axis
  14693. */
  14694. static readonly BILLBOARDMODE_Y: number;
  14695. /**
  14696. * Billboard mode will apply to all axes
  14697. */
  14698. static readonly BILLBOARDMODE_ALL: number;
  14699. /**
  14700. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14701. */
  14702. static readonly BILLBOARDMODE_STRETCHED: number;
  14703. /**
  14704. * This function can be defined to provide custom update for active particles.
  14705. * This function will be called instead of regular update (age, position, color, etc.).
  14706. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14707. */
  14708. updateFunction: (particles: Particle[]) => void;
  14709. private _emitterWorldMatrix;
  14710. /**
  14711. * This function can be defined to specify initial direction for every new particle.
  14712. * It by default use the emitterType defined function
  14713. */
  14714. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14715. /**
  14716. * This function can be defined to specify initial position for every new particle.
  14717. * It by default use the emitterType defined function
  14718. */
  14719. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14720. /**
  14721. * @hidden
  14722. */
  14723. _inheritedVelocityOffset: Vector3;
  14724. /**
  14725. * An event triggered when the system is disposed
  14726. */
  14727. onDisposeObservable: Observable<ParticleSystem>;
  14728. private _onDisposeObserver;
  14729. /**
  14730. * Sets a callback that will be triggered when the system is disposed
  14731. */
  14732. onDispose: () => void;
  14733. private _particles;
  14734. private _epsilon;
  14735. private _capacity;
  14736. private _stockParticles;
  14737. private _newPartsExcess;
  14738. private _vertexData;
  14739. private _vertexBuffer;
  14740. private _vertexBuffers;
  14741. private _spriteBuffer;
  14742. private _indexBuffer;
  14743. private _effect;
  14744. private _customEffect;
  14745. private _cachedDefines;
  14746. private _scaledColorStep;
  14747. private _colorDiff;
  14748. private _scaledDirection;
  14749. private _scaledGravity;
  14750. private _currentRenderId;
  14751. private _alive;
  14752. private _useInstancing;
  14753. private _started;
  14754. private _stopped;
  14755. private _actualFrame;
  14756. private _scaledUpdateSpeed;
  14757. private _vertexBufferSize;
  14758. /** @hidden */
  14759. _currentEmitRateGradient: Nullable<FactorGradient>;
  14760. /** @hidden */
  14761. _currentEmitRate1: number;
  14762. /** @hidden */
  14763. _currentEmitRate2: number;
  14764. /** @hidden */
  14765. _currentStartSizeGradient: Nullable<FactorGradient>;
  14766. /** @hidden */
  14767. _currentStartSize1: number;
  14768. /** @hidden */
  14769. _currentStartSize2: number;
  14770. private readonly _rawTextureWidth;
  14771. private _rampGradientsTexture;
  14772. private _useRampGradients;
  14773. /** Gets or sets a boolean indicating that ramp gradients must be used
  14774. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14775. */
  14776. useRampGradients: boolean;
  14777. /**
  14778. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  14779. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  14780. */
  14781. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14782. private _subEmitters;
  14783. /**
  14784. * @hidden
  14785. * If the particle systems emitter should be disposed when the particle system is disposed
  14786. */
  14787. _disposeEmitterOnDispose: boolean;
  14788. /**
  14789. * The current active Sub-systems, this property is used by the root particle system only.
  14790. */
  14791. activeSubSystems: Array<ParticleSystem>;
  14792. private _rootParticleSystem;
  14793. /**
  14794. * Gets the current list of active particles
  14795. */
  14796. readonly particles: Particle[];
  14797. /**
  14798. * Returns the string "ParticleSystem"
  14799. * @returns a string containing the class name
  14800. */
  14801. getClassName(): string;
  14802. /**
  14803. * Instantiates a particle system.
  14804. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14805. * @param name The name of the particle system
  14806. * @param capacity The max number of particles alive at the same time
  14807. * @param scene The scene the particle system belongs to
  14808. * @param customEffect a custom effect used to change the way particles are rendered by default
  14809. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14810. * @param epsilon Offset used to render the particles
  14811. */
  14812. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14813. private _addFactorGradient;
  14814. private _removeFactorGradient;
  14815. /**
  14816. * Adds a new life time gradient
  14817. * @param gradient defines the gradient to use (between 0 and 1)
  14818. * @param factor defines the life time factor to affect to the specified gradient
  14819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14820. * @returns the current particle system
  14821. */
  14822. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14823. /**
  14824. * Remove a specific life time gradient
  14825. * @param gradient defines the gradient to remove
  14826. * @returns the current particle system
  14827. */
  14828. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14829. /**
  14830. * Adds a new size gradient
  14831. * @param gradient defines the gradient to use (between 0 and 1)
  14832. * @param factor defines the size factor to affect to the specified gradient
  14833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14834. * @returns the current particle system
  14835. */
  14836. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14837. /**
  14838. * Remove a specific size gradient
  14839. * @param gradient defines the gradient to remove
  14840. * @returns the current particle system
  14841. */
  14842. removeSizeGradient(gradient: number): IParticleSystem;
  14843. /**
  14844. * Adds a new color remap gradient
  14845. * @param gradient defines the gradient to use (between 0 and 1)
  14846. * @param min defines the color remap minimal range
  14847. * @param max defines the color remap maximal range
  14848. * @returns the current particle system
  14849. */
  14850. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14851. /**
  14852. * Remove a specific color remap gradient
  14853. * @param gradient defines the gradient to remove
  14854. * @returns the current particle system
  14855. */
  14856. removeColorRemapGradient(gradient: number): IParticleSystem;
  14857. /**
  14858. * Adds a new alpha remap gradient
  14859. * @param gradient defines the gradient to use (between 0 and 1)
  14860. * @param min defines the alpha remap minimal range
  14861. * @param max defines the alpha remap maximal range
  14862. * @returns the current particle system
  14863. */
  14864. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14865. /**
  14866. * Remove a specific alpha remap gradient
  14867. * @param gradient defines the gradient to remove
  14868. * @returns the current particle system
  14869. */
  14870. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14871. /**
  14872. * Adds a new angular speed gradient
  14873. * @param gradient defines the gradient to use (between 0 and 1)
  14874. * @param factor defines the angular speed to affect to the specified gradient
  14875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14876. * @returns the current particle system
  14877. */
  14878. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14879. /**
  14880. * Remove a specific angular speed gradient
  14881. * @param gradient defines the gradient to remove
  14882. * @returns the current particle system
  14883. */
  14884. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14885. /**
  14886. * Adds a new velocity gradient
  14887. * @param gradient defines the gradient to use (between 0 and 1)
  14888. * @param factor defines the velocity to affect to the specified gradient
  14889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14890. * @returns the current particle system
  14891. */
  14892. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14893. /**
  14894. * Remove a specific velocity gradient
  14895. * @param gradient defines the gradient to remove
  14896. * @returns the current particle system
  14897. */
  14898. removeVelocityGradient(gradient: number): IParticleSystem;
  14899. /**
  14900. * Adds a new limit velocity gradient
  14901. * @param gradient defines the gradient to use (between 0 and 1)
  14902. * @param factor defines the limit velocity value to affect to the specified gradient
  14903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14904. * @returns the current particle system
  14905. */
  14906. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14907. /**
  14908. * Remove a specific limit velocity gradient
  14909. * @param gradient defines the gradient to remove
  14910. * @returns the current particle system
  14911. */
  14912. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14913. /**
  14914. * Adds a new drag gradient
  14915. * @param gradient defines the gradient to use (between 0 and 1)
  14916. * @param factor defines the drag value to affect to the specified gradient
  14917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14918. * @returns the current particle system
  14919. */
  14920. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14921. /**
  14922. * Remove a specific drag gradient
  14923. * @param gradient defines the gradient to remove
  14924. * @returns the current particle system
  14925. */
  14926. removeDragGradient(gradient: number): IParticleSystem;
  14927. /**
  14928. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14929. * @param gradient defines the gradient to use (between 0 and 1)
  14930. * @param factor defines the emit rate value to affect to the specified gradient
  14931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14932. * @returns the current particle system
  14933. */
  14934. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14935. /**
  14936. * Remove a specific emit rate gradient
  14937. * @param gradient defines the gradient to remove
  14938. * @returns the current particle system
  14939. */
  14940. removeEmitRateGradient(gradient: number): IParticleSystem;
  14941. /**
  14942. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14943. * @param gradient defines the gradient to use (between 0 and 1)
  14944. * @param factor defines the start size value to affect to the specified gradient
  14945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14946. * @returns the current particle system
  14947. */
  14948. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14949. /**
  14950. * Remove a specific start size gradient
  14951. * @param gradient defines the gradient to remove
  14952. * @returns the current particle system
  14953. */
  14954. removeStartSizeGradient(gradient: number): IParticleSystem;
  14955. private _createRampGradientTexture;
  14956. /**
  14957. * Gets the current list of ramp gradients.
  14958. * You must use addRampGradient and removeRampGradient to udpate this list
  14959. * @returns the list of ramp gradients
  14960. */
  14961. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14962. /**
  14963. * Adds a new ramp gradient used to remap particle colors
  14964. * @param gradient defines the gradient to use (between 0 and 1)
  14965. * @param color defines the color to affect to the specified gradient
  14966. * @returns the current particle system
  14967. */
  14968. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14969. /**
  14970. * Remove a specific ramp gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeRampGradient(gradient: number): ParticleSystem;
  14975. /**
  14976. * Adds a new color gradient
  14977. * @param gradient defines the gradient to use (between 0 and 1)
  14978. * @param color1 defines the color to affect to the specified gradient
  14979. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14980. * @returns this particle system
  14981. */
  14982. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14983. /**
  14984. * Remove a specific color gradient
  14985. * @param gradient defines the gradient to remove
  14986. * @returns this particle system
  14987. */
  14988. removeColorGradient(gradient: number): IParticleSystem;
  14989. private _fetchR;
  14990. protected _reset(): void;
  14991. private _resetEffect;
  14992. private _createVertexBuffers;
  14993. private _createIndexBuffer;
  14994. /**
  14995. * Gets the maximum number of particles active at the same time.
  14996. * @returns The max number of active particles.
  14997. */
  14998. getCapacity(): number;
  14999. /**
  15000. * Gets whether there are still active particles in the system.
  15001. * @returns True if it is alive, otherwise false.
  15002. */
  15003. isAlive(): boolean;
  15004. /**
  15005. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15006. * @returns True if it has been started, otherwise false.
  15007. */
  15008. isStarted(): boolean;
  15009. private _prepareSubEmitterInternalArray;
  15010. /**
  15011. * Starts the particle system and begins to emit
  15012. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15013. */
  15014. start(delay?: number): void;
  15015. /**
  15016. * Stops the particle system.
  15017. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15018. */
  15019. stop(stopSubEmitters?: boolean): void;
  15020. /**
  15021. * Remove all active particles
  15022. */
  15023. reset(): void;
  15024. /**
  15025. * @hidden (for internal use only)
  15026. */
  15027. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15028. /**
  15029. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15030. * Its lifetime will start back at 0.
  15031. */
  15032. recycleParticle: (particle: Particle) => void;
  15033. private _stopSubEmitters;
  15034. private _createParticle;
  15035. private _removeFromRoot;
  15036. private _emitFromParticle;
  15037. private _update;
  15038. /** @hidden */
  15039. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15040. /** @hidden */
  15041. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15042. /** @hidden */
  15043. private _getEffect;
  15044. /**
  15045. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15046. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15047. */
  15048. animate(preWarmOnly?: boolean): void;
  15049. private _appendParticleVertices;
  15050. /**
  15051. * Rebuilds the particle system.
  15052. */
  15053. rebuild(): void;
  15054. /**
  15055. * Is this system ready to be used/rendered
  15056. * @return true if the system is ready
  15057. */
  15058. isReady(): boolean;
  15059. private _render;
  15060. /**
  15061. * Renders the particle system in its current state.
  15062. * @returns the current number of particles
  15063. */
  15064. render(): number;
  15065. /**
  15066. * Disposes the particle system and free the associated resources
  15067. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15068. */
  15069. dispose(disposeTexture?: boolean): void;
  15070. /**
  15071. * Clones the particle system.
  15072. * @param name The name of the cloned object
  15073. * @param newEmitter The new emitter to use
  15074. * @returns the cloned particle system
  15075. */
  15076. clone(name: string, newEmitter: any): ParticleSystem;
  15077. /**
  15078. * Serializes the particle system to a JSON object.
  15079. * @returns the JSON object
  15080. */
  15081. serialize(): any;
  15082. /** @hidden */
  15083. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15084. /** @hidden */
  15085. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15086. /**
  15087. * Parses a JSON object to create a particle system.
  15088. * @param parsedParticleSystem The JSON object to parse
  15089. * @param scene The scene to create the particle system in
  15090. * @param rootUrl The root url to use to load external dependencies like texture
  15091. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15092. * @returns the Parsed particle system
  15093. */
  15094. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15095. }
  15096. }
  15097. declare module BABYLON {
  15098. /**
  15099. * A particle represents one of the element emitted by a particle system.
  15100. * This is mainly define by its coordinates, direction, velocity and age.
  15101. */
  15102. export class Particle {
  15103. /**
  15104. * The particle system the particle belongs to.
  15105. */
  15106. particleSystem: ParticleSystem;
  15107. private static _Count;
  15108. /**
  15109. * Unique ID of the particle
  15110. */
  15111. id: number;
  15112. /**
  15113. * The world position of the particle in the scene.
  15114. */
  15115. position: Vector3;
  15116. /**
  15117. * The world direction of the particle in the scene.
  15118. */
  15119. direction: Vector3;
  15120. /**
  15121. * The color of the particle.
  15122. */
  15123. color: Color4;
  15124. /**
  15125. * The color change of the particle per step.
  15126. */
  15127. colorStep: Color4;
  15128. /**
  15129. * Defines how long will the life of the particle be.
  15130. */
  15131. lifeTime: number;
  15132. /**
  15133. * The current age of the particle.
  15134. */
  15135. age: number;
  15136. /**
  15137. * The current size of the particle.
  15138. */
  15139. size: number;
  15140. /**
  15141. * The current scale of the particle.
  15142. */
  15143. scale: Vector2;
  15144. /**
  15145. * The current angle of the particle.
  15146. */
  15147. angle: number;
  15148. /**
  15149. * Defines how fast is the angle changing.
  15150. */
  15151. angularSpeed: number;
  15152. /**
  15153. * Defines the cell index used by the particle to be rendered from a sprite.
  15154. */
  15155. cellIndex: number;
  15156. /**
  15157. * The information required to support color remapping
  15158. */
  15159. remapData: Vector4;
  15160. /** @hidden */
  15161. _randomCellOffset?: number;
  15162. /** @hidden */
  15163. _initialDirection: Nullable<Vector3>;
  15164. /** @hidden */
  15165. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15166. /** @hidden */
  15167. _initialStartSpriteCellID: number;
  15168. /** @hidden */
  15169. _initialEndSpriteCellID: number;
  15170. /** @hidden */
  15171. _currentColorGradient: Nullable<ColorGradient>;
  15172. /** @hidden */
  15173. _currentColor1: Color4;
  15174. /** @hidden */
  15175. _currentColor2: Color4;
  15176. /** @hidden */
  15177. _currentSizeGradient: Nullable<FactorGradient>;
  15178. /** @hidden */
  15179. _currentSize1: number;
  15180. /** @hidden */
  15181. _currentSize2: number;
  15182. /** @hidden */
  15183. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15184. /** @hidden */
  15185. _currentAngularSpeed1: number;
  15186. /** @hidden */
  15187. _currentAngularSpeed2: number;
  15188. /** @hidden */
  15189. _currentVelocityGradient: Nullable<FactorGradient>;
  15190. /** @hidden */
  15191. _currentVelocity1: number;
  15192. /** @hidden */
  15193. _currentVelocity2: number;
  15194. /** @hidden */
  15195. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15196. /** @hidden */
  15197. _currentLimitVelocity1: number;
  15198. /** @hidden */
  15199. _currentLimitVelocity2: number;
  15200. /** @hidden */
  15201. _currentDragGradient: Nullable<FactorGradient>;
  15202. /** @hidden */
  15203. _currentDrag1: number;
  15204. /** @hidden */
  15205. _currentDrag2: number;
  15206. /** @hidden */
  15207. _randomNoiseCoordinates1: Vector3;
  15208. /** @hidden */
  15209. _randomNoiseCoordinates2: Vector3;
  15210. /**
  15211. * Creates a new instance Particle
  15212. * @param particleSystem the particle system the particle belongs to
  15213. */
  15214. constructor(
  15215. /**
  15216. * The particle system the particle belongs to.
  15217. */
  15218. particleSystem: ParticleSystem);
  15219. private updateCellInfoFromSystem;
  15220. /**
  15221. * Defines how the sprite cell index is updated for the particle
  15222. */
  15223. updateCellIndex(): void;
  15224. /** @hidden */
  15225. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15226. /** @hidden */
  15227. _inheritParticleInfoToSubEmitters(): void;
  15228. /** @hidden */
  15229. _reset(): void;
  15230. /**
  15231. * Copy the properties of particle to another one.
  15232. * @param other the particle to copy the information to.
  15233. */
  15234. copyTo(other: Particle): void;
  15235. }
  15236. }
  15237. declare module BABYLON {
  15238. /**
  15239. * Particle emitter represents a volume emitting particles.
  15240. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15241. */
  15242. export interface IParticleEmitterType {
  15243. /**
  15244. * Called by the particle System when the direction is computed for the created particle.
  15245. * @param worldMatrix is the world matrix of the particle system
  15246. * @param directionToUpdate is the direction vector to update with the result
  15247. * @param particle is the particle we are computed the direction for
  15248. */
  15249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15250. /**
  15251. * Called by the particle System when the position is computed for the created particle.
  15252. * @param worldMatrix is the world matrix of the particle system
  15253. * @param positionToUpdate is the position vector to update with the result
  15254. * @param particle is the particle we are computed the position for
  15255. */
  15256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15257. /**
  15258. * Clones the current emitter and returns a copy of it
  15259. * @returns the new emitter
  15260. */
  15261. clone(): IParticleEmitterType;
  15262. /**
  15263. * Called by the GPUParticleSystem to setup the update shader
  15264. * @param effect defines the update shader
  15265. */
  15266. applyToShader(effect: Effect): void;
  15267. /**
  15268. * Returns a string to use to update the GPU particles update shader
  15269. * @returns the effect defines string
  15270. */
  15271. getEffectDefines(): string;
  15272. /**
  15273. * Returns a string representing the class name
  15274. * @returns a string containing the class name
  15275. */
  15276. getClassName(): string;
  15277. /**
  15278. * Serializes the particle system to a JSON object.
  15279. * @returns the JSON object
  15280. */
  15281. serialize(): any;
  15282. /**
  15283. * Parse properties from a JSON object
  15284. * @param serializationObject defines the JSON object
  15285. */
  15286. parse(serializationObject: any): void;
  15287. }
  15288. }
  15289. declare module BABYLON {
  15290. /**
  15291. * Particle emitter emitting particles from the inside of a box.
  15292. * It emits the particles randomly between 2 given directions.
  15293. */
  15294. export class BoxParticleEmitter implements IParticleEmitterType {
  15295. /**
  15296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15297. */
  15298. direction1: Vector3;
  15299. /**
  15300. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15301. */
  15302. direction2: Vector3;
  15303. /**
  15304. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15305. */
  15306. minEmitBox: Vector3;
  15307. /**
  15308. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15309. */
  15310. maxEmitBox: Vector3;
  15311. /**
  15312. * Creates a new instance BoxParticleEmitter
  15313. */
  15314. constructor();
  15315. /**
  15316. * Called by the particle System when the direction is computed for the created particle.
  15317. * @param worldMatrix is the world matrix of the particle system
  15318. * @param directionToUpdate is the direction vector to update with the result
  15319. * @param particle is the particle we are computed the direction for
  15320. */
  15321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15322. /**
  15323. * Called by the particle System when the position is computed for the created particle.
  15324. * @param worldMatrix is the world matrix of the particle system
  15325. * @param positionToUpdate is the position vector to update with the result
  15326. * @param particle is the particle we are computed the position for
  15327. */
  15328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15329. /**
  15330. * Clones the current emitter and returns a copy of it
  15331. * @returns the new emitter
  15332. */
  15333. clone(): BoxParticleEmitter;
  15334. /**
  15335. * Called by the GPUParticleSystem to setup the update shader
  15336. * @param effect defines the update shader
  15337. */
  15338. applyToShader(effect: Effect): void;
  15339. /**
  15340. * Returns a string to use to update the GPU particles update shader
  15341. * @returns a string containng the defines string
  15342. */
  15343. getEffectDefines(): string;
  15344. /**
  15345. * Returns the string "BoxParticleEmitter"
  15346. * @returns a string containing the class name
  15347. */
  15348. getClassName(): string;
  15349. /**
  15350. * Serializes the particle system to a JSON object.
  15351. * @returns the JSON object
  15352. */
  15353. serialize(): any;
  15354. /**
  15355. * Parse properties from a JSON object
  15356. * @param serializationObject defines the JSON object
  15357. */
  15358. parse(serializationObject: any): void;
  15359. }
  15360. }
  15361. declare module BABYLON {
  15362. /**
  15363. * Particle emitter emitting particles from the inside of a cone.
  15364. * It emits the particles alongside the cone volume from the base to the particle.
  15365. * The emission direction might be randomized.
  15366. */
  15367. export class ConeParticleEmitter implements IParticleEmitterType {
  15368. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15369. directionRandomizer: number;
  15370. private _radius;
  15371. private _angle;
  15372. private _height;
  15373. /**
  15374. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15375. */
  15376. radiusRange: number;
  15377. /**
  15378. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15379. */
  15380. heightRange: number;
  15381. /**
  15382. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15383. */
  15384. emitFromSpawnPointOnly: boolean;
  15385. /**
  15386. * Gets or sets the radius of the emission cone
  15387. */
  15388. radius: number;
  15389. /**
  15390. * Gets or sets the angle of the emission cone
  15391. */
  15392. angle: number;
  15393. private _buildHeight;
  15394. /**
  15395. * Creates a new instance ConeParticleEmitter
  15396. * @param radius the radius of the emission cone (1 by default)
  15397. * @param angle the cone base angle (PI by default)
  15398. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15399. */
  15400. constructor(radius?: number, angle?: number,
  15401. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15402. directionRandomizer?: number);
  15403. /**
  15404. * Called by the particle System when the direction is computed for the created particle.
  15405. * @param worldMatrix is the world matrix of the particle system
  15406. * @param directionToUpdate is the direction vector to update with the result
  15407. * @param particle is the particle we are computed the direction for
  15408. */
  15409. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15410. /**
  15411. * Called by the particle System when the position is computed for the created particle.
  15412. * @param worldMatrix is the world matrix of the particle system
  15413. * @param positionToUpdate is the position vector to update with the result
  15414. * @param particle is the particle we are computed the position for
  15415. */
  15416. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15417. /**
  15418. * Clones the current emitter and returns a copy of it
  15419. * @returns the new emitter
  15420. */
  15421. clone(): ConeParticleEmitter;
  15422. /**
  15423. * Called by the GPUParticleSystem to setup the update shader
  15424. * @param effect defines the update shader
  15425. */
  15426. applyToShader(effect: Effect): void;
  15427. /**
  15428. * Returns a string to use to update the GPU particles update shader
  15429. * @returns a string containng the defines string
  15430. */
  15431. getEffectDefines(): string;
  15432. /**
  15433. * Returns the string "ConeParticleEmitter"
  15434. * @returns a string containing the class name
  15435. */
  15436. getClassName(): string;
  15437. /**
  15438. * Serializes the particle system to a JSON object.
  15439. * @returns the JSON object
  15440. */
  15441. serialize(): any;
  15442. /**
  15443. * Parse properties from a JSON object
  15444. * @param serializationObject defines the JSON object
  15445. */
  15446. parse(serializationObject: any): void;
  15447. }
  15448. }
  15449. declare module BABYLON {
  15450. /**
  15451. * Particle emitter emitting particles from the inside of a cylinder.
  15452. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15453. */
  15454. export class CylinderParticleEmitter implements IParticleEmitterType {
  15455. /**
  15456. * The radius of the emission cylinder.
  15457. */
  15458. radius: number;
  15459. /**
  15460. * The height of the emission cylinder.
  15461. */
  15462. height: number;
  15463. /**
  15464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15465. */
  15466. radiusRange: number;
  15467. /**
  15468. * How much to randomize the particle direction [0-1].
  15469. */
  15470. directionRandomizer: number;
  15471. /**
  15472. * Creates a new instance CylinderParticleEmitter
  15473. * @param radius the radius of the emission cylinder (1 by default)
  15474. * @param height the height of the emission cylinder (1 by default)
  15475. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15476. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15477. */
  15478. constructor(
  15479. /**
  15480. * The radius of the emission cylinder.
  15481. */
  15482. radius?: number,
  15483. /**
  15484. * The height of the emission cylinder.
  15485. */
  15486. height?: number,
  15487. /**
  15488. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15489. */
  15490. radiusRange?: number,
  15491. /**
  15492. * How much to randomize the particle direction [0-1].
  15493. */
  15494. directionRandomizer?: number);
  15495. /**
  15496. * Called by the particle System when the direction is computed for the created particle.
  15497. * @param worldMatrix is the world matrix of the particle system
  15498. * @param directionToUpdate is the direction vector to update with the result
  15499. * @param particle is the particle we are computed the direction for
  15500. */
  15501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15502. /**
  15503. * Called by the particle System when the position is computed for the created particle.
  15504. * @param worldMatrix is the world matrix of the particle system
  15505. * @param positionToUpdate is the position vector to update with the result
  15506. * @param particle is the particle we are computed the position for
  15507. */
  15508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15509. /**
  15510. * Clones the current emitter and returns a copy of it
  15511. * @returns the new emitter
  15512. */
  15513. clone(): CylinderParticleEmitter;
  15514. /**
  15515. * Called by the GPUParticleSystem to setup the update shader
  15516. * @param effect defines the update shader
  15517. */
  15518. applyToShader(effect: Effect): void;
  15519. /**
  15520. * Returns a string to use to update the GPU particles update shader
  15521. * @returns a string containng the defines string
  15522. */
  15523. getEffectDefines(): string;
  15524. /**
  15525. * Returns the string "CylinderParticleEmitter"
  15526. * @returns a string containing the class name
  15527. */
  15528. getClassName(): string;
  15529. /**
  15530. * Serializes the particle system to a JSON object.
  15531. * @returns the JSON object
  15532. */
  15533. serialize(): any;
  15534. /**
  15535. * Parse properties from a JSON object
  15536. * @param serializationObject defines the JSON object
  15537. */
  15538. parse(serializationObject: any): void;
  15539. }
  15540. /**
  15541. * Particle emitter emitting particles from the inside of a cylinder.
  15542. * It emits the particles randomly between two vectors.
  15543. */
  15544. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15545. /**
  15546. * The min limit of the emission direction.
  15547. */
  15548. direction1: Vector3;
  15549. /**
  15550. * The max limit of the emission direction.
  15551. */
  15552. direction2: Vector3;
  15553. /**
  15554. * Creates a new instance CylinderDirectedParticleEmitter
  15555. * @param radius the radius of the emission cylinder (1 by default)
  15556. * @param height the height of the emission cylinder (1 by default)
  15557. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15558. * @param direction1 the min limit of the emission direction (up vector by default)
  15559. * @param direction2 the max limit of the emission direction (up vector by default)
  15560. */
  15561. constructor(radius?: number, height?: number, radiusRange?: number,
  15562. /**
  15563. * The min limit of the emission direction.
  15564. */
  15565. direction1?: Vector3,
  15566. /**
  15567. * The max limit of the emission direction.
  15568. */
  15569. direction2?: Vector3);
  15570. /**
  15571. * Called by the particle System when the direction is computed for the created particle.
  15572. * @param worldMatrix is the world matrix of the particle system
  15573. * @param directionToUpdate is the direction vector to update with the result
  15574. * @param particle is the particle we are computed the direction for
  15575. */
  15576. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15577. /**
  15578. * Clones the current emitter and returns a copy of it
  15579. * @returns the new emitter
  15580. */
  15581. clone(): CylinderDirectedParticleEmitter;
  15582. /**
  15583. * Called by the GPUParticleSystem to setup the update shader
  15584. * @param effect defines the update shader
  15585. */
  15586. applyToShader(effect: Effect): void;
  15587. /**
  15588. * Returns a string to use to update the GPU particles update shader
  15589. * @returns a string containng the defines string
  15590. */
  15591. getEffectDefines(): string;
  15592. /**
  15593. * Returns the string "CylinderDirectedParticleEmitter"
  15594. * @returns a string containing the class name
  15595. */
  15596. getClassName(): string;
  15597. /**
  15598. * Serializes the particle system to a JSON object.
  15599. * @returns the JSON object
  15600. */
  15601. serialize(): any;
  15602. /**
  15603. * Parse properties from a JSON object
  15604. * @param serializationObject defines the JSON object
  15605. */
  15606. parse(serializationObject: any): void;
  15607. }
  15608. }
  15609. declare module BABYLON {
  15610. /**
  15611. * Particle emitter emitting particles from the inside of a hemisphere.
  15612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15613. */
  15614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15615. /**
  15616. * The radius of the emission hemisphere.
  15617. */
  15618. radius: number;
  15619. /**
  15620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15621. */
  15622. radiusRange: number;
  15623. /**
  15624. * How much to randomize the particle direction [0-1].
  15625. */
  15626. directionRandomizer: number;
  15627. /**
  15628. * Creates a new instance HemisphericParticleEmitter
  15629. * @param radius the radius of the emission hemisphere (1 by default)
  15630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15632. */
  15633. constructor(
  15634. /**
  15635. * The radius of the emission hemisphere.
  15636. */
  15637. radius?: number,
  15638. /**
  15639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15640. */
  15641. radiusRange?: number,
  15642. /**
  15643. * How much to randomize the particle direction [0-1].
  15644. */
  15645. directionRandomizer?: number);
  15646. /**
  15647. * Called by the particle System when the direction is computed for the created particle.
  15648. * @param worldMatrix is the world matrix of the particle system
  15649. * @param directionToUpdate is the direction vector to update with the result
  15650. * @param particle is the particle we are computed the direction for
  15651. */
  15652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15653. /**
  15654. * Called by the particle System when the position is computed for the created particle.
  15655. * @param worldMatrix is the world matrix of the particle system
  15656. * @param positionToUpdate is the position vector to update with the result
  15657. * @param particle is the particle we are computed the position for
  15658. */
  15659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15660. /**
  15661. * Clones the current emitter and returns a copy of it
  15662. * @returns the new emitter
  15663. */
  15664. clone(): HemisphericParticleEmitter;
  15665. /**
  15666. * Called by the GPUParticleSystem to setup the update shader
  15667. * @param effect defines the update shader
  15668. */
  15669. applyToShader(effect: Effect): void;
  15670. /**
  15671. * Returns a string to use to update the GPU particles update shader
  15672. * @returns a string containng the defines string
  15673. */
  15674. getEffectDefines(): string;
  15675. /**
  15676. * Returns the string "HemisphericParticleEmitter"
  15677. * @returns a string containing the class name
  15678. */
  15679. getClassName(): string;
  15680. /**
  15681. * Serializes the particle system to a JSON object.
  15682. * @returns the JSON object
  15683. */
  15684. serialize(): any;
  15685. /**
  15686. * Parse properties from a JSON object
  15687. * @param serializationObject defines the JSON object
  15688. */
  15689. parse(serializationObject: any): void;
  15690. }
  15691. }
  15692. declare module BABYLON {
  15693. /**
  15694. * Particle emitter emitting particles from a point.
  15695. * It emits the particles randomly between 2 given directions.
  15696. */
  15697. export class PointParticleEmitter implements IParticleEmitterType {
  15698. /**
  15699. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15700. */
  15701. direction1: Vector3;
  15702. /**
  15703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15704. */
  15705. direction2: Vector3;
  15706. /**
  15707. * Creates a new instance PointParticleEmitter
  15708. */
  15709. constructor();
  15710. /**
  15711. * Called by the particle System when the direction is computed for the created particle.
  15712. * @param worldMatrix is the world matrix of the particle system
  15713. * @param directionToUpdate is the direction vector to update with the result
  15714. * @param particle is the particle we are computed the direction for
  15715. */
  15716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15717. /**
  15718. * Called by the particle System when the position is computed for the created particle.
  15719. * @param worldMatrix is the world matrix of the particle system
  15720. * @param positionToUpdate is the position vector to update with the result
  15721. * @param particle is the particle we are computed the position for
  15722. */
  15723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15724. /**
  15725. * Clones the current emitter and returns a copy of it
  15726. * @returns the new emitter
  15727. */
  15728. clone(): PointParticleEmitter;
  15729. /**
  15730. * Called by the GPUParticleSystem to setup the update shader
  15731. * @param effect defines the update shader
  15732. */
  15733. applyToShader(effect: Effect): void;
  15734. /**
  15735. * Returns a string to use to update the GPU particles update shader
  15736. * @returns a string containng the defines string
  15737. */
  15738. getEffectDefines(): string;
  15739. /**
  15740. * Returns the string "PointParticleEmitter"
  15741. * @returns a string containing the class name
  15742. */
  15743. getClassName(): string;
  15744. /**
  15745. * Serializes the particle system to a JSON object.
  15746. * @returns the JSON object
  15747. */
  15748. serialize(): any;
  15749. /**
  15750. * Parse properties from a JSON object
  15751. * @param serializationObject defines the JSON object
  15752. */
  15753. parse(serializationObject: any): void;
  15754. }
  15755. }
  15756. declare module BABYLON {
  15757. /**
  15758. * Particle emitter emitting particles from the inside of a sphere.
  15759. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15760. */
  15761. export class SphereParticleEmitter implements IParticleEmitterType {
  15762. /**
  15763. * The radius of the emission sphere.
  15764. */
  15765. radius: number;
  15766. /**
  15767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15768. */
  15769. radiusRange: number;
  15770. /**
  15771. * How much to randomize the particle direction [0-1].
  15772. */
  15773. directionRandomizer: number;
  15774. /**
  15775. * Creates a new instance SphereParticleEmitter
  15776. * @param radius the radius of the emission sphere (1 by default)
  15777. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15778. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15779. */
  15780. constructor(
  15781. /**
  15782. * The radius of the emission sphere.
  15783. */
  15784. radius?: number,
  15785. /**
  15786. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15787. */
  15788. radiusRange?: number,
  15789. /**
  15790. * How much to randomize the particle direction [0-1].
  15791. */
  15792. directionRandomizer?: number);
  15793. /**
  15794. * Called by the particle System when the direction is computed for the created particle.
  15795. * @param worldMatrix is the world matrix of the particle system
  15796. * @param directionToUpdate is the direction vector to update with the result
  15797. * @param particle is the particle we are computed the direction for
  15798. */
  15799. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15800. /**
  15801. * Called by the particle System when the position is computed for the created particle.
  15802. * @param worldMatrix is the world matrix of the particle system
  15803. * @param positionToUpdate is the position vector to update with the result
  15804. * @param particle is the particle we are computed the position for
  15805. */
  15806. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15807. /**
  15808. * Clones the current emitter and returns a copy of it
  15809. * @returns the new emitter
  15810. */
  15811. clone(): SphereParticleEmitter;
  15812. /**
  15813. * Called by the GPUParticleSystem to setup the update shader
  15814. * @param effect defines the update shader
  15815. */
  15816. applyToShader(effect: Effect): void;
  15817. /**
  15818. * Returns a string to use to update the GPU particles update shader
  15819. * @returns a string containng the defines string
  15820. */
  15821. getEffectDefines(): string;
  15822. /**
  15823. * Returns the string "SphereParticleEmitter"
  15824. * @returns a string containing the class name
  15825. */
  15826. getClassName(): string;
  15827. /**
  15828. * Serializes the particle system to a JSON object.
  15829. * @returns the JSON object
  15830. */
  15831. serialize(): any;
  15832. /**
  15833. * Parse properties from a JSON object
  15834. * @param serializationObject defines the JSON object
  15835. */
  15836. parse(serializationObject: any): void;
  15837. }
  15838. /**
  15839. * Particle emitter emitting particles from the inside of a sphere.
  15840. * It emits the particles randomly between two vectors.
  15841. */
  15842. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15843. /**
  15844. * The min limit of the emission direction.
  15845. */
  15846. direction1: Vector3;
  15847. /**
  15848. * The max limit of the emission direction.
  15849. */
  15850. direction2: Vector3;
  15851. /**
  15852. * Creates a new instance SphereDirectedParticleEmitter
  15853. * @param radius the radius of the emission sphere (1 by default)
  15854. * @param direction1 the min limit of the emission direction (up vector by default)
  15855. * @param direction2 the max limit of the emission direction (up vector by default)
  15856. */
  15857. constructor(radius?: number,
  15858. /**
  15859. * The min limit of the emission direction.
  15860. */
  15861. direction1?: Vector3,
  15862. /**
  15863. * The max limit of the emission direction.
  15864. */
  15865. direction2?: Vector3);
  15866. /**
  15867. * Called by the particle System when the direction is computed for the created particle.
  15868. * @param worldMatrix is the world matrix of the particle system
  15869. * @param directionToUpdate is the direction vector to update with the result
  15870. * @param particle is the particle we are computed the direction for
  15871. */
  15872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15873. /**
  15874. * Clones the current emitter and returns a copy of it
  15875. * @returns the new emitter
  15876. */
  15877. clone(): SphereDirectedParticleEmitter;
  15878. /**
  15879. * Called by the GPUParticleSystem to setup the update shader
  15880. * @param effect defines the update shader
  15881. */
  15882. applyToShader(effect: Effect): void;
  15883. /**
  15884. * Returns a string to use to update the GPU particles update shader
  15885. * @returns a string containng the defines string
  15886. */
  15887. getEffectDefines(): string;
  15888. /**
  15889. * Returns the string "SphereDirectedParticleEmitter"
  15890. * @returns a string containing the class name
  15891. */
  15892. getClassName(): string;
  15893. /**
  15894. * Serializes the particle system to a JSON object.
  15895. * @returns the JSON object
  15896. */
  15897. serialize(): any;
  15898. /**
  15899. * Parse properties from a JSON object
  15900. * @param serializationObject defines the JSON object
  15901. */
  15902. parse(serializationObject: any): void;
  15903. }
  15904. }
  15905. declare module BABYLON {
  15906. /**
  15907. * Interface representing a particle system in Babylon.js.
  15908. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15909. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15910. */
  15911. export interface IParticleSystem {
  15912. /**
  15913. * List of animations used by the particle system.
  15914. */
  15915. animations: Animation[];
  15916. /**
  15917. * The id of the Particle system.
  15918. */
  15919. id: string;
  15920. /**
  15921. * The name of the Particle system.
  15922. */
  15923. name: string;
  15924. /**
  15925. * The emitter represents the Mesh or position we are attaching the particle system to.
  15926. */
  15927. emitter: Nullable<AbstractMesh | Vector3>;
  15928. /**
  15929. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15930. */
  15931. isBillboardBased: boolean;
  15932. /**
  15933. * The rendering group used by the Particle system to chose when to render.
  15934. */
  15935. renderingGroupId: number;
  15936. /**
  15937. * The layer mask we are rendering the particles through.
  15938. */
  15939. layerMask: number;
  15940. /**
  15941. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15942. */
  15943. updateSpeed: number;
  15944. /**
  15945. * The amount of time the particle system is running (depends of the overall update speed).
  15946. */
  15947. targetStopDuration: number;
  15948. /**
  15949. * The texture used to render each particle. (this can be a spritesheet)
  15950. */
  15951. particleTexture: Nullable<Texture>;
  15952. /**
  15953. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15954. */
  15955. blendMode: number;
  15956. /**
  15957. * Minimum life time of emitting particles.
  15958. */
  15959. minLifeTime: number;
  15960. /**
  15961. * Maximum life time of emitting particles.
  15962. */
  15963. maxLifeTime: number;
  15964. /**
  15965. * Minimum Size of emitting particles.
  15966. */
  15967. minSize: number;
  15968. /**
  15969. * Maximum Size of emitting particles.
  15970. */
  15971. maxSize: number;
  15972. /**
  15973. * Minimum scale of emitting particles on X axis.
  15974. */
  15975. minScaleX: number;
  15976. /**
  15977. * Maximum scale of emitting particles on X axis.
  15978. */
  15979. maxScaleX: number;
  15980. /**
  15981. * Minimum scale of emitting particles on Y axis.
  15982. */
  15983. minScaleY: number;
  15984. /**
  15985. * Maximum scale of emitting particles on Y axis.
  15986. */
  15987. maxScaleY: number;
  15988. /**
  15989. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15990. */
  15991. color1: Color4;
  15992. /**
  15993. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15994. */
  15995. color2: Color4;
  15996. /**
  15997. * Color the particle will have at the end of its lifetime.
  15998. */
  15999. colorDead: Color4;
  16000. /**
  16001. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16002. */
  16003. emitRate: number;
  16004. /**
  16005. * You can use gravity if you want to give an orientation to your particles.
  16006. */
  16007. gravity: Vector3;
  16008. /**
  16009. * Minimum power of emitting particles.
  16010. */
  16011. minEmitPower: number;
  16012. /**
  16013. * Maximum power of emitting particles.
  16014. */
  16015. maxEmitPower: number;
  16016. /**
  16017. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16018. */
  16019. minAngularSpeed: number;
  16020. /**
  16021. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16022. */
  16023. maxAngularSpeed: number;
  16024. /**
  16025. * Gets or sets the minimal initial rotation in radians.
  16026. */
  16027. minInitialRotation: number;
  16028. /**
  16029. * Gets or sets the maximal initial rotation in radians.
  16030. */
  16031. maxInitialRotation: number;
  16032. /**
  16033. * The particle emitter type defines the emitter used by the particle system.
  16034. * It can be for example box, sphere, or cone...
  16035. */
  16036. particleEmitterType: Nullable<IParticleEmitterType>;
  16037. /**
  16038. * Defines the delay in milliseconds before starting the system (0 by default)
  16039. */
  16040. startDelay: number;
  16041. /**
  16042. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  16043. */
  16044. preWarmCycles: number;
  16045. /**
  16046. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16047. */
  16048. preWarmStepOffset: number;
  16049. /**
  16050. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16051. */
  16052. spriteCellChangeSpeed: number;
  16053. /**
  16054. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16055. */
  16056. startSpriteCellID: number;
  16057. /**
  16058. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16059. */
  16060. endSpriteCellID: number;
  16061. /**
  16062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16063. */
  16064. spriteCellWidth: number;
  16065. /**
  16066. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16067. */
  16068. spriteCellHeight: number;
  16069. /**
  16070. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16071. */
  16072. spriteRandomStartCell: boolean;
  16073. /**
  16074. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16075. */
  16076. isAnimationSheetEnabled: boolean;
  16077. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16078. translationPivot: Vector2;
  16079. /**
  16080. * Gets or sets a texture used to add random noise to particle positions
  16081. */
  16082. noiseTexture: Nullable<BaseTexture>;
  16083. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16084. noiseStrength: Vector3;
  16085. /**
  16086. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16087. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16088. */
  16089. billboardMode: number;
  16090. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16091. limitVelocityDamping: number;
  16092. /**
  16093. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16094. */
  16095. beginAnimationOnStart: boolean;
  16096. /**
  16097. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16098. */
  16099. beginAnimationFrom: number;
  16100. /**
  16101. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16102. */
  16103. beginAnimationTo: number;
  16104. /**
  16105. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16106. */
  16107. beginAnimationLoop: boolean;
  16108. /**
  16109. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16110. */
  16111. disposeOnStop: boolean;
  16112. /**
  16113. * Gets the maximum number of particles active at the same time.
  16114. * @returns The max number of active particles.
  16115. */
  16116. getCapacity(): number;
  16117. /**
  16118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16119. * @returns True if it has been started, otherwise false.
  16120. */
  16121. isStarted(): boolean;
  16122. /**
  16123. * Animates the particle system for this frame.
  16124. */
  16125. animate(): void;
  16126. /**
  16127. * Renders the particle system in its current state.
  16128. * @returns the current number of particles
  16129. */
  16130. render(): number;
  16131. /**
  16132. * Dispose the particle system and frees its associated resources.
  16133. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16134. */
  16135. dispose(disposeTexture?: boolean): void;
  16136. /**
  16137. * Clones the particle system.
  16138. * @param name The name of the cloned object
  16139. * @param newEmitter The new emitter to use
  16140. * @returns the cloned particle system
  16141. */
  16142. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16143. /**
  16144. * Serializes the particle system to a JSON object.
  16145. * @returns the JSON object
  16146. */
  16147. serialize(): any;
  16148. /**
  16149. * Rebuild the particle system
  16150. */
  16151. rebuild(): void;
  16152. /**
  16153. * Starts the particle system and begins to emit
  16154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16155. */
  16156. start(delay?: number): void;
  16157. /**
  16158. * Stops the particle system.
  16159. */
  16160. stop(): void;
  16161. /**
  16162. * Remove all active particles
  16163. */
  16164. reset(): void;
  16165. /**
  16166. * Is this system ready to be used/rendered
  16167. * @return true if the system is ready
  16168. */
  16169. isReady(): boolean;
  16170. /**
  16171. * Adds a new color gradient
  16172. * @param gradient defines the gradient to use (between 0 and 1)
  16173. * @param color1 defines the color to affect to the specified gradient
  16174. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16175. * @returns the current particle system
  16176. */
  16177. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16178. /**
  16179. * Remove a specific color gradient
  16180. * @param gradient defines the gradient to remove
  16181. * @returns the current particle system
  16182. */
  16183. removeColorGradient(gradient: number): IParticleSystem;
  16184. /**
  16185. * Adds a new size gradient
  16186. * @param gradient defines the gradient to use (between 0 and 1)
  16187. * @param factor defines the size factor to affect to the specified gradient
  16188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16189. * @returns the current particle system
  16190. */
  16191. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16192. /**
  16193. * Remove a specific size gradient
  16194. * @param gradient defines the gradient to remove
  16195. * @returns the current particle system
  16196. */
  16197. removeSizeGradient(gradient: number): IParticleSystem;
  16198. /**
  16199. * Gets the current list of color gradients.
  16200. * You must use addColorGradient and removeColorGradient to udpate this list
  16201. * @returns the list of color gradients
  16202. */
  16203. getColorGradients(): Nullable<Array<ColorGradient>>;
  16204. /**
  16205. * Gets the current list of size gradients.
  16206. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16207. * @returns the list of size gradients
  16208. */
  16209. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16210. /**
  16211. * Gets the current list of angular speed gradients.
  16212. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16213. * @returns the list of angular speed gradients
  16214. */
  16215. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16216. /**
  16217. * Adds a new angular speed gradient
  16218. * @param gradient defines the gradient to use (between 0 and 1)
  16219. * @param factor defines the angular speed to affect to the specified gradient
  16220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16221. * @returns the current particle system
  16222. */
  16223. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16224. /**
  16225. * Remove a specific angular speed gradient
  16226. * @param gradient defines the gradient to remove
  16227. * @returns the current particle system
  16228. */
  16229. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16230. /**
  16231. * Gets the current list of velocity gradients.
  16232. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16233. * @returns the list of velocity gradients
  16234. */
  16235. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16236. /**
  16237. * Adds a new velocity gradient
  16238. * @param gradient defines the gradient to use (between 0 and 1)
  16239. * @param factor defines the velocity to affect to the specified gradient
  16240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16241. * @returns the current particle system
  16242. */
  16243. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16244. /**
  16245. * Remove a specific velocity gradient
  16246. * @param gradient defines the gradient to remove
  16247. * @returns the current particle system
  16248. */
  16249. removeVelocityGradient(gradient: number): IParticleSystem;
  16250. /**
  16251. * Gets the current list of limit velocity gradients.
  16252. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16253. * @returns the list of limit velocity gradients
  16254. */
  16255. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16256. /**
  16257. * Adds a new limit velocity gradient
  16258. * @param gradient defines the gradient to use (between 0 and 1)
  16259. * @param factor defines the limit velocity to affect to the specified gradient
  16260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16261. * @returns the current particle system
  16262. */
  16263. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16264. /**
  16265. * Remove a specific limit velocity gradient
  16266. * @param gradient defines the gradient to remove
  16267. * @returns the current particle system
  16268. */
  16269. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16270. /**
  16271. * Adds a new drag gradient
  16272. * @param gradient defines the gradient to use (between 0 and 1)
  16273. * @param factor defines the drag to affect to the specified gradient
  16274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16275. * @returns the current particle system
  16276. */
  16277. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16278. /**
  16279. * Remove a specific drag gradient
  16280. * @param gradient defines the gradient to remove
  16281. * @returns the current particle system
  16282. */
  16283. removeDragGradient(gradient: number): IParticleSystem;
  16284. /**
  16285. * Gets the current list of drag gradients.
  16286. * You must use addDragGradient and removeDragGradient to udpate this list
  16287. * @returns the list of drag gradients
  16288. */
  16289. getDragGradients(): Nullable<Array<FactorGradient>>;
  16290. /**
  16291. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16292. * @param gradient defines the gradient to use (between 0 and 1)
  16293. * @param factor defines the emit rate to affect to the specified gradient
  16294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16295. * @returns the current particle system
  16296. */
  16297. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16298. /**
  16299. * Remove a specific emit rate gradient
  16300. * @param gradient defines the gradient to remove
  16301. * @returns the current particle system
  16302. */
  16303. removeEmitRateGradient(gradient: number): IParticleSystem;
  16304. /**
  16305. * Gets the current list of emit rate gradients.
  16306. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16307. * @returns the list of emit rate gradients
  16308. */
  16309. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16310. /**
  16311. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16312. * @param gradient defines the gradient to use (between 0 and 1)
  16313. * @param factor defines the start size to affect to the specified gradient
  16314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16315. * @returns the current particle system
  16316. */
  16317. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16318. /**
  16319. * Remove a specific start size gradient
  16320. * @param gradient defines the gradient to remove
  16321. * @returns the current particle system
  16322. */
  16323. removeStartSizeGradient(gradient: number): IParticleSystem;
  16324. /**
  16325. * Gets the current list of start size gradients.
  16326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16327. * @returns the list of start size gradients
  16328. */
  16329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16330. /**
  16331. * Adds a new life time gradient
  16332. * @param gradient defines the gradient to use (between 0 and 1)
  16333. * @param factor defines the life time factor to affect to the specified gradient
  16334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16335. * @returns the current particle system
  16336. */
  16337. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16338. /**
  16339. * Remove a specific life time gradient
  16340. * @param gradient defines the gradient to remove
  16341. * @returns the current particle system
  16342. */
  16343. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16344. /**
  16345. * Gets the current list of life time gradients.
  16346. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16347. * @returns the list of life time gradients
  16348. */
  16349. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16350. /**
  16351. * Gets the current list of color gradients.
  16352. * You must use addColorGradient and removeColorGradient to udpate this list
  16353. * @returns the list of color gradients
  16354. */
  16355. getColorGradients(): Nullable<Array<ColorGradient>>;
  16356. /**
  16357. * Adds a new ramp gradient used to remap particle colors
  16358. * @param gradient defines the gradient to use (between 0 and 1)
  16359. * @param color defines the color to affect to the specified gradient
  16360. * @returns the current particle system
  16361. */
  16362. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16363. /**
  16364. * Gets the current list of ramp gradients.
  16365. * You must use addRampGradient and removeRampGradient to udpate this list
  16366. * @returns the list of ramp gradients
  16367. */
  16368. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16369. /** Gets or sets a boolean indicating that ramp gradients must be used
  16370. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16371. */
  16372. useRampGradients: boolean;
  16373. /**
  16374. * Adds a new color remap gradient
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param min defines the color remap minimal range
  16377. * @param max defines the color remap maximal range
  16378. * @returns the current particle system
  16379. */
  16380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16381. /**
  16382. * Gets the current list of color remap gradients.
  16383. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16384. * @returns the list of color remap gradients
  16385. */
  16386. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16387. /**
  16388. * Adds a new alpha remap gradient
  16389. * @param gradient defines the gradient to use (between 0 and 1)
  16390. * @param min defines the alpha remap minimal range
  16391. * @param max defines the alpha remap maximal range
  16392. * @returns the current particle system
  16393. */
  16394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16395. /**
  16396. * Gets the current list of alpha remap gradients.
  16397. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16398. * @returns the list of alpha remap gradients
  16399. */
  16400. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16401. /**
  16402. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16405. * @returns the emitter
  16406. */
  16407. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16408. /**
  16409. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16410. * @param radius The radius of the hemisphere to emit from
  16411. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16412. * @returns the emitter
  16413. */
  16414. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16415. /**
  16416. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16417. * @param radius The radius of the sphere to emit from
  16418. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16419. * @returns the emitter
  16420. */
  16421. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16422. /**
  16423. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16424. * @param radius The radius of the sphere to emit from
  16425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16427. * @returns the emitter
  16428. */
  16429. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16430. /**
  16431. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16432. * @param radius The radius of the emission cylinder
  16433. * @param height The height of the emission cylinder
  16434. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16435. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16436. * @returns the emitter
  16437. */
  16438. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16439. /**
  16440. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16441. * @param radius The radius of the cylinder to emit from
  16442. * @param height The height of the emission cylinder
  16443. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16446. * @returns the emitter
  16447. */
  16448. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16449. /**
  16450. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16451. * @param radius The radius of the cone to emit from
  16452. * @param angle The base angle of the cone
  16453. * @returns the emitter
  16454. */
  16455. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16456. /**
  16457. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16458. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16459. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16460. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16461. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16462. * @returns the emitter
  16463. */
  16464. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16465. /**
  16466. * Get hosting scene
  16467. * @returns the scene
  16468. */
  16469. getScene(): Scene;
  16470. }
  16471. }
  16472. declare module BABYLON {
  16473. /**
  16474. * Creates an instance based on a source mesh.
  16475. */
  16476. export class InstancedMesh extends AbstractMesh {
  16477. private _sourceMesh;
  16478. private _currentLOD;
  16479. /** @hidden */
  16480. _indexInSourceMeshInstanceArray: number;
  16481. constructor(name: string, source: Mesh);
  16482. /**
  16483. * Returns the string "InstancedMesh".
  16484. */
  16485. getClassName(): string;
  16486. /**
  16487. * If the source mesh receives shadows
  16488. */
  16489. readonly receiveShadows: boolean;
  16490. /**
  16491. * The material of the source mesh
  16492. */
  16493. readonly material: Nullable<Material>;
  16494. /**
  16495. * Visibility of the source mesh
  16496. */
  16497. readonly visibility: number;
  16498. /**
  16499. * Skeleton of the source mesh
  16500. */
  16501. readonly skeleton: Nullable<Skeleton>;
  16502. /**
  16503. * Rendering ground id of the source mesh
  16504. */
  16505. renderingGroupId: number;
  16506. /**
  16507. * Returns the total number of vertices (integer).
  16508. */
  16509. getTotalVertices(): number;
  16510. /**
  16511. * Returns a positive integer : the total number of indices in this mesh geometry.
  16512. * @returns the numner of indices or zero if the mesh has no geometry.
  16513. */
  16514. getTotalIndices(): number;
  16515. /**
  16516. * The source mesh of the instance
  16517. */
  16518. readonly sourceMesh: Mesh;
  16519. /**
  16520. * Is this node ready to be used/rendered
  16521. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16522. * @return {boolean} is it ready
  16523. */
  16524. isReady(completeCheck?: boolean): boolean;
  16525. /**
  16526. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16527. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16528. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16529. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16530. */
  16531. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16532. /**
  16533. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16534. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16535. * The `data` are either a numeric array either a Float32Array.
  16536. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16537. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16538. * Note that a new underlying VertexBuffer object is created each call.
  16539. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16540. *
  16541. * Possible `kind` values :
  16542. * - VertexBuffer.PositionKind
  16543. * - VertexBuffer.UVKind
  16544. * - VertexBuffer.UV2Kind
  16545. * - VertexBuffer.UV3Kind
  16546. * - VertexBuffer.UV4Kind
  16547. * - VertexBuffer.UV5Kind
  16548. * - VertexBuffer.UV6Kind
  16549. * - VertexBuffer.ColorKind
  16550. * - VertexBuffer.MatricesIndicesKind
  16551. * - VertexBuffer.MatricesIndicesExtraKind
  16552. * - VertexBuffer.MatricesWeightsKind
  16553. * - VertexBuffer.MatricesWeightsExtraKind
  16554. *
  16555. * Returns the Mesh.
  16556. */
  16557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16558. /**
  16559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16560. * If the mesh has no geometry, it is simply returned as it is.
  16561. * The `data` are either a numeric array either a Float32Array.
  16562. * No new underlying VertexBuffer object is created.
  16563. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16564. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16565. *
  16566. * Possible `kind` values :
  16567. * - VertexBuffer.PositionKind
  16568. * - VertexBuffer.UVKind
  16569. * - VertexBuffer.UV2Kind
  16570. * - VertexBuffer.UV3Kind
  16571. * - VertexBuffer.UV4Kind
  16572. * - VertexBuffer.UV5Kind
  16573. * - VertexBuffer.UV6Kind
  16574. * - VertexBuffer.ColorKind
  16575. * - VertexBuffer.MatricesIndicesKind
  16576. * - VertexBuffer.MatricesIndicesExtraKind
  16577. * - VertexBuffer.MatricesWeightsKind
  16578. * - VertexBuffer.MatricesWeightsExtraKind
  16579. *
  16580. * Returns the Mesh.
  16581. */
  16582. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16583. /**
  16584. * Sets the mesh indices.
  16585. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16586. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16587. * This method creates a new index buffer each call.
  16588. * Returns the Mesh.
  16589. */
  16590. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16591. /**
  16592. * Boolean : True if the mesh owns the requested kind of data.
  16593. */
  16594. isVerticesDataPresent(kind: string): boolean;
  16595. /**
  16596. * Returns an array of indices (IndicesArray).
  16597. */
  16598. getIndices(): Nullable<IndicesArray>;
  16599. readonly _positions: Nullable<Vector3[]>;
  16600. /**
  16601. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16602. * This means the mesh underlying bounding box and sphere are recomputed.
  16603. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16604. * @returns the current mesh
  16605. */
  16606. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16607. /** @hidden */
  16608. _preActivate(): InstancedMesh;
  16609. /** @hidden */
  16610. _activate(renderId: number): boolean;
  16611. /**
  16612. * Returns the current associated LOD AbstractMesh.
  16613. */
  16614. getLOD(camera: Camera): AbstractMesh;
  16615. /** @hidden */
  16616. _syncSubMeshes(): InstancedMesh;
  16617. /** @hidden */
  16618. _generatePointsArray(): boolean;
  16619. /**
  16620. * Creates a new InstancedMesh from the current mesh.
  16621. * - name (string) : the cloned mesh name
  16622. * - newParent (optional Node) : the optional Node to parent the clone to.
  16623. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16624. *
  16625. * Returns the clone.
  16626. */
  16627. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16628. /**
  16629. * Disposes the InstancedMesh.
  16630. * Returns nothing.
  16631. */
  16632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16633. }
  16634. }
  16635. declare module BABYLON {
  16636. /**
  16637. * Defines the options associated with the creation of a shader material.
  16638. */
  16639. export interface IShaderMaterialOptions {
  16640. /**
  16641. * Does the material work in alpha blend mode
  16642. */
  16643. needAlphaBlending: boolean;
  16644. /**
  16645. * Does the material work in alpha test mode
  16646. */
  16647. needAlphaTesting: boolean;
  16648. /**
  16649. * The list of attribute names used in the shader
  16650. */
  16651. attributes: string[];
  16652. /**
  16653. * The list of unifrom names used in the shader
  16654. */
  16655. uniforms: string[];
  16656. /**
  16657. * The list of UBO names used in the shader
  16658. */
  16659. uniformBuffers: string[];
  16660. /**
  16661. * The list of sampler names used in the shader
  16662. */
  16663. samplers: string[];
  16664. /**
  16665. * The list of defines used in the shader
  16666. */
  16667. defines: string[];
  16668. }
  16669. /**
  16670. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16671. *
  16672. * This returned material effects how the mesh will look based on the code in the shaders.
  16673. *
  16674. * @see http://doc.babylonjs.com/how_to/shader_material
  16675. */
  16676. export class ShaderMaterial extends Material {
  16677. private _shaderPath;
  16678. private _options;
  16679. private _textures;
  16680. private _textureArrays;
  16681. private _floats;
  16682. private _ints;
  16683. private _floatsArrays;
  16684. private _colors3;
  16685. private _colors3Arrays;
  16686. private _colors4;
  16687. private _vectors2;
  16688. private _vectors3;
  16689. private _vectors4;
  16690. private _matrices;
  16691. private _matrices3x3;
  16692. private _matrices2x2;
  16693. private _vectors2Arrays;
  16694. private _vectors3Arrays;
  16695. private _cachedWorldViewMatrix;
  16696. private _renderId;
  16697. /**
  16698. * Instantiate a new shader material.
  16699. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16700. * This returned material effects how the mesh will look based on the code in the shaders.
  16701. * @see http://doc.babylonjs.com/how_to/shader_material
  16702. * @param name Define the name of the material in the scene
  16703. * @param scene Define the scene the material belongs to
  16704. * @param shaderPath Defines the route to the shader code in one of three ways:
  16705. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16706. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16707. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16708. * @param options Define the options used to create the shader
  16709. */
  16710. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16711. /**
  16712. * Gets the options used to compile the shader.
  16713. * They can be modified to trigger a new compilation
  16714. */
  16715. readonly options: IShaderMaterialOptions;
  16716. /**
  16717. * Gets the current class name of the material e.g. "ShaderMaterial"
  16718. * Mainly use in serialization.
  16719. * @returns the class name
  16720. */
  16721. getClassName(): string;
  16722. /**
  16723. * Specifies if the material will require alpha blending
  16724. * @returns a boolean specifying if alpha blending is needed
  16725. */
  16726. needAlphaBlending(): boolean;
  16727. /**
  16728. * Specifies if this material should be rendered in alpha test mode
  16729. * @returns a boolean specifying if an alpha test is needed.
  16730. */
  16731. needAlphaTesting(): boolean;
  16732. private _checkUniform;
  16733. /**
  16734. * Set a texture in the shader.
  16735. * @param name Define the name of the uniform samplers as defined in the shader
  16736. * @param texture Define the texture to bind to this sampler
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setTexture(name: string, texture: Texture): ShaderMaterial;
  16740. /**
  16741. * Set a texture array in the shader.
  16742. * @param name Define the name of the uniform sampler array as defined in the shader
  16743. * @param textures Define the list of textures to bind to this sampler
  16744. * @return the material itself allowing "fluent" like uniform updates
  16745. */
  16746. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16747. /**
  16748. * Set a float in the shader.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the material itself allowing "fluent" like uniform updates
  16752. */
  16753. setFloat(name: string, value: number): ShaderMaterial;
  16754. /**
  16755. * Set a int in the shader.
  16756. * @param name Define the name of the uniform as defined in the shader
  16757. * @param value Define the value to give to the uniform
  16758. * @return the material itself allowing "fluent" like uniform updates
  16759. */
  16760. setInt(name: string, value: number): ShaderMaterial;
  16761. /**
  16762. * Set an array of floats in the shader.
  16763. * @param name Define the name of the uniform as defined in the shader
  16764. * @param value Define the value to give to the uniform
  16765. * @return the material itself allowing "fluent" like uniform updates
  16766. */
  16767. setFloats(name: string, value: number[]): ShaderMaterial;
  16768. /**
  16769. * Set a vec3 in the shader from a Color3.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the material itself allowing "fluent" like uniform updates
  16773. */
  16774. setColor3(name: string, value: Color3): ShaderMaterial;
  16775. /**
  16776. * Set a vec3 array in the shader from a Color3 array.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the material itself allowing "fluent" like uniform updates
  16780. */
  16781. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16782. /**
  16783. * Set a vec4 in the shader from a Color4.
  16784. * @param name Define the name of the uniform as defined in the shader
  16785. * @param value Define the value to give to the uniform
  16786. * @return the material itself allowing "fluent" like uniform updates
  16787. */
  16788. setColor4(name: string, value: Color4): ShaderMaterial;
  16789. /**
  16790. * Set a vec2 in the shader from a Vector2.
  16791. * @param name Define the name of the uniform as defined in the shader
  16792. * @param value Define the value to give to the uniform
  16793. * @return the material itself allowing "fluent" like uniform updates
  16794. */
  16795. setVector2(name: string, value: Vector2): ShaderMaterial;
  16796. /**
  16797. * Set a vec3 in the shader from a Vector3.
  16798. * @param name Define the name of the uniform as defined in the shader
  16799. * @param value Define the value to give to the uniform
  16800. * @return the material itself allowing "fluent" like uniform updates
  16801. */
  16802. setVector3(name: string, value: Vector3): ShaderMaterial;
  16803. /**
  16804. * Set a vec4 in the shader from a Vector4.
  16805. * @param name Define the name of the uniform as defined in the shader
  16806. * @param value Define the value to give to the uniform
  16807. * @return the material itself allowing "fluent" like uniform updates
  16808. */
  16809. setVector4(name: string, value: Vector4): ShaderMaterial;
  16810. /**
  16811. * Set a mat4 in the shader from a Matrix.
  16812. * @param name Define the name of the uniform as defined in the shader
  16813. * @param value Define the value to give to the uniform
  16814. * @return the material itself allowing "fluent" like uniform updates
  16815. */
  16816. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16817. /**
  16818. * Set a mat3 in the shader from a Float32Array.
  16819. * @param name Define the name of the uniform as defined in the shader
  16820. * @param value Define the value to give to the uniform
  16821. * @return the material itself allowing "fluent" like uniform updates
  16822. */
  16823. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16824. /**
  16825. * Set a mat2 in the shader from a Float32Array.
  16826. * @param name Define the name of the uniform as defined in the shader
  16827. * @param value Define the value to give to the uniform
  16828. * @return the material itself allowing "fluent" like uniform updates
  16829. */
  16830. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16831. /**
  16832. * Set a vec2 array in the shader from a number array.
  16833. * @param name Define the name of the uniform as defined in the shader
  16834. * @param value Define the value to give to the uniform
  16835. * @return the material itself allowing "fluent" like uniform updates
  16836. */
  16837. setArray2(name: string, value: number[]): ShaderMaterial;
  16838. /**
  16839. * Set a vec3 array in the shader from a number array.
  16840. * @param name Define the name of the uniform as defined in the shader
  16841. * @param value Define the value to give to the uniform
  16842. * @return the material itself allowing "fluent" like uniform updates
  16843. */
  16844. setArray3(name: string, value: number[]): ShaderMaterial;
  16845. private _checkCache;
  16846. /**
  16847. * Specifies that the submesh is ready to be used
  16848. * @param mesh defines the mesh to check
  16849. * @param subMesh defines which submesh to check
  16850. * @param useInstances specifies that instances should be used
  16851. * @returns a boolean indicating that the submesh is ready or not
  16852. */
  16853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16854. /**
  16855. * Checks if the material is ready to render the requested mesh
  16856. * @param mesh Define the mesh to render
  16857. * @param useInstances Define whether or not the material is used with instances
  16858. * @returns true if ready, otherwise false
  16859. */
  16860. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16861. /**
  16862. * Binds the world matrix to the material
  16863. * @param world defines the world transformation matrix
  16864. */
  16865. bindOnlyWorldMatrix(world: Matrix): void;
  16866. /**
  16867. * Binds the material to the mesh
  16868. * @param world defines the world transformation matrix
  16869. * @param mesh defines the mesh to bind the material to
  16870. */
  16871. bind(world: Matrix, mesh?: Mesh): void;
  16872. /**
  16873. * Gets the active textures from the material
  16874. * @returns an array of textures
  16875. */
  16876. getActiveTextures(): BaseTexture[];
  16877. /**
  16878. * Specifies if the material uses a texture
  16879. * @param texture defines the texture to check against the material
  16880. * @returns a boolean specifying if the material uses the texture
  16881. */
  16882. hasTexture(texture: BaseTexture): boolean;
  16883. /**
  16884. * Makes a duplicate of the material, and gives it a new name
  16885. * @param name defines the new name for the duplicated material
  16886. * @returns the cloned material
  16887. */
  16888. clone(name: string): ShaderMaterial;
  16889. /**
  16890. * Disposes the material
  16891. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16892. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16893. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16894. */
  16895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16896. /**
  16897. * Serializes this material in a JSON representation
  16898. * @returns the serialized material object
  16899. */
  16900. serialize(): any;
  16901. /**
  16902. * Creates a shader material from parsed shader material data
  16903. * @param source defines the JSON represnetation of the material
  16904. * @param scene defines the hosting scene
  16905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16906. * @returns a new material
  16907. */
  16908. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16909. }
  16910. }
  16911. declare module BABYLON {
  16912. /** @hidden */
  16913. export var colorPixelShader: {
  16914. name: string;
  16915. shader: string;
  16916. };
  16917. }
  16918. declare module BABYLON {
  16919. /** @hidden */
  16920. export var colorVertexShader: {
  16921. name: string;
  16922. shader: string;
  16923. };
  16924. }
  16925. declare module BABYLON {
  16926. /**
  16927. * Line mesh
  16928. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16929. */
  16930. export class LinesMesh extends Mesh {
  16931. /**
  16932. * If vertex color should be applied to the mesh
  16933. */
  16934. useVertexColor?: boolean | undefined;
  16935. /**
  16936. * If vertex alpha should be applied to the mesh
  16937. */
  16938. useVertexAlpha?: boolean | undefined;
  16939. /**
  16940. * Color of the line (Default: White)
  16941. */
  16942. color: Color3;
  16943. /**
  16944. * Alpha of the line (Default: 1)
  16945. */
  16946. alpha: number;
  16947. /**
  16948. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16949. * This margin is expressed in world space coordinates, so its value may vary.
  16950. * Default value is 0.1
  16951. */
  16952. intersectionThreshold: number;
  16953. private _colorShader;
  16954. /**
  16955. * Creates a new LinesMesh
  16956. * @param name defines the name
  16957. * @param scene defines the hosting scene
  16958. * @param parent defines the parent mesh if any
  16959. * @param source defines the optional source LinesMesh used to clone data from
  16960. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16961. * When false, achieved by calling a clone(), also passing False.
  16962. * This will make creation of children, recursive.
  16963. * @param useVertexColor defines if this LinesMesh supports vertex color
  16964. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16965. */
  16966. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16967. /**
  16968. * If vertex color should be applied to the mesh
  16969. */
  16970. useVertexColor?: boolean | undefined,
  16971. /**
  16972. * If vertex alpha should be applied to the mesh
  16973. */
  16974. useVertexAlpha?: boolean | undefined);
  16975. private _addClipPlaneDefine;
  16976. private _removeClipPlaneDefine;
  16977. isReady(): boolean;
  16978. /**
  16979. * Returns the string "LineMesh"
  16980. */
  16981. getClassName(): string;
  16982. /**
  16983. * @hidden
  16984. */
  16985. /**
  16986. * @hidden
  16987. */
  16988. material: Material;
  16989. /**
  16990. * @hidden
  16991. */
  16992. readonly checkCollisions: boolean;
  16993. /** @hidden */
  16994. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16995. /** @hidden */
  16996. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16997. /**
  16998. * Disposes of the line mesh
  16999. * @param doNotRecurse If children should be disposed
  17000. */
  17001. dispose(doNotRecurse?: boolean): void;
  17002. /**
  17003. * Returns a new LineMesh object cloned from the current one.
  17004. */
  17005. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17006. /**
  17007. * Creates a new InstancedLinesMesh object from the mesh model.
  17008. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17009. * @param name defines the name of the new instance
  17010. * @returns a new InstancedLinesMesh
  17011. */
  17012. createInstance(name: string): InstancedLinesMesh;
  17013. }
  17014. /**
  17015. * Creates an instance based on a source LinesMesh
  17016. */
  17017. export class InstancedLinesMesh extends InstancedMesh {
  17018. /**
  17019. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17020. * This margin is expressed in world space coordinates, so its value may vary.
  17021. * Initilized with the intersectionThreshold value of the source LinesMesh
  17022. */
  17023. intersectionThreshold: number;
  17024. constructor(name: string, source: LinesMesh);
  17025. /**
  17026. * Returns the string "InstancedLinesMesh".
  17027. */
  17028. getClassName(): string;
  17029. }
  17030. }
  17031. declare module BABYLON {
  17032. /** @hidden */
  17033. export var linePixelShader: {
  17034. name: string;
  17035. shader: string;
  17036. };
  17037. }
  17038. declare module BABYLON {
  17039. /** @hidden */
  17040. export var lineVertexShader: {
  17041. name: string;
  17042. shader: string;
  17043. };
  17044. }
  17045. declare module BABYLON {
  17046. interface AbstractMesh {
  17047. /**
  17048. * Disables the mesh edge rendering mode
  17049. * @returns the currentAbstractMesh
  17050. */
  17051. disableEdgesRendering(): AbstractMesh;
  17052. /**
  17053. * Enables the edge rendering mode on the mesh.
  17054. * This mode makes the mesh edges visible
  17055. * @param epsilon defines the maximal distance between two angles to detect a face
  17056. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17057. * @returns the currentAbstractMesh
  17058. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17059. */
  17060. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17061. /**
  17062. * Gets the edgesRenderer associated with the mesh
  17063. */
  17064. edgesRenderer: Nullable<EdgesRenderer>;
  17065. }
  17066. interface LinesMesh {
  17067. /**
  17068. * Enables the edge rendering mode on the mesh.
  17069. * This mode makes the mesh edges visible
  17070. * @param epsilon defines the maximal distance between two angles to detect a face
  17071. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17072. * @returns the currentAbstractMesh
  17073. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17074. */
  17075. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17076. }
  17077. interface InstancedLinesMesh {
  17078. /**
  17079. * Enables the edge rendering mode on the mesh.
  17080. * This mode makes the mesh edges visible
  17081. * @param epsilon defines the maximal distance between two angles to detect a face
  17082. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17083. * @returns the current InstancedLinesMesh
  17084. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17085. */
  17086. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17087. }
  17088. /**
  17089. * Defines the minimum contract an Edges renderer should follow.
  17090. */
  17091. export interface IEdgesRenderer extends IDisposable {
  17092. /**
  17093. * Gets or sets a boolean indicating if the edgesRenderer is active
  17094. */
  17095. isEnabled: boolean;
  17096. /**
  17097. * Renders the edges of the attached mesh,
  17098. */
  17099. render(): void;
  17100. /**
  17101. * Checks wether or not the edges renderer is ready to render.
  17102. * @return true if ready, otherwise false.
  17103. */
  17104. isReady(): boolean;
  17105. }
  17106. /**
  17107. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17108. */
  17109. export class EdgesRenderer implements IEdgesRenderer {
  17110. /**
  17111. * Define the size of the edges with an orthographic camera
  17112. */
  17113. edgesWidthScalerForOrthographic: number;
  17114. /**
  17115. * Define the size of the edges with a perspective camera
  17116. */
  17117. edgesWidthScalerForPerspective: number;
  17118. protected _source: AbstractMesh;
  17119. protected _linesPositions: number[];
  17120. protected _linesNormals: number[];
  17121. protected _linesIndices: number[];
  17122. protected _epsilon: number;
  17123. protected _indicesCount: number;
  17124. protected _lineShader: ShaderMaterial;
  17125. protected _ib: WebGLBuffer;
  17126. protected _buffers: {
  17127. [key: string]: Nullable<VertexBuffer>;
  17128. };
  17129. protected _checkVerticesInsteadOfIndices: boolean;
  17130. private _meshRebuildObserver;
  17131. private _meshDisposeObserver;
  17132. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17133. isEnabled: boolean;
  17134. /**
  17135. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17136. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17137. * @param source Mesh used to create edges
  17138. * @param epsilon sum of angles in adjacency to check for edge
  17139. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17140. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17141. */
  17142. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17143. protected _prepareRessources(): void;
  17144. /** @hidden */
  17145. _rebuild(): void;
  17146. /**
  17147. * Releases the required resources for the edges renderer
  17148. */
  17149. dispose(): void;
  17150. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17151. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17152. /**
  17153. * Checks if the pair of p0 and p1 is en edge
  17154. * @param faceIndex
  17155. * @param edge
  17156. * @param faceNormals
  17157. * @param p0
  17158. * @param p1
  17159. * @private
  17160. */
  17161. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17162. /**
  17163. * push line into the position, normal and index buffer
  17164. * @protected
  17165. */
  17166. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17167. /**
  17168. * Generates lines edges from adjacencjes
  17169. * @private
  17170. */
  17171. _generateEdgesLines(): void;
  17172. /**
  17173. * Checks wether or not the edges renderer is ready to render.
  17174. * @return true if ready, otherwise false.
  17175. */
  17176. isReady(): boolean;
  17177. /**
  17178. * Renders the edges of the attached mesh,
  17179. */
  17180. render(): void;
  17181. }
  17182. /**
  17183. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17184. */
  17185. export class LineEdgesRenderer extends EdgesRenderer {
  17186. /**
  17187. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17188. * @param source LineMesh used to generate edges
  17189. * @param epsilon not important (specified angle for edge detection)
  17190. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17191. */
  17192. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17193. /**
  17194. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17195. */
  17196. _generateEdgesLines(): void;
  17197. }
  17198. }
  17199. declare module BABYLON {
  17200. /**
  17201. * This represents the object necessary to create a rendering group.
  17202. * This is exclusively used and created by the rendering manager.
  17203. * To modify the behavior, you use the available helpers in your scene or meshes.
  17204. * @hidden
  17205. */
  17206. export class RenderingGroup {
  17207. index: number;
  17208. private _scene;
  17209. private _opaqueSubMeshes;
  17210. private _transparentSubMeshes;
  17211. private _alphaTestSubMeshes;
  17212. private _depthOnlySubMeshes;
  17213. private _particleSystems;
  17214. private _spriteManagers;
  17215. private _opaqueSortCompareFn;
  17216. private _alphaTestSortCompareFn;
  17217. private _transparentSortCompareFn;
  17218. private _renderOpaque;
  17219. private _renderAlphaTest;
  17220. private _renderTransparent;
  17221. /** @hidden */
  17222. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17223. onBeforeTransparentRendering: () => void;
  17224. /**
  17225. * Set the opaque sort comparison function.
  17226. * If null the sub meshes will be render in the order they were created
  17227. */
  17228. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17229. /**
  17230. * Set the alpha test sort comparison function.
  17231. * If null the sub meshes will be render in the order they were created
  17232. */
  17233. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17234. /**
  17235. * Set the transparent sort comparison function.
  17236. * If null the sub meshes will be render in the order they were created
  17237. */
  17238. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17239. /**
  17240. * Creates a new rendering group.
  17241. * @param index The rendering group index
  17242. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17243. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17244. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17245. */
  17246. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17247. /**
  17248. * Render all the sub meshes contained in the group.
  17249. * @param customRenderFunction Used to override the default render behaviour of the group.
  17250. * @returns true if rendered some submeshes.
  17251. */
  17252. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17253. /**
  17254. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17255. * @param subMeshes The submeshes to render
  17256. */
  17257. private renderOpaqueSorted;
  17258. /**
  17259. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17260. * @param subMeshes The submeshes to render
  17261. */
  17262. private renderAlphaTestSorted;
  17263. /**
  17264. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17265. * @param subMeshes The submeshes to render
  17266. */
  17267. private renderTransparentSorted;
  17268. /**
  17269. * Renders the submeshes in a specified order.
  17270. * @param subMeshes The submeshes to sort before render
  17271. * @param sortCompareFn The comparison function use to sort
  17272. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17273. * @param transparent Specifies to activate blending if true
  17274. */
  17275. private static renderSorted;
  17276. /**
  17277. * Renders the submeshes in the order they were dispatched (no sort applied).
  17278. * @param subMeshes The submeshes to render
  17279. */
  17280. private static renderUnsorted;
  17281. /**
  17282. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17283. * are rendered back to front if in the same alpha index.
  17284. *
  17285. * @param a The first submesh
  17286. * @param b The second submesh
  17287. * @returns The result of the comparison
  17288. */
  17289. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17290. /**
  17291. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17292. * are rendered back to front.
  17293. *
  17294. * @param a The first submesh
  17295. * @param b The second submesh
  17296. * @returns The result of the comparison
  17297. */
  17298. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17299. /**
  17300. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17301. * are rendered front to back (prevent overdraw).
  17302. *
  17303. * @param a The first submesh
  17304. * @param b The second submesh
  17305. * @returns The result of the comparison
  17306. */
  17307. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17308. /**
  17309. * Resets the different lists of submeshes to prepare a new frame.
  17310. */
  17311. prepare(): void;
  17312. dispose(): void;
  17313. /**
  17314. * Inserts the submesh in its correct queue depending on its material.
  17315. * @param subMesh The submesh to dispatch
  17316. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17317. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17318. */
  17319. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17320. dispatchSprites(spriteManager: ISpriteManager): void;
  17321. dispatchParticles(particleSystem: IParticleSystem): void;
  17322. private _renderParticles;
  17323. private _renderSprites;
  17324. }
  17325. }
  17326. declare module BABYLON {
  17327. /**
  17328. * Interface describing the different options available in the rendering manager
  17329. * regarding Auto Clear between groups.
  17330. */
  17331. export interface IRenderingManagerAutoClearSetup {
  17332. /**
  17333. * Defines whether or not autoclear is enable.
  17334. */
  17335. autoClear: boolean;
  17336. /**
  17337. * Defines whether or not to autoclear the depth buffer.
  17338. */
  17339. depth: boolean;
  17340. /**
  17341. * Defines whether or not to autoclear the stencil buffer.
  17342. */
  17343. stencil: boolean;
  17344. }
  17345. /**
  17346. * This class is used by the onRenderingGroupObservable
  17347. */
  17348. export class RenderingGroupInfo {
  17349. /**
  17350. * The Scene that being rendered
  17351. */
  17352. scene: Scene;
  17353. /**
  17354. * The camera currently used for the rendering pass
  17355. */
  17356. camera: Nullable<Camera>;
  17357. /**
  17358. * The ID of the renderingGroup being processed
  17359. */
  17360. renderingGroupId: number;
  17361. }
  17362. /**
  17363. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17364. * It is enable to manage the different groups as well as the different necessary sort functions.
  17365. * This should not be used directly aside of the few static configurations
  17366. */
  17367. export class RenderingManager {
  17368. /**
  17369. * The max id used for rendering groups (not included)
  17370. */
  17371. static MAX_RENDERINGGROUPS: number;
  17372. /**
  17373. * The min id used for rendering groups (included)
  17374. */
  17375. static MIN_RENDERINGGROUPS: number;
  17376. /**
  17377. * Used to globally prevent autoclearing scenes.
  17378. */
  17379. static AUTOCLEAR: boolean;
  17380. /**
  17381. * @hidden
  17382. */
  17383. _useSceneAutoClearSetup: boolean;
  17384. private _scene;
  17385. private _renderingGroups;
  17386. private _depthStencilBufferAlreadyCleaned;
  17387. private _autoClearDepthStencil;
  17388. private _customOpaqueSortCompareFn;
  17389. private _customAlphaTestSortCompareFn;
  17390. private _customTransparentSortCompareFn;
  17391. private _renderingGroupInfo;
  17392. /**
  17393. * Instantiates a new rendering group for a particular scene
  17394. * @param scene Defines the scene the groups belongs to
  17395. */
  17396. constructor(scene: Scene);
  17397. private _clearDepthStencilBuffer;
  17398. /**
  17399. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17400. * @hidden
  17401. */
  17402. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17403. /**
  17404. * Resets the different information of the group to prepare a new frame
  17405. * @hidden
  17406. */
  17407. reset(): void;
  17408. /**
  17409. * Dispose and release the group and its associated resources.
  17410. * @hidden
  17411. */
  17412. dispose(): void;
  17413. /**
  17414. * Clear the info related to rendering groups preventing retention points during dispose.
  17415. */
  17416. freeRenderingGroups(): void;
  17417. private _prepareRenderingGroup;
  17418. /**
  17419. * Add a sprite manager to the rendering manager in order to render it this frame.
  17420. * @param spriteManager Define the sprite manager to render
  17421. */
  17422. dispatchSprites(spriteManager: ISpriteManager): void;
  17423. /**
  17424. * Add a particle system to the rendering manager in order to render it this frame.
  17425. * @param particleSystem Define the particle system to render
  17426. */
  17427. dispatchParticles(particleSystem: IParticleSystem): void;
  17428. /**
  17429. * Add a submesh to the manager in order to render it this frame
  17430. * @param subMesh The submesh to dispatch
  17431. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17432. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17433. */
  17434. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17435. /**
  17436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17437. * This allowed control for front to back rendering or reversly depending of the special needs.
  17438. *
  17439. * @param renderingGroupId The rendering group id corresponding to its index
  17440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17443. */
  17444. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17445. /**
  17446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17447. *
  17448. * @param renderingGroupId The rendering group id corresponding to its index
  17449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17450. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17451. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17452. */
  17453. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17454. /**
  17455. * Gets the current auto clear configuration for one rendering group of the rendering
  17456. * manager.
  17457. * @param index the rendering group index to get the information for
  17458. * @returns The auto clear setup for the requested rendering group
  17459. */
  17460. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17461. }
  17462. }
  17463. declare module BABYLON {
  17464. /**
  17465. * This Helps creating a texture that will be created from a camera in your scene.
  17466. * It is basically a dynamic texture that could be used to create special effects for instance.
  17467. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17468. */
  17469. export class RenderTargetTexture extends Texture {
  17470. isCube: boolean;
  17471. /**
  17472. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17473. */
  17474. static readonly REFRESHRATE_RENDER_ONCE: number;
  17475. /**
  17476. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17477. */
  17478. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17479. /**
  17480. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17481. * the central point of your effect and can save a lot of performances.
  17482. */
  17483. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17484. /**
  17485. * Use this predicate to dynamically define the list of mesh you want to render.
  17486. * If set, the renderList property will be overwritten.
  17487. */
  17488. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17489. private _renderList;
  17490. /**
  17491. * Use this list to define the list of mesh you want to render.
  17492. */
  17493. renderList: Nullable<Array<AbstractMesh>>;
  17494. private _hookArray;
  17495. /**
  17496. * Define if particles should be rendered in your texture.
  17497. */
  17498. renderParticles: boolean;
  17499. /**
  17500. * Define if sprites should be rendered in your texture.
  17501. */
  17502. renderSprites: boolean;
  17503. /**
  17504. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17505. */
  17506. coordinatesMode: number;
  17507. /**
  17508. * Define the camera used to render the texture.
  17509. */
  17510. activeCamera: Nullable<Camera>;
  17511. /**
  17512. * Override the render function of the texture with your own one.
  17513. */
  17514. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17515. /**
  17516. * Define if camera post processes should be use while rendering the texture.
  17517. */
  17518. useCameraPostProcesses: boolean;
  17519. /**
  17520. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17521. */
  17522. ignoreCameraViewport: boolean;
  17523. private _postProcessManager;
  17524. private _postProcesses;
  17525. private _resizeObserver;
  17526. /**
  17527. * An event triggered when the texture is unbind.
  17528. */
  17529. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17530. /**
  17531. * An event triggered when the texture is unbind.
  17532. */
  17533. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17534. private _onAfterUnbindObserver;
  17535. /**
  17536. * Set a after unbind callback in the texture.
  17537. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17538. */
  17539. onAfterUnbind: () => void;
  17540. /**
  17541. * An event triggered before rendering the texture
  17542. */
  17543. onBeforeRenderObservable: Observable<number>;
  17544. private _onBeforeRenderObserver;
  17545. /**
  17546. * Set a before render callback in the texture.
  17547. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17548. */
  17549. onBeforeRender: (faceIndex: number) => void;
  17550. /**
  17551. * An event triggered after rendering the texture
  17552. */
  17553. onAfterRenderObservable: Observable<number>;
  17554. private _onAfterRenderObserver;
  17555. /**
  17556. * Set a after render callback in the texture.
  17557. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17558. */
  17559. onAfterRender: (faceIndex: number) => void;
  17560. /**
  17561. * An event triggered after the texture clear
  17562. */
  17563. onClearObservable: Observable<Engine>;
  17564. private _onClearObserver;
  17565. /**
  17566. * Set a clear callback in the texture.
  17567. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17568. */
  17569. onClear: (Engine: Engine) => void;
  17570. /**
  17571. * Define the clear color of the Render Target if it should be different from the scene.
  17572. */
  17573. clearColor: Color4;
  17574. protected _size: number | {
  17575. width: number;
  17576. height: number;
  17577. };
  17578. protected _initialSizeParameter: number | {
  17579. width: number;
  17580. height: number;
  17581. } | {
  17582. ratio: number;
  17583. };
  17584. protected _sizeRatio: Nullable<number>;
  17585. /** @hidden */
  17586. _generateMipMaps: boolean;
  17587. protected _renderingManager: RenderingManager;
  17588. /** @hidden */
  17589. _waitingRenderList: string[];
  17590. protected _doNotChangeAspectRatio: boolean;
  17591. protected _currentRefreshId: number;
  17592. protected _refreshRate: number;
  17593. protected _textureMatrix: Matrix;
  17594. protected _samples: number;
  17595. protected _renderTargetOptions: RenderTargetCreationOptions;
  17596. /**
  17597. * Gets render target creation options that were used.
  17598. */
  17599. readonly renderTargetOptions: RenderTargetCreationOptions;
  17600. protected _engine: Engine;
  17601. protected _onRatioRescale(): void;
  17602. /**
  17603. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17604. * It must define where the camera used to render the texture is set
  17605. */
  17606. boundingBoxPosition: Vector3;
  17607. private _boundingBoxSize;
  17608. /**
  17609. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17610. * When defined, the cubemap will switch to local mode
  17611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17612. * @example https://www.babylonjs-playground.com/#RNASML
  17613. */
  17614. boundingBoxSize: Vector3;
  17615. /**
  17616. * In case the RTT has been created with a depth texture, get the associated
  17617. * depth texture.
  17618. * Otherwise, return null.
  17619. */
  17620. depthStencilTexture: Nullable<InternalTexture>;
  17621. /**
  17622. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17623. * or used a shadow, depth texture...
  17624. * @param name The friendly name of the texture
  17625. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  17626. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17627. * @param generateMipMaps True if mip maps need to be generated after render.
  17628. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17629. * @param type The type of the buffer in the RTT (int, half float, float...)
  17630. * @param isCube True if a cube texture needs to be created
  17631. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17632. * @param generateDepthBuffer True to generate a depth buffer
  17633. * @param generateStencilBuffer True to generate a stencil buffer
  17634. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17635. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17637. */
  17638. constructor(name: string, size: number | {
  17639. width: number;
  17640. height: number;
  17641. } | {
  17642. ratio: number;
  17643. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17644. /**
  17645. * Creates a depth stencil texture.
  17646. * This is only available in WebGL 2 or with the depth texture extension available.
  17647. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17648. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17649. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17650. */
  17651. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17652. private _processSizeParameter;
  17653. /**
  17654. * Define the number of samples to use in case of MSAA.
  17655. * It defaults to one meaning no MSAA has been enabled.
  17656. */
  17657. samples: number;
  17658. /**
  17659. * Resets the refresh counter of the texture and start bak from scratch.
  17660. * Could be useful to regenerate the texture if it is setup to render only once.
  17661. */
  17662. resetRefreshCounter(): void;
  17663. /**
  17664. * Define the refresh rate of the texture or the rendering frequency.
  17665. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17666. */
  17667. refreshRate: number;
  17668. /**
  17669. * Adds a post process to the render target rendering passes.
  17670. * @param postProcess define the post process to add
  17671. */
  17672. addPostProcess(postProcess: PostProcess): void;
  17673. /**
  17674. * Clear all the post processes attached to the render target
  17675. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17676. */
  17677. clearPostProcesses(dispose?: boolean): void;
  17678. /**
  17679. * Remove one of the post process from the list of attached post processes to the texture
  17680. * @param postProcess define the post process to remove from the list
  17681. */
  17682. removePostProcess(postProcess: PostProcess): void;
  17683. /** @hidden */
  17684. _shouldRender(): boolean;
  17685. /**
  17686. * Gets the actual render size of the texture.
  17687. * @returns the width of the render size
  17688. */
  17689. getRenderSize(): number;
  17690. /**
  17691. * Gets the actual render width of the texture.
  17692. * @returns the width of the render size
  17693. */
  17694. getRenderWidth(): number;
  17695. /**
  17696. * Gets the actual render height of the texture.
  17697. * @returns the height of the render size
  17698. */
  17699. getRenderHeight(): number;
  17700. /**
  17701. * Get if the texture can be rescaled or not.
  17702. */
  17703. readonly canRescale: boolean;
  17704. /**
  17705. * Resize the texture using a ratio.
  17706. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17707. */
  17708. scale(ratio: number): void;
  17709. /**
  17710. * Get the texture reflection matrix used to rotate/transform the reflection.
  17711. * @returns the reflection matrix
  17712. */
  17713. getReflectionTextureMatrix(): Matrix;
  17714. /**
  17715. * Resize the texture to a new desired size.
  17716. * Be carrefull as it will recreate all the data in the new texture.
  17717. * @param size Define the new size. It can be:
  17718. * - a number for squared texture,
  17719. * - an object containing { width: number, height: number }
  17720. * - or an object containing a ratio { ratio: number }
  17721. */
  17722. resize(size: number | {
  17723. width: number;
  17724. height: number;
  17725. } | {
  17726. ratio: number;
  17727. }): void;
  17728. /**
  17729. * Renders all the objects from the render list into the texture.
  17730. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17731. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17732. */
  17733. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17734. private _bestReflectionRenderTargetDimension;
  17735. /**
  17736. * @hidden
  17737. * @param faceIndex face index to bind to if this is a cubetexture
  17738. */
  17739. _bindFrameBuffer(faceIndex?: number): void;
  17740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17741. private renderToTarget;
  17742. /**
  17743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17744. * This allowed control for front to back rendering or reversly depending of the special needs.
  17745. *
  17746. * @param renderingGroupId The rendering group id corresponding to its index
  17747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17750. */
  17751. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17752. /**
  17753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17754. *
  17755. * @param renderingGroupId The rendering group id corresponding to its index
  17756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17757. */
  17758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17759. /**
  17760. * Clones the texture.
  17761. * @returns the cloned texture
  17762. */
  17763. clone(): RenderTargetTexture;
  17764. /**
  17765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17766. * @returns The JSON representation of the texture
  17767. */
  17768. serialize(): any;
  17769. /**
  17770. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17771. */
  17772. disposeFramebufferObjects(): void;
  17773. /**
  17774. * Dispose the texture and release its associated resources.
  17775. */
  17776. dispose(): void;
  17777. /** @hidden */
  17778. _rebuild(): void;
  17779. /**
  17780. * Clear the info related to rendering groups preventing retention point in material dispose.
  17781. */
  17782. freeRenderingGroups(): void;
  17783. /**
  17784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17785. * @returns the view count
  17786. */
  17787. getViewCount(): number;
  17788. }
  17789. }
  17790. declare module BABYLON {
  17791. /**
  17792. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17793. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17794. * You can then easily use it as a reflectionTexture on a flat surface.
  17795. * In case the surface is not a plane, please consider relying on reflection probes.
  17796. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17797. */
  17798. export class MirrorTexture extends RenderTargetTexture {
  17799. private scene;
  17800. /**
  17801. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17802. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  17803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17804. */
  17805. mirrorPlane: Plane;
  17806. /**
  17807. * Define the blur ratio used to blur the reflection if needed.
  17808. */
  17809. blurRatio: number;
  17810. /**
  17811. * Define the adaptive blur kernel used to blur the reflection if needed.
  17812. * This will autocompute the closest best match for the `blurKernel`
  17813. */
  17814. adaptiveBlurKernel: number;
  17815. /**
  17816. * Define the blur kernel used to blur the reflection if needed.
  17817. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17818. */
  17819. blurKernel: number;
  17820. /**
  17821. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17822. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17823. */
  17824. blurKernelX: number;
  17825. /**
  17826. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17827. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17828. */
  17829. blurKernelY: number;
  17830. private _autoComputeBlurKernel;
  17831. protected _onRatioRescale(): void;
  17832. private _updateGammaSpace;
  17833. private _imageProcessingConfigChangeObserver;
  17834. private _transformMatrix;
  17835. private _mirrorMatrix;
  17836. private _savedViewMatrix;
  17837. private _blurX;
  17838. private _blurY;
  17839. private _adaptiveBlurKernel;
  17840. private _blurKernelX;
  17841. private _blurKernelY;
  17842. private _blurRatio;
  17843. /**
  17844. * Instantiates a Mirror Texture.
  17845. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17846. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17847. * You can then easily use it as a reflectionTexture on a flat surface.
  17848. * In case the surface is not a plane, please consider relying on reflection probes.
  17849. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17850. * @param name
  17851. * @param size
  17852. * @param scene
  17853. * @param generateMipMaps
  17854. * @param type
  17855. * @param samplingMode
  17856. * @param generateDepthBuffer
  17857. */
  17858. constructor(name: string, size: number | {
  17859. width: number;
  17860. height: number;
  17861. } | {
  17862. ratio: number;
  17863. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17864. private _preparePostProcesses;
  17865. /**
  17866. * Clone the mirror texture.
  17867. * @returns the cloned texture
  17868. */
  17869. clone(): MirrorTexture;
  17870. /**
  17871. * Serialize the texture to a JSON representation you could use in Parse later on
  17872. * @returns the serialized JSON representation
  17873. */
  17874. serialize(): any;
  17875. /**
  17876. * Dispose the texture and release its associated resources.
  17877. */
  17878. dispose(): void;
  17879. }
  17880. }
  17881. declare module BABYLON {
  17882. /**
  17883. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17884. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17885. */
  17886. export class Texture extends BaseTexture {
  17887. /** @hidden */
  17888. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17889. /** @hidden */
  17890. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17891. /** @hidden */
  17892. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17893. /** nearest is mag = nearest and min = nearest and mip = linear */
  17894. static readonly NEAREST_SAMPLINGMODE: number;
  17895. /** nearest is mag = nearest and min = nearest and mip = linear */
  17896. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17897. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17898. static readonly BILINEAR_SAMPLINGMODE: number;
  17899. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17900. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17901. /** Trilinear is mag = linear and min = linear and mip = linear */
  17902. static readonly TRILINEAR_SAMPLINGMODE: number;
  17903. /** Trilinear is mag = linear and min = linear and mip = linear */
  17904. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17905. /** mag = nearest and min = nearest and mip = nearest */
  17906. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17907. /** mag = nearest and min = linear and mip = nearest */
  17908. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17909. /** mag = nearest and min = linear and mip = linear */
  17910. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17911. /** mag = nearest and min = linear and mip = none */
  17912. static readonly NEAREST_LINEAR: number;
  17913. /** mag = nearest and min = nearest and mip = none */
  17914. static readonly NEAREST_NEAREST: number;
  17915. /** mag = linear and min = nearest and mip = nearest */
  17916. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17917. /** mag = linear and min = nearest and mip = linear */
  17918. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17919. /** mag = linear and min = linear and mip = none */
  17920. static readonly LINEAR_LINEAR: number;
  17921. /** mag = linear and min = nearest and mip = none */
  17922. static readonly LINEAR_NEAREST: number;
  17923. /** Explicit coordinates mode */
  17924. static readonly EXPLICIT_MODE: number;
  17925. /** Spherical coordinates mode */
  17926. static readonly SPHERICAL_MODE: number;
  17927. /** Planar coordinates mode */
  17928. static readonly PLANAR_MODE: number;
  17929. /** Cubic coordinates mode */
  17930. static readonly CUBIC_MODE: number;
  17931. /** Projection coordinates mode */
  17932. static readonly PROJECTION_MODE: number;
  17933. /** Inverse Cubic coordinates mode */
  17934. static readonly SKYBOX_MODE: number;
  17935. /** Inverse Cubic coordinates mode */
  17936. static readonly INVCUBIC_MODE: number;
  17937. /** Equirectangular coordinates mode */
  17938. static readonly EQUIRECTANGULAR_MODE: number;
  17939. /** Equirectangular Fixed coordinates mode */
  17940. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17941. /** Equirectangular Fixed Mirrored coordinates mode */
  17942. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17943. /** Texture is not repeating outside of 0..1 UVs */
  17944. static readonly CLAMP_ADDRESSMODE: number;
  17945. /** Texture is repeating outside of 0..1 UVs */
  17946. static readonly WRAP_ADDRESSMODE: number;
  17947. /** Texture is repeating and mirrored */
  17948. static readonly MIRROR_ADDRESSMODE: number;
  17949. /**
  17950. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  17951. */
  17952. static UseSerializedUrlIfAny: boolean;
  17953. /**
  17954. * Define the url of the texture.
  17955. */
  17956. url: Nullable<string>;
  17957. /**
  17958. * Define an offset on the texture to offset the u coordinates of the UVs
  17959. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17960. */
  17961. uOffset: number;
  17962. /**
  17963. * Define an offset on the texture to offset the v coordinates of the UVs
  17964. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17965. */
  17966. vOffset: number;
  17967. /**
  17968. * Define an offset on the texture to scale the u coordinates of the UVs
  17969. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17970. */
  17971. uScale: number;
  17972. /**
  17973. * Define an offset on the texture to scale the v coordinates of the UVs
  17974. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17975. */
  17976. vScale: number;
  17977. /**
  17978. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17979. * @see http://doc.babylonjs.com/how_to/more_materials
  17980. */
  17981. uAng: number;
  17982. /**
  17983. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17984. * @see http://doc.babylonjs.com/how_to/more_materials
  17985. */
  17986. vAng: number;
  17987. /**
  17988. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17989. * @see http://doc.babylonjs.com/how_to/more_materials
  17990. */
  17991. wAng: number;
  17992. /**
  17993. * Defines the center of rotation (U)
  17994. */
  17995. uRotationCenter: number;
  17996. /**
  17997. * Defines the center of rotation (V)
  17998. */
  17999. vRotationCenter: number;
  18000. /**
  18001. * Defines the center of rotation (W)
  18002. */
  18003. wRotationCenter: number;
  18004. /**
  18005. * Are mip maps generated for this texture or not.
  18006. */
  18007. readonly noMipmap: boolean;
  18008. /**
  18009. * List of inspectable custom properties (used by the Inspector)
  18010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18011. */
  18012. inspectableCustomProperties: Nullable<IInspectable[]>;
  18013. private _noMipmap;
  18014. /** @hidden */
  18015. _invertY: boolean;
  18016. private _rowGenerationMatrix;
  18017. private _cachedTextureMatrix;
  18018. private _projectionModeMatrix;
  18019. private _t0;
  18020. private _t1;
  18021. private _t2;
  18022. private _cachedUOffset;
  18023. private _cachedVOffset;
  18024. private _cachedUScale;
  18025. private _cachedVScale;
  18026. private _cachedUAng;
  18027. private _cachedVAng;
  18028. private _cachedWAng;
  18029. private _cachedProjectionMatrixId;
  18030. private _cachedCoordinatesMode;
  18031. /** @hidden */
  18032. protected _initialSamplingMode: number;
  18033. /** @hidden */
  18034. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18035. private _deleteBuffer;
  18036. protected _format: Nullable<number>;
  18037. private _delayedOnLoad;
  18038. private _delayedOnError;
  18039. /**
  18040. * Observable triggered once the texture has been loaded.
  18041. */
  18042. onLoadObservable: Observable<Texture>;
  18043. protected _isBlocking: boolean;
  18044. /**
  18045. * Is the texture preventing material to render while loading.
  18046. * If false, a default texture will be used instead of the loading one during the preparation step.
  18047. */
  18048. isBlocking: boolean;
  18049. /**
  18050. * Get the current sampling mode associated with the texture.
  18051. */
  18052. readonly samplingMode: number;
  18053. /**
  18054. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18055. */
  18056. readonly invertY: boolean;
  18057. /**
  18058. * Instantiates a new texture.
  18059. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18060. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18061. * @param url define the url of the picture to load as a texture
  18062. * @param scene define the scene the texture will belong to
  18063. * @param noMipmap define if the texture will require mip maps or not
  18064. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18065. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18066. * @param onLoad define a callback triggered when the texture has been loaded
  18067. * @param onError define a callback triggered when an error occurred during the loading session
  18068. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18069. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18070. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18071. */
  18072. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18073. /**
  18074. * Update the url (and optional buffer) of this texture if url was null during construction.
  18075. * @param url the url of the texture
  18076. * @param buffer the buffer of the texture (defaults to null)
  18077. * @param onLoad callback called when the texture is loaded (defaults to null)
  18078. */
  18079. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18080. /**
  18081. * Finish the loading sequence of a texture flagged as delayed load.
  18082. * @hidden
  18083. */
  18084. delayLoad(): void;
  18085. private _prepareRowForTextureGeneration;
  18086. /**
  18087. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18088. * @returns the transform matrix of the texture.
  18089. */
  18090. getTextureMatrix(): Matrix;
  18091. /**
  18092. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18093. * @returns The reflection texture transform
  18094. */
  18095. getReflectionTextureMatrix(): Matrix;
  18096. /**
  18097. * Clones the texture.
  18098. * @returns the cloned texture
  18099. */
  18100. clone(): Texture;
  18101. /**
  18102. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18103. * @returns The JSON representation of the texture
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Get the current class name of the texture useful for serialization or dynamic coding.
  18108. * @returns "Texture"
  18109. */
  18110. getClassName(): string;
  18111. /**
  18112. * Dispose the texture and release its associated resources.
  18113. */
  18114. dispose(): void;
  18115. /**
  18116. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18117. * @param parsedTexture Define the JSON representation of the texture
  18118. * @param scene Define the scene the parsed texture should be instantiated in
  18119. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18120. * @returns The parsed texture if successful
  18121. */
  18122. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18123. /**
  18124. * Creates a texture from its base 64 representation.
  18125. * @param data Define the base64 payload without the data: prefix
  18126. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18127. * @param scene Define the scene the texture should belong to
  18128. * @param noMipmap Forces the texture to not create mip map information if true
  18129. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18130. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18131. * @param onLoad define a callback triggered when the texture has been loaded
  18132. * @param onError define a callback triggered when an error occurred during the loading session
  18133. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18134. * @returns the created texture
  18135. */
  18136. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18137. /**
  18138. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18139. * @param data Define the base64 payload without the data: prefix
  18140. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18141. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18142. * @param scene Define the scene the texture should belong to
  18143. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18144. * @param noMipmap Forces the texture to not create mip map information if true
  18145. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18146. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18147. * @param onLoad define a callback triggered when the texture has been loaded
  18148. * @param onError define a callback triggered when an error occurred during the loading session
  18149. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18150. * @returns the created texture
  18151. */
  18152. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  18153. }
  18154. }
  18155. declare module BABYLON {
  18156. interface Engine {
  18157. /**
  18158. * Creates a raw texture
  18159. * @param data defines the data to store in the texture
  18160. * @param width defines the width of the texture
  18161. * @param height defines the height of the texture
  18162. * @param format defines the format of the data
  18163. * @param generateMipMaps defines if the engine should generate the mip levels
  18164. * @param invertY defines if data must be stored with Y axis inverted
  18165. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18166. * @param compression defines the compression used (null by default)
  18167. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18168. * @returns the raw texture inside an InternalTexture
  18169. */
  18170. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18171. /**
  18172. * Update a raw texture
  18173. * @param texture defines the texture to update
  18174. * @param data defines the data to store in the texture
  18175. * @param format defines the format of the data
  18176. * @param invertY defines if data must be stored with Y axis inverted
  18177. */
  18178. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18179. /**
  18180. * Update a raw texture
  18181. * @param texture defines the texture to update
  18182. * @param data defines the data to store in the texture
  18183. * @param format defines the format of the data
  18184. * @param invertY defines if data must be stored with Y axis inverted
  18185. * @param compression defines the compression used (null by default)
  18186. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18187. */
  18188. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18189. /**
  18190. * Creates a new raw cube texture
  18191. * @param data defines the array of data to use to create each face
  18192. * @param size defines the size of the textures
  18193. * @param format defines the format of the data
  18194. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18195. * @param generateMipMaps defines if the engine should generate the mip levels
  18196. * @param invertY defines if data must be stored with Y axis inverted
  18197. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18198. * @param compression defines the compression used (null by default)
  18199. * @returns the cube texture as an InternalTexture
  18200. */
  18201. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18202. /**
  18203. * Update a raw cube texture
  18204. * @param texture defines the texture to udpdate
  18205. * @param data defines the data to store
  18206. * @param format defines the data format
  18207. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18208. * @param invertY defines if data must be stored with Y axis inverted
  18209. */
  18210. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18211. /**
  18212. * Update a raw cube texture
  18213. * @param texture defines the texture to udpdate
  18214. * @param data defines the data to store
  18215. * @param format defines the data format
  18216. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18217. * @param invertY defines if data must be stored with Y axis inverted
  18218. * @param compression defines the compression used (null by default)
  18219. */
  18220. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18221. /**
  18222. * Update a raw cube texture
  18223. * @param texture defines the texture to udpdate
  18224. * @param data defines the data to store
  18225. * @param format defines the data format
  18226. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18227. * @param invertY defines if data must be stored with Y axis inverted
  18228. * @param compression defines the compression used (null by default)
  18229. * @param level defines which level of the texture to update
  18230. */
  18231. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18232. /**
  18233. * Creates a new raw cube texture from a specified url
  18234. * @param url defines the url where the data is located
  18235. * @param scene defines the current scene
  18236. * @param size defines the size of the textures
  18237. * @param format defines the format of the data
  18238. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18239. * @param noMipmap defines if the engine should avoid generating the mip levels
  18240. * @param callback defines a callback used to extract texture data from loaded data
  18241. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18242. * @param onLoad defines a callback called when texture is loaded
  18243. * @param onError defines a callback called if there is an error
  18244. * @returns the cube texture as an InternalTexture
  18245. */
  18246. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  18247. /**
  18248. * Creates a new raw cube texture from a specified url
  18249. * @param url defines the url where the data is located
  18250. * @param scene defines the current scene
  18251. * @param size defines the size of the textures
  18252. * @param format defines the format of the data
  18253. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18254. * @param noMipmap defines if the engine should avoid generating the mip levels
  18255. * @param callback defines a callback used to extract texture data from loaded data
  18256. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18257. * @param onLoad defines a callback called when texture is loaded
  18258. * @param onError defines a callback called if there is an error
  18259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18260. * @param invertY defines if data must be stored with Y axis inverted
  18261. * @returns the cube texture as an InternalTexture
  18262. */
  18263. 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;
  18264. /**
  18265. * Creates a new raw 3D texture
  18266. * @param data defines the data used to create the texture
  18267. * @param width defines the width of the texture
  18268. * @param height defines the height of the texture
  18269. * @param depth defines the depth of the texture
  18270. * @param format defines the format of the texture
  18271. * @param generateMipMaps defines if the engine must generate mip levels
  18272. * @param invertY defines if data must be stored with Y axis inverted
  18273. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18274. * @param compression defines the compressed used (can be null)
  18275. * @param textureType defines the compressed used (can be null)
  18276. * @returns a new raw 3D texture (stored in an InternalTexture)
  18277. */
  18278. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18279. /**
  18280. * Update a raw 3D texture
  18281. * @param texture defines the texture to update
  18282. * @param data defines the data to store
  18283. * @param format defines the data format
  18284. * @param invertY defines if data must be stored with Y axis inverted
  18285. */
  18286. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18287. /**
  18288. * Update a raw 3D texture
  18289. * @param texture defines the texture to update
  18290. * @param data defines the data to store
  18291. * @param format defines the data format
  18292. * @param invertY defines if data must be stored with Y axis inverted
  18293. * @param compression defines the used compression (can be null)
  18294. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18295. */
  18296. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Raw texture can help creating a texture directly from an array of data.
  18302. * This can be super useful if you either get the data from an uncompressed source or
  18303. * if you wish to create your texture pixel by pixel.
  18304. */
  18305. export class RawTexture extends Texture {
  18306. /**
  18307. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18308. */
  18309. format: number;
  18310. private _engine;
  18311. /**
  18312. * Instantiates a new RawTexture.
  18313. * Raw texture can help creating a texture directly from an array of data.
  18314. * This can be super useful if you either get the data from an uncompressed source or
  18315. * if you wish to create your texture pixel by pixel.
  18316. * @param data define the array of data to use to create the texture
  18317. * @param width define the width of the texture
  18318. * @param height define the height of the texture
  18319. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18320. * @param scene define the scene the texture belongs to
  18321. * @param generateMipMaps define whether mip maps should be generated or not
  18322. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18323. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18324. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18325. */
  18326. constructor(data: ArrayBufferView, width: number, height: number,
  18327. /**
  18328. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18329. */
  18330. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18331. /**
  18332. * Updates the texture underlying data.
  18333. * @param data Define the new data of the texture
  18334. */
  18335. update(data: ArrayBufferView): void;
  18336. /**
  18337. * Creates a luminance texture from some data.
  18338. * @param data Define the texture data
  18339. * @param width Define the width of the texture
  18340. * @param height Define the height of the texture
  18341. * @param scene Define the scene the texture belongs to
  18342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18345. * @returns the luminance texture
  18346. */
  18347. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18348. /**
  18349. * Creates a luminance alpha texture from some data.
  18350. * @param data Define the texture data
  18351. * @param width Define the width of the texture
  18352. * @param height Define the height of the texture
  18353. * @param scene Define the scene the texture belongs to
  18354. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18355. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18356. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18357. * @returns the luminance alpha texture
  18358. */
  18359. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18360. /**
  18361. * Creates an alpha texture from some data.
  18362. * @param data Define the texture data
  18363. * @param width Define the width of the texture
  18364. * @param height Define the height of the texture
  18365. * @param scene Define the scene the texture belongs to
  18366. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18367. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18368. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18369. * @returns the alpha texture
  18370. */
  18371. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18372. /**
  18373. * Creates a RGB texture from some data.
  18374. * @param data Define the texture data
  18375. * @param width Define the width of the texture
  18376. * @param height Define the height of the texture
  18377. * @param scene Define the scene the texture belongs to
  18378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18381. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18382. * @returns the RGB alpha texture
  18383. */
  18384. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18385. /**
  18386. * Creates a RGBA texture from some data.
  18387. * @param data Define the texture data
  18388. * @param width Define the width of the texture
  18389. * @param height Define the height of the texture
  18390. * @param scene Define the scene the texture belongs to
  18391. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18392. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18393. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18394. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18395. * @returns the RGBA texture
  18396. */
  18397. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18398. /**
  18399. * Creates a R texture from some data.
  18400. * @param data Define the texture data
  18401. * @param width Define the width of the texture
  18402. * @param height Define the height of the texture
  18403. * @param scene Define the scene the texture belongs to
  18404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18408. * @returns the R texture
  18409. */
  18410. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18411. }
  18412. }
  18413. declare module BABYLON {
  18414. /**
  18415. * Defines a runtime animation
  18416. */
  18417. export class RuntimeAnimation {
  18418. private _events;
  18419. /**
  18420. * The current frame of the runtime animation
  18421. */
  18422. private _currentFrame;
  18423. /**
  18424. * The animation used by the runtime animation
  18425. */
  18426. private _animation;
  18427. /**
  18428. * The target of the runtime animation
  18429. */
  18430. private _target;
  18431. /**
  18432. * The initiating animatable
  18433. */
  18434. private _host;
  18435. /**
  18436. * The original value of the runtime animation
  18437. */
  18438. private _originalValue;
  18439. /**
  18440. * The original blend value of the runtime animation
  18441. */
  18442. private _originalBlendValue;
  18443. /**
  18444. * The offsets cache of the runtime animation
  18445. */
  18446. private _offsetsCache;
  18447. /**
  18448. * The high limits cache of the runtime animation
  18449. */
  18450. private _highLimitsCache;
  18451. /**
  18452. * Specifies if the runtime animation has been stopped
  18453. */
  18454. private _stopped;
  18455. /**
  18456. * The blending factor of the runtime animation
  18457. */
  18458. private _blendingFactor;
  18459. /**
  18460. * The BabylonJS scene
  18461. */
  18462. private _scene;
  18463. /**
  18464. * The current value of the runtime animation
  18465. */
  18466. private _currentValue;
  18467. /** @hidden */
  18468. _animationState: _IAnimationState;
  18469. /**
  18470. * The active target of the runtime animation
  18471. */
  18472. private _activeTargets;
  18473. private _currentActiveTarget;
  18474. private _directTarget;
  18475. /**
  18476. * The target path of the runtime animation
  18477. */
  18478. private _targetPath;
  18479. /**
  18480. * The weight of the runtime animation
  18481. */
  18482. private _weight;
  18483. /**
  18484. * The ratio offset of the runtime animation
  18485. */
  18486. private _ratioOffset;
  18487. /**
  18488. * The previous delay of the runtime animation
  18489. */
  18490. private _previousDelay;
  18491. /**
  18492. * The previous ratio of the runtime animation
  18493. */
  18494. private _previousRatio;
  18495. private _enableBlending;
  18496. private _keys;
  18497. private _minFrame;
  18498. private _maxFrame;
  18499. private _minValue;
  18500. private _maxValue;
  18501. private _targetIsArray;
  18502. /**
  18503. * Gets the current frame of the runtime animation
  18504. */
  18505. readonly currentFrame: number;
  18506. /**
  18507. * Gets the weight of the runtime animation
  18508. */
  18509. readonly weight: number;
  18510. /**
  18511. * Gets the current value of the runtime animation
  18512. */
  18513. readonly currentValue: any;
  18514. /**
  18515. * Gets the target path of the runtime animation
  18516. */
  18517. readonly targetPath: string;
  18518. /**
  18519. * Gets the actual target of the runtime animation
  18520. */
  18521. readonly target: any;
  18522. /** @hidden */
  18523. _onLoop: () => void;
  18524. /**
  18525. * Create a new RuntimeAnimation object
  18526. * @param target defines the target of the animation
  18527. * @param animation defines the source animation object
  18528. * @param scene defines the hosting scene
  18529. * @param host defines the initiating Animatable
  18530. */
  18531. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18532. private _preparePath;
  18533. /**
  18534. * Gets the animation from the runtime animation
  18535. */
  18536. readonly animation: Animation;
  18537. /**
  18538. * Resets the runtime animation to the beginning
  18539. * @param restoreOriginal defines whether to restore the target property to the original value
  18540. */
  18541. reset(restoreOriginal?: boolean): void;
  18542. /**
  18543. * Specifies if the runtime animation is stopped
  18544. * @returns Boolean specifying if the runtime animation is stopped
  18545. */
  18546. isStopped(): boolean;
  18547. /**
  18548. * Disposes of the runtime animation
  18549. */
  18550. dispose(): void;
  18551. /**
  18552. * Apply the interpolated value to the target
  18553. * @param currentValue defines the value computed by the animation
  18554. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18555. */
  18556. setValue(currentValue: any, weight: number): void;
  18557. private _getOriginalValues;
  18558. private _setValue;
  18559. /**
  18560. * Gets the loop pmode of the runtime animation
  18561. * @returns Loop Mode
  18562. */
  18563. private _getCorrectLoopMode;
  18564. /**
  18565. * Move the current animation to a given frame
  18566. * @param frame defines the frame to move to
  18567. */
  18568. goToFrame(frame: number): void;
  18569. /**
  18570. * @hidden Internal use only
  18571. */
  18572. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18573. /**
  18574. * Execute the current animation
  18575. * @param delay defines the delay to add to the current frame
  18576. * @param from defines the lower bound of the animation range
  18577. * @param to defines the upper bound of the animation range
  18578. * @param loop defines if the current animation must loop
  18579. * @param speedRatio defines the current speed ratio
  18580. * @param weight defines the weight of the animation (default is -1 so no weight)
  18581. * @param onLoop optional callback called when animation loops
  18582. * @returns a boolean indicating if the animation is running
  18583. */
  18584. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18585. }
  18586. }
  18587. declare module BABYLON {
  18588. /**
  18589. * Class used to store an actual running animation
  18590. */
  18591. export class Animatable {
  18592. /** defines the target object */
  18593. target: any;
  18594. /** defines the starting frame number (default is 0) */
  18595. fromFrame: number;
  18596. /** defines the ending frame number (default is 100) */
  18597. toFrame: number;
  18598. /** defines if the animation must loop (default is false) */
  18599. loopAnimation: boolean;
  18600. /** defines a callback to call when animation ends if it is not looping */
  18601. onAnimationEnd?: (() => void) | null | undefined;
  18602. /** defines a callback to call when animation loops */
  18603. onAnimationLoop?: (() => void) | null | undefined;
  18604. private _localDelayOffset;
  18605. private _pausedDelay;
  18606. private _runtimeAnimations;
  18607. private _paused;
  18608. private _scene;
  18609. private _speedRatio;
  18610. private _weight;
  18611. private _syncRoot;
  18612. /**
  18613. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18614. * This will only apply for non looping animation (default is true)
  18615. */
  18616. disposeOnEnd: boolean;
  18617. /**
  18618. * Gets a boolean indicating if the animation has started
  18619. */
  18620. animationStarted: boolean;
  18621. /**
  18622. * Observer raised when the animation ends
  18623. */
  18624. onAnimationEndObservable: Observable<Animatable>;
  18625. /**
  18626. * Observer raised when the animation loops
  18627. */
  18628. onAnimationLoopObservable: Observable<Animatable>;
  18629. /**
  18630. * Gets the root Animatable used to synchronize and normalize animations
  18631. */
  18632. readonly syncRoot: Nullable<Animatable>;
  18633. /**
  18634. * Gets the current frame of the first RuntimeAnimation
  18635. * Used to synchronize Animatables
  18636. */
  18637. readonly masterFrame: number;
  18638. /**
  18639. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18640. */
  18641. weight: number;
  18642. /**
  18643. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18644. */
  18645. speedRatio: number;
  18646. /**
  18647. * Creates a new Animatable
  18648. * @param scene defines the hosting scene
  18649. * @param target defines the target object
  18650. * @param fromFrame defines the starting frame number (default is 0)
  18651. * @param toFrame defines the ending frame number (default is 100)
  18652. * @param loopAnimation defines if the animation must loop (default is false)
  18653. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18654. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18655. * @param animations defines a group of animation to add to the new Animatable
  18656. * @param onAnimationLoop defines a callback to call when animation loops
  18657. */
  18658. constructor(scene: Scene,
  18659. /** defines the target object */
  18660. target: any,
  18661. /** defines the starting frame number (default is 0) */
  18662. fromFrame?: number,
  18663. /** defines the ending frame number (default is 100) */
  18664. toFrame?: number,
  18665. /** defines if the animation must loop (default is false) */
  18666. loopAnimation?: boolean, speedRatio?: number,
  18667. /** defines a callback to call when animation ends if it is not looping */
  18668. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18669. /** defines a callback to call when animation loops */
  18670. onAnimationLoop?: (() => void) | null | undefined);
  18671. /**
  18672. * Synchronize and normalize current Animatable with a source Animatable
  18673. * This is useful when using animation weights and when animations are not of the same length
  18674. * @param root defines the root Animatable to synchronize with
  18675. * @returns the current Animatable
  18676. */
  18677. syncWith(root: Animatable): Animatable;
  18678. /**
  18679. * Gets the list of runtime animations
  18680. * @returns an array of RuntimeAnimation
  18681. */
  18682. getAnimations(): RuntimeAnimation[];
  18683. /**
  18684. * Adds more animations to the current animatable
  18685. * @param target defines the target of the animations
  18686. * @param animations defines the new animations to add
  18687. */
  18688. appendAnimations(target: any, animations: Animation[]): void;
  18689. /**
  18690. * Gets the source animation for a specific property
  18691. * @param property defines the propertyu to look for
  18692. * @returns null or the source animation for the given property
  18693. */
  18694. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18695. /**
  18696. * Gets the runtime animation for a specific property
  18697. * @param property defines the propertyu to look for
  18698. * @returns null or the runtime animation for the given property
  18699. */
  18700. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18701. /**
  18702. * Resets the animatable to its original state
  18703. */
  18704. reset(): void;
  18705. /**
  18706. * Allows the animatable to blend with current running animations
  18707. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18708. * @param blendingSpeed defines the blending speed to use
  18709. */
  18710. enableBlending(blendingSpeed: number): void;
  18711. /**
  18712. * Disable animation blending
  18713. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18714. */
  18715. disableBlending(): void;
  18716. /**
  18717. * Jump directly to a given frame
  18718. * @param frame defines the frame to jump to
  18719. */
  18720. goToFrame(frame: number): void;
  18721. /**
  18722. * Pause the animation
  18723. */
  18724. pause(): void;
  18725. /**
  18726. * Restart the animation
  18727. */
  18728. restart(): void;
  18729. private _raiseOnAnimationEnd;
  18730. /**
  18731. * Stop and delete the current animation
  18732. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18733. * @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)
  18734. */
  18735. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18736. /**
  18737. * Wait asynchronously for the animation to end
  18738. * @returns a promise which will be fullfilled when the animation ends
  18739. */
  18740. waitAsync(): Promise<Animatable>;
  18741. /** @hidden */
  18742. _animate(delay: number): boolean;
  18743. }
  18744. interface Scene {
  18745. /** @hidden */
  18746. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18747. /** @hidden */
  18748. _processLateAnimationBindingsForMatrices(holder: {
  18749. totalWeight: number;
  18750. animations: RuntimeAnimation[];
  18751. originalValue: Matrix;
  18752. }): any;
  18753. /** @hidden */
  18754. _processLateAnimationBindingsForQuaternions(holder: {
  18755. totalWeight: number;
  18756. animations: RuntimeAnimation[];
  18757. originalValue: Quaternion;
  18758. }, refQuaternion: Quaternion): Quaternion;
  18759. /** @hidden */
  18760. _processLateAnimationBindings(): void;
  18761. /**
  18762. * Will start the animation sequence of a given target
  18763. * @param target defines the target
  18764. * @param from defines from which frame should animation start
  18765. * @param to defines until which frame should animation run.
  18766. * @param weight defines the weight to apply to the animation (1.0 by default)
  18767. * @param loop defines if the animation loops
  18768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18769. * @param onAnimationEnd defines the function to be executed when the animation ends
  18770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18772. * @param onAnimationLoop defines the callback to call when an animation loops
  18773. * @returns the animatable object created for this animation
  18774. */
  18775. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18776. /**
  18777. * Will start the animation sequence of a given target
  18778. * @param target defines the target
  18779. * @param from defines from which frame should animation start
  18780. * @param to defines until which frame should animation run.
  18781. * @param loop defines if the animation loops
  18782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18783. * @param onAnimationEnd defines the function to be executed when the animation ends
  18784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18786. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18787. * @param onAnimationLoop defines the callback to call when an animation loops
  18788. * @returns the animatable object created for this animation
  18789. */
  18790. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18791. /**
  18792. * Will start the animation sequence of a given target and its hierarchy
  18793. * @param target defines the target
  18794. * @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.
  18795. * @param from defines from which frame should animation start
  18796. * @param to defines until which frame should animation run.
  18797. * @param loop defines if the animation loops
  18798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18799. * @param onAnimationEnd defines the function to be executed when the animation ends
  18800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18802. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18803. * @param onAnimationLoop defines the callback to call when an animation loops
  18804. * @returns the list of created animatables
  18805. */
  18806. 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[];
  18807. /**
  18808. * Begin a new animation on a given node
  18809. * @param target defines the target where the animation will take place
  18810. * @param animations defines the list of animations to start
  18811. * @param from defines the initial value
  18812. * @param to defines the final value
  18813. * @param loop defines if you want animation to loop (off by default)
  18814. * @param speedRatio defines the speed ratio to apply to all animations
  18815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18816. * @param onAnimationLoop defines the callback to call when an animation loops
  18817. * @returns the list of created animatables
  18818. */
  18819. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18820. /**
  18821. * Begin a new animation on a given node and its hierarchy
  18822. * @param target defines the root node where the animation will take place
  18823. * @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.
  18824. * @param animations defines the list of animations to start
  18825. * @param from defines the initial value
  18826. * @param to defines the final value
  18827. * @param loop defines if you want animation to loop (off by default)
  18828. * @param speedRatio defines the speed ratio to apply to all animations
  18829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18830. * @param onAnimationLoop defines the callback to call when an animation loops
  18831. * @returns the list of animatables created for all nodes
  18832. */
  18833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18834. /**
  18835. * Gets the animatable associated with a specific target
  18836. * @param target defines the target of the animatable
  18837. * @returns the required animatable if found
  18838. */
  18839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18840. /**
  18841. * Gets all animatables associated with a given target
  18842. * @param target defines the target to look animatables for
  18843. * @returns an array of Animatables
  18844. */
  18845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18846. /**
  18847. * Will stop the animation of the given target
  18848. * @param target - the target
  18849. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18850. * @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)
  18851. */
  18852. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18853. /**
  18854. * Stops and removes all animations that have been applied to the scene
  18855. */
  18856. stopAllAnimations(): void;
  18857. }
  18858. interface Bone {
  18859. /**
  18860. * Copy an animation range from another bone
  18861. * @param source defines the source bone
  18862. * @param rangeName defines the range name to copy
  18863. * @param frameOffset defines the frame offset
  18864. * @param rescaleAsRequired defines if rescaling must be applied if required
  18865. * @param skelDimensionsRatio defines the scaling ratio
  18866. * @returns true if operation was successful
  18867. */
  18868. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18869. }
  18870. }
  18871. declare module BABYLON {
  18872. /**
  18873. * Class used to handle skinning animations
  18874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18875. */
  18876. export class Skeleton implements IAnimatable {
  18877. /** defines the skeleton name */
  18878. name: string;
  18879. /** defines the skeleton Id */
  18880. id: string;
  18881. /**
  18882. * Defines the list of child bones
  18883. */
  18884. bones: Bone[];
  18885. /**
  18886. * Defines an estimate of the dimension of the skeleton at rest
  18887. */
  18888. dimensionsAtRest: Vector3;
  18889. /**
  18890. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18891. */
  18892. needInitialSkinMatrix: boolean;
  18893. /**
  18894. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18895. */
  18896. overrideMesh: Nullable<AbstractMesh>;
  18897. /**
  18898. * Gets the list of animations attached to this skeleton
  18899. */
  18900. animations: Array<Animation>;
  18901. private _scene;
  18902. private _isDirty;
  18903. private _transformMatrices;
  18904. private _transformMatrixTexture;
  18905. private _meshesWithPoseMatrix;
  18906. private _animatables;
  18907. private _identity;
  18908. private _synchronizedWithMesh;
  18909. private _ranges;
  18910. private _lastAbsoluteTransformsUpdateId;
  18911. private _canUseTextureForBones;
  18912. private _uniqueId;
  18913. /** @hidden */
  18914. _numBonesWithLinkedTransformNode: number;
  18915. /**
  18916. * Specifies if the skeleton should be serialized
  18917. */
  18918. doNotSerialize: boolean;
  18919. private _useTextureToStoreBoneMatrices;
  18920. /**
  18921. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18922. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18923. */
  18924. useTextureToStoreBoneMatrices: boolean;
  18925. private _animationPropertiesOverride;
  18926. /**
  18927. * Gets or sets the animation properties override
  18928. */
  18929. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18930. /**
  18931. * List of inspectable custom properties (used by the Inspector)
  18932. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18933. */
  18934. inspectableCustomProperties: IInspectable[];
  18935. /**
  18936. * An observable triggered before computing the skeleton's matrices
  18937. */
  18938. onBeforeComputeObservable: Observable<Skeleton>;
  18939. /**
  18940. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18941. */
  18942. readonly isUsingTextureForMatrices: boolean;
  18943. /**
  18944. * Gets the unique ID of this skeleton
  18945. */
  18946. readonly uniqueId: number;
  18947. /**
  18948. * Creates a new skeleton
  18949. * @param name defines the skeleton name
  18950. * @param id defines the skeleton Id
  18951. * @param scene defines the hosting scene
  18952. */
  18953. constructor(
  18954. /** defines the skeleton name */
  18955. name: string,
  18956. /** defines the skeleton Id */
  18957. id: string, scene: Scene);
  18958. /**
  18959. * Gets the current object class name.
  18960. * @return the class name
  18961. */
  18962. getClassName(): string;
  18963. /**
  18964. * Returns an array containing the root bones
  18965. * @returns an array containing the root bones
  18966. */
  18967. getChildren(): Array<Bone>;
  18968. /**
  18969. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18970. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18971. * @returns a Float32Array containing matrices data
  18972. */
  18973. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18974. /**
  18975. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18976. * @returns a raw texture containing the data
  18977. */
  18978. getTransformMatrixTexture(): Nullable<RawTexture>;
  18979. /**
  18980. * Gets the current hosting scene
  18981. * @returns a scene object
  18982. */
  18983. getScene(): Scene;
  18984. /**
  18985. * Gets a string representing the current skeleton data
  18986. * @param fullDetails defines a boolean indicating if we want a verbose version
  18987. * @returns a string representing the current skeleton data
  18988. */
  18989. toString(fullDetails?: boolean): string;
  18990. /**
  18991. * Get bone's index searching by name
  18992. * @param name defines bone's name to search for
  18993. * @return the indice of the bone. Returns -1 if not found
  18994. */
  18995. getBoneIndexByName(name: string): number;
  18996. /**
  18997. * Creater a new animation range
  18998. * @param name defines the name of the range
  18999. * @param from defines the start key
  19000. * @param to defines the end key
  19001. */
  19002. createAnimationRange(name: string, from: number, to: number): void;
  19003. /**
  19004. * Delete a specific animation range
  19005. * @param name defines the name of the range
  19006. * @param deleteFrames defines if frames must be removed as well
  19007. */
  19008. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19009. /**
  19010. * Gets a specific animation range
  19011. * @param name defines the name of the range to look for
  19012. * @returns the requested animation range or null if not found
  19013. */
  19014. getAnimationRange(name: string): Nullable<AnimationRange>;
  19015. /**
  19016. * Gets the list of all animation ranges defined on this skeleton
  19017. * @returns an array
  19018. */
  19019. getAnimationRanges(): Nullable<AnimationRange>[];
  19020. /**
  19021. * Copy animation range from a source skeleton.
  19022. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19023. * @param source defines the source skeleton
  19024. * @param name defines the name of the range to copy
  19025. * @param rescaleAsRequired defines if rescaling must be applied if required
  19026. * @returns true if operation was successful
  19027. */
  19028. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19029. /**
  19030. * Forces the skeleton to go to rest pose
  19031. */
  19032. returnToRest(): void;
  19033. private _getHighestAnimationFrame;
  19034. /**
  19035. * Begin a specific animation range
  19036. * @param name defines the name of the range to start
  19037. * @param loop defines if looping must be turned on (false by default)
  19038. * @param speedRatio defines the speed ratio to apply (1 by default)
  19039. * @param onAnimationEnd defines a callback which will be called when animation will end
  19040. * @returns a new animatable
  19041. */
  19042. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19043. /** @hidden */
  19044. _markAsDirty(): void;
  19045. /** @hidden */
  19046. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19047. /** @hidden */
  19048. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19049. private _computeTransformMatrices;
  19050. /**
  19051. * Build all resources required to render a skeleton
  19052. */
  19053. prepare(): void;
  19054. /**
  19055. * Gets the list of animatables currently running for this skeleton
  19056. * @returns an array of animatables
  19057. */
  19058. getAnimatables(): IAnimatable[];
  19059. /**
  19060. * Clone the current skeleton
  19061. * @param name defines the name of the new skeleton
  19062. * @param id defines the id of the new skeleton
  19063. * @returns the new skeleton
  19064. */
  19065. clone(name: string, id: string): Skeleton;
  19066. /**
  19067. * Enable animation blending for this skeleton
  19068. * @param blendingSpeed defines the blending speed to apply
  19069. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19070. */
  19071. enableBlending(blendingSpeed?: number): void;
  19072. /**
  19073. * Releases all resources associated with the current skeleton
  19074. */
  19075. dispose(): void;
  19076. /**
  19077. * Serialize the skeleton in a JSON object
  19078. * @returns a JSON object
  19079. */
  19080. serialize(): any;
  19081. /**
  19082. * Creates a new skeleton from serialized data
  19083. * @param parsedSkeleton defines the serialized data
  19084. * @param scene defines the hosting scene
  19085. * @returns a new skeleton
  19086. */
  19087. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19088. /**
  19089. * Compute all node absolute transforms
  19090. * @param forceUpdate defines if computation must be done even if cache is up to date
  19091. */
  19092. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19093. /**
  19094. * Gets the root pose matrix
  19095. * @returns a matrix
  19096. */
  19097. getPoseMatrix(): Nullable<Matrix>;
  19098. /**
  19099. * Sorts bones per internal index
  19100. */
  19101. sortBones(): void;
  19102. private _sortBones;
  19103. }
  19104. }
  19105. declare module BABYLON {
  19106. /**
  19107. * Defines a target to use with MorphTargetManager
  19108. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19109. */
  19110. export class MorphTarget implements IAnimatable {
  19111. /** defines the name of the target */
  19112. name: string;
  19113. /**
  19114. * Gets or sets the list of animations
  19115. */
  19116. animations: Animation[];
  19117. private _scene;
  19118. private _positions;
  19119. private _normals;
  19120. private _tangents;
  19121. private _influence;
  19122. /**
  19123. * Observable raised when the influence changes
  19124. */
  19125. onInfluenceChanged: Observable<boolean>;
  19126. /** @hidden */
  19127. _onDataLayoutChanged: Observable<void>;
  19128. /**
  19129. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19130. */
  19131. influence: number;
  19132. /**
  19133. * Gets or sets the id of the morph Target
  19134. */
  19135. id: string;
  19136. private _animationPropertiesOverride;
  19137. /**
  19138. * Gets or sets the animation properties override
  19139. */
  19140. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19141. /**
  19142. * Creates a new MorphTarget
  19143. * @param name defines the name of the target
  19144. * @param influence defines the influence to use
  19145. * @param scene defines the scene the morphtarget belongs to
  19146. */
  19147. constructor(
  19148. /** defines the name of the target */
  19149. name: string, influence?: number, scene?: Nullable<Scene>);
  19150. /**
  19151. * Gets a boolean defining if the target contains position data
  19152. */
  19153. readonly hasPositions: boolean;
  19154. /**
  19155. * Gets a boolean defining if the target contains normal data
  19156. */
  19157. readonly hasNormals: boolean;
  19158. /**
  19159. * Gets a boolean defining if the target contains tangent data
  19160. */
  19161. readonly hasTangents: boolean;
  19162. /**
  19163. * Affects position data to this target
  19164. * @param data defines the position data to use
  19165. */
  19166. setPositions(data: Nullable<FloatArray>): void;
  19167. /**
  19168. * Gets the position data stored in this target
  19169. * @returns a FloatArray containing the position data (or null if not present)
  19170. */
  19171. getPositions(): Nullable<FloatArray>;
  19172. /**
  19173. * Affects normal data to this target
  19174. * @param data defines the normal data to use
  19175. */
  19176. setNormals(data: Nullable<FloatArray>): void;
  19177. /**
  19178. * Gets the normal data stored in this target
  19179. * @returns a FloatArray containing the normal data (or null if not present)
  19180. */
  19181. getNormals(): Nullable<FloatArray>;
  19182. /**
  19183. * Affects tangent data to this target
  19184. * @param data defines the tangent data to use
  19185. */
  19186. setTangents(data: Nullable<FloatArray>): void;
  19187. /**
  19188. * Gets the tangent data stored in this target
  19189. * @returns a FloatArray containing the tangent data (or null if not present)
  19190. */
  19191. getTangents(): Nullable<FloatArray>;
  19192. /**
  19193. * Serializes the current target into a Serialization object
  19194. * @returns the serialized object
  19195. */
  19196. serialize(): any;
  19197. /**
  19198. * Returns the string "MorphTarget"
  19199. * @returns "MorphTarget"
  19200. */
  19201. getClassName(): string;
  19202. /**
  19203. * Creates a new target from serialized data
  19204. * @param serializationObject defines the serialized data to use
  19205. * @returns a new MorphTarget
  19206. */
  19207. static Parse(serializationObject: any): MorphTarget;
  19208. /**
  19209. * Creates a MorphTarget from mesh data
  19210. * @param mesh defines the source mesh
  19211. * @param name defines the name to use for the new target
  19212. * @param influence defines the influence to attach to the target
  19213. * @returns a new MorphTarget
  19214. */
  19215. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19216. }
  19217. }
  19218. declare module BABYLON {
  19219. /**
  19220. * This class is used to deform meshes using morphing between different targets
  19221. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19222. */
  19223. export class MorphTargetManager {
  19224. private _targets;
  19225. private _targetInfluenceChangedObservers;
  19226. private _targetDataLayoutChangedObservers;
  19227. private _activeTargets;
  19228. private _scene;
  19229. private _influences;
  19230. private _supportsNormals;
  19231. private _supportsTangents;
  19232. private _vertexCount;
  19233. private _uniqueId;
  19234. private _tempInfluences;
  19235. /**
  19236. * Creates a new MorphTargetManager
  19237. * @param scene defines the current scene
  19238. */
  19239. constructor(scene?: Nullable<Scene>);
  19240. /**
  19241. * Gets the unique ID of this manager
  19242. */
  19243. readonly uniqueId: number;
  19244. /**
  19245. * Gets the number of vertices handled by this manager
  19246. */
  19247. readonly vertexCount: number;
  19248. /**
  19249. * Gets a boolean indicating if this manager supports morphing of normals
  19250. */
  19251. readonly supportsNormals: boolean;
  19252. /**
  19253. * Gets a boolean indicating if this manager supports morphing of tangents
  19254. */
  19255. readonly supportsTangents: boolean;
  19256. /**
  19257. * Gets the number of targets stored in this manager
  19258. */
  19259. readonly numTargets: number;
  19260. /**
  19261. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19262. */
  19263. readonly numInfluencers: number;
  19264. /**
  19265. * Gets the list of influences (one per target)
  19266. */
  19267. readonly influences: Float32Array;
  19268. /**
  19269. * Gets the active target at specified index. An active target is a target with an influence > 0
  19270. * @param index defines the index to check
  19271. * @returns the requested target
  19272. */
  19273. getActiveTarget(index: number): MorphTarget;
  19274. /**
  19275. * Gets the target at specified index
  19276. * @param index defines the index to check
  19277. * @returns the requested target
  19278. */
  19279. getTarget(index: number): MorphTarget;
  19280. /**
  19281. * Add a new target to this manager
  19282. * @param target defines the target to add
  19283. */
  19284. addTarget(target: MorphTarget): void;
  19285. /**
  19286. * Removes a target from the manager
  19287. * @param target defines the target to remove
  19288. */
  19289. removeTarget(target: MorphTarget): void;
  19290. /**
  19291. * Serializes the current manager into a Serialization object
  19292. * @returns the serialized object
  19293. */
  19294. serialize(): any;
  19295. private _syncActiveTargets;
  19296. /**
  19297. * Syncrhonize the targets with all the meshes using this morph target manager
  19298. */
  19299. synchronize(): void;
  19300. /**
  19301. * Creates a new MorphTargetManager from serialized data
  19302. * @param serializationObject defines the serialized data
  19303. * @param scene defines the hosting scene
  19304. * @returns the new MorphTargetManager
  19305. */
  19306. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19307. }
  19308. }
  19309. declare module BABYLON {
  19310. /**
  19311. * Mesh representing the gorund
  19312. */
  19313. export class GroundMesh extends Mesh {
  19314. /** If octree should be generated */
  19315. generateOctree: boolean;
  19316. private _heightQuads;
  19317. /** @hidden */
  19318. _subdivisionsX: number;
  19319. /** @hidden */
  19320. _subdivisionsY: number;
  19321. /** @hidden */
  19322. _width: number;
  19323. /** @hidden */
  19324. _height: number;
  19325. /** @hidden */
  19326. _minX: number;
  19327. /** @hidden */
  19328. _maxX: number;
  19329. /** @hidden */
  19330. _minZ: number;
  19331. /** @hidden */
  19332. _maxZ: number;
  19333. constructor(name: string, scene: Scene);
  19334. /**
  19335. * "GroundMesh"
  19336. * @returns "GroundMesh"
  19337. */
  19338. getClassName(): string;
  19339. /**
  19340. * The minimum of x and y subdivisions
  19341. */
  19342. readonly subdivisions: number;
  19343. /**
  19344. * X subdivisions
  19345. */
  19346. readonly subdivisionsX: number;
  19347. /**
  19348. * Y subdivisions
  19349. */
  19350. readonly subdivisionsY: number;
  19351. /**
  19352. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19353. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19354. * @param chunksCount the number of subdivisions for x and y
  19355. * @param octreeBlocksSize (Default: 32)
  19356. */
  19357. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19358. /**
  19359. * Returns a height (y) value in the Worl system :
  19360. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19361. * @param x x coordinate
  19362. * @param z z coordinate
  19363. * @returns the ground y position if (x, z) are outside the ground surface.
  19364. */
  19365. getHeightAtCoordinates(x: number, z: number): number;
  19366. /**
  19367. * Returns a normalized vector (Vector3) orthogonal to the ground
  19368. * at the ground coordinates (x, z) expressed in the World system.
  19369. * @param x x coordinate
  19370. * @param z z coordinate
  19371. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19372. */
  19373. getNormalAtCoordinates(x: number, z: number): Vector3;
  19374. /**
  19375. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19376. * at the ground coordinates (x, z) expressed in the World system.
  19377. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19378. * @param x x coordinate
  19379. * @param z z coordinate
  19380. * @param ref vector to store the result
  19381. * @returns the GroundMesh.
  19382. */
  19383. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19384. /**
  19385. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19386. * if the ground has been updated.
  19387. * This can be used in the render loop.
  19388. * @returns the GroundMesh.
  19389. */
  19390. updateCoordinateHeights(): GroundMesh;
  19391. private _getFacetAt;
  19392. private _initHeightQuads;
  19393. private _computeHeightQuads;
  19394. /**
  19395. * Serializes this ground mesh
  19396. * @param serializationObject object to write serialization to
  19397. */
  19398. serialize(serializationObject: any): void;
  19399. /**
  19400. * Parses a serialized ground mesh
  19401. * @param parsedMesh the serialized mesh
  19402. * @param scene the scene to create the ground mesh in
  19403. * @returns the created ground mesh
  19404. */
  19405. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19406. }
  19407. }
  19408. declare module BABYLON {
  19409. /**
  19410. * Interface for Physics-Joint data
  19411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19412. */
  19413. export interface PhysicsJointData {
  19414. /**
  19415. * The main pivot of the joint
  19416. */
  19417. mainPivot?: Vector3;
  19418. /**
  19419. * The connected pivot of the joint
  19420. */
  19421. connectedPivot?: Vector3;
  19422. /**
  19423. * The main axis of the joint
  19424. */
  19425. mainAxis?: Vector3;
  19426. /**
  19427. * The connected axis of the joint
  19428. */
  19429. connectedAxis?: Vector3;
  19430. /**
  19431. * The collision of the joint
  19432. */
  19433. collision?: boolean;
  19434. /**
  19435. * Native Oimo/Cannon/Energy data
  19436. */
  19437. nativeParams?: any;
  19438. }
  19439. /**
  19440. * This is a holder class for the physics joint created by the physics plugin
  19441. * It holds a set of functions to control the underlying joint
  19442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19443. */
  19444. export class PhysicsJoint {
  19445. /**
  19446. * The type of the physics joint
  19447. */
  19448. type: number;
  19449. /**
  19450. * The data for the physics joint
  19451. */
  19452. jointData: PhysicsJointData;
  19453. private _physicsJoint;
  19454. protected _physicsPlugin: IPhysicsEnginePlugin;
  19455. /**
  19456. * Initializes the physics joint
  19457. * @param type The type of the physics joint
  19458. * @param jointData The data for the physics joint
  19459. */
  19460. constructor(
  19461. /**
  19462. * The type of the physics joint
  19463. */
  19464. type: number,
  19465. /**
  19466. * The data for the physics joint
  19467. */
  19468. jointData: PhysicsJointData);
  19469. /**
  19470. * Gets the physics joint
  19471. */
  19472. /**
  19473. * Sets the physics joint
  19474. */
  19475. physicsJoint: any;
  19476. /**
  19477. * Sets the physics plugin
  19478. */
  19479. physicsPlugin: IPhysicsEnginePlugin;
  19480. /**
  19481. * Execute a function that is physics-plugin specific.
  19482. * @param {Function} func the function that will be executed.
  19483. * It accepts two parameters: the physics world and the physics joint
  19484. */
  19485. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19486. /**
  19487. * Distance-Joint type
  19488. */
  19489. static DistanceJoint: number;
  19490. /**
  19491. * Hinge-Joint type
  19492. */
  19493. static HingeJoint: number;
  19494. /**
  19495. * Ball-and-Socket joint type
  19496. */
  19497. static BallAndSocketJoint: number;
  19498. /**
  19499. * Wheel-Joint type
  19500. */
  19501. static WheelJoint: number;
  19502. /**
  19503. * Slider-Joint type
  19504. */
  19505. static SliderJoint: number;
  19506. /**
  19507. * Prismatic-Joint type
  19508. */
  19509. static PrismaticJoint: number;
  19510. /**
  19511. * Universal-Joint type
  19512. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19513. */
  19514. static UniversalJoint: number;
  19515. /**
  19516. * Hinge-Joint 2 type
  19517. */
  19518. static Hinge2Joint: number;
  19519. /**
  19520. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19521. */
  19522. static PointToPointJoint: number;
  19523. /**
  19524. * Spring-Joint type
  19525. */
  19526. static SpringJoint: number;
  19527. /**
  19528. * Lock-Joint type
  19529. */
  19530. static LockJoint: number;
  19531. }
  19532. /**
  19533. * A class representing a physics distance joint
  19534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19535. */
  19536. export class DistanceJoint extends PhysicsJoint {
  19537. /**
  19538. *
  19539. * @param jointData The data for the Distance-Joint
  19540. */
  19541. constructor(jointData: DistanceJointData);
  19542. /**
  19543. * Update the predefined distance.
  19544. * @param maxDistance The maximum preferred distance
  19545. * @param minDistance The minimum preferred distance
  19546. */
  19547. updateDistance(maxDistance: number, minDistance?: number): void;
  19548. }
  19549. /**
  19550. * Represents a Motor-Enabled Joint
  19551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19552. */
  19553. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19554. /**
  19555. * Initializes the Motor-Enabled Joint
  19556. * @param type The type of the joint
  19557. * @param jointData The physica joint data for the joint
  19558. */
  19559. constructor(type: number, jointData: PhysicsJointData);
  19560. /**
  19561. * Set the motor values.
  19562. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19563. * @param force the force to apply
  19564. * @param maxForce max force for this motor.
  19565. */
  19566. setMotor(force?: number, maxForce?: number): void;
  19567. /**
  19568. * Set the motor's limits.
  19569. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19570. * @param upperLimit The upper limit of the motor
  19571. * @param lowerLimit The lower limit of the motor
  19572. */
  19573. setLimit(upperLimit: number, lowerLimit?: number): void;
  19574. }
  19575. /**
  19576. * This class represents a single physics Hinge-Joint
  19577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19578. */
  19579. export class HingeJoint extends MotorEnabledJoint {
  19580. /**
  19581. * Initializes the Hinge-Joint
  19582. * @param jointData The joint data for the Hinge-Joint
  19583. */
  19584. constructor(jointData: PhysicsJointData);
  19585. /**
  19586. * Set the motor values.
  19587. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19588. * @param {number} force the force to apply
  19589. * @param {number} maxForce max force for this motor.
  19590. */
  19591. setMotor(force?: number, maxForce?: number): void;
  19592. /**
  19593. * Set the motor's limits.
  19594. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19595. * @param upperLimit The upper limit of the motor
  19596. * @param lowerLimit The lower limit of the motor
  19597. */
  19598. setLimit(upperLimit: number, lowerLimit?: number): void;
  19599. }
  19600. /**
  19601. * This class represents a dual hinge physics joint (same as wheel joint)
  19602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19603. */
  19604. export class Hinge2Joint extends MotorEnabledJoint {
  19605. /**
  19606. * Initializes the Hinge2-Joint
  19607. * @param jointData The joint data for the Hinge2-Joint
  19608. */
  19609. constructor(jointData: PhysicsJointData);
  19610. /**
  19611. * Set the motor values.
  19612. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19613. * @param {number} targetSpeed the speed the motor is to reach
  19614. * @param {number} maxForce max force for this motor.
  19615. * @param {motorIndex} the motor's index, 0 or 1.
  19616. */
  19617. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19618. /**
  19619. * Set the motor limits.
  19620. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19621. * @param {number} upperLimit the upper limit
  19622. * @param {number} lowerLimit lower limit
  19623. * @param {motorIndex} the motor's index, 0 or 1.
  19624. */
  19625. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19626. }
  19627. /**
  19628. * Interface for a motor enabled joint
  19629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19630. */
  19631. export interface IMotorEnabledJoint {
  19632. /**
  19633. * Physics joint
  19634. */
  19635. physicsJoint: any;
  19636. /**
  19637. * Sets the motor of the motor-enabled joint
  19638. * @param force The force of the motor
  19639. * @param maxForce The maximum force of the motor
  19640. * @param motorIndex The index of the motor
  19641. */
  19642. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19643. /**
  19644. * Sets the limit of the motor
  19645. * @param upperLimit The upper limit of the motor
  19646. * @param lowerLimit The lower limit of the motor
  19647. * @param motorIndex The index of the motor
  19648. */
  19649. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19650. }
  19651. /**
  19652. * Joint data for a Distance-Joint
  19653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19654. */
  19655. export interface DistanceJointData extends PhysicsJointData {
  19656. /**
  19657. * Max distance the 2 joint objects can be apart
  19658. */
  19659. maxDistance: number;
  19660. }
  19661. /**
  19662. * Joint data from a spring joint
  19663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19664. */
  19665. export interface SpringJointData extends PhysicsJointData {
  19666. /**
  19667. * Length of the spring
  19668. */
  19669. length: number;
  19670. /**
  19671. * Stiffness of the spring
  19672. */
  19673. stiffness: number;
  19674. /**
  19675. * Damping of the spring
  19676. */
  19677. damping: number;
  19678. /** this callback will be called when applying the force to the impostors. */
  19679. forceApplicationCallback: () => void;
  19680. }
  19681. }
  19682. declare module BABYLON {
  19683. /**
  19684. * Holds the data for the raycast result
  19685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19686. */
  19687. export class PhysicsRaycastResult {
  19688. private _hasHit;
  19689. private _hitDistance;
  19690. private _hitNormalWorld;
  19691. private _hitPointWorld;
  19692. private _rayFromWorld;
  19693. private _rayToWorld;
  19694. /**
  19695. * Gets if there was a hit
  19696. */
  19697. readonly hasHit: boolean;
  19698. /**
  19699. * Gets the distance from the hit
  19700. */
  19701. readonly hitDistance: number;
  19702. /**
  19703. * Gets the hit normal/direction in the world
  19704. */
  19705. readonly hitNormalWorld: Vector3;
  19706. /**
  19707. * Gets the hit point in the world
  19708. */
  19709. readonly hitPointWorld: Vector3;
  19710. /**
  19711. * Gets the ray "start point" of the ray in the world
  19712. */
  19713. readonly rayFromWorld: Vector3;
  19714. /**
  19715. * Gets the ray "end point" of the ray in the world
  19716. */
  19717. readonly rayToWorld: Vector3;
  19718. /**
  19719. * Sets the hit data (normal & point in world space)
  19720. * @param hitNormalWorld defines the normal in world space
  19721. * @param hitPointWorld defines the point in world space
  19722. */
  19723. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19724. /**
  19725. * Sets the distance from the start point to the hit point
  19726. * @param distance
  19727. */
  19728. setHitDistance(distance: number): void;
  19729. /**
  19730. * Calculates the distance manually
  19731. */
  19732. calculateHitDistance(): void;
  19733. /**
  19734. * Resets all the values to default
  19735. * @param from The from point on world space
  19736. * @param to The to point on world space
  19737. */
  19738. reset(from?: Vector3, to?: Vector3): void;
  19739. }
  19740. /**
  19741. * Interface for the size containing width and height
  19742. */
  19743. interface IXYZ {
  19744. /**
  19745. * X
  19746. */
  19747. x: number;
  19748. /**
  19749. * Y
  19750. */
  19751. y: number;
  19752. /**
  19753. * Z
  19754. */
  19755. z: number;
  19756. }
  19757. }
  19758. declare module BABYLON {
  19759. /**
  19760. * Interface used to describe a physics joint
  19761. */
  19762. export interface PhysicsImpostorJoint {
  19763. /** Defines the main impostor to which the joint is linked */
  19764. mainImpostor: PhysicsImpostor;
  19765. /** Defines the impostor that is connected to the main impostor using this joint */
  19766. connectedImpostor: PhysicsImpostor;
  19767. /** Defines the joint itself */
  19768. joint: PhysicsJoint;
  19769. }
  19770. /** @hidden */
  19771. export interface IPhysicsEnginePlugin {
  19772. world: any;
  19773. name: string;
  19774. setGravity(gravity: Vector3): void;
  19775. setTimeStep(timeStep: number): void;
  19776. getTimeStep(): number;
  19777. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19778. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19779. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19780. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19781. removePhysicsBody(impostor: PhysicsImpostor): void;
  19782. generateJoint(joint: PhysicsImpostorJoint): void;
  19783. removeJoint(joint: PhysicsImpostorJoint): void;
  19784. isSupported(): boolean;
  19785. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19786. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19787. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19788. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19790. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19791. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19792. getBodyMass(impostor: PhysicsImpostor): number;
  19793. getBodyFriction(impostor: PhysicsImpostor): number;
  19794. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19795. getBodyRestitution(impostor: PhysicsImpostor): number;
  19796. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19797. getBodyPressure?(impostor: PhysicsImpostor): number;
  19798. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19799. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19800. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19801. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19802. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19803. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19804. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19805. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19806. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19807. sleepBody(impostor: PhysicsImpostor): void;
  19808. wakeUpBody(impostor: PhysicsImpostor): void;
  19809. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19810. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19811. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19812. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19813. getRadius(impostor: PhysicsImpostor): number;
  19814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19816. dispose(): void;
  19817. }
  19818. /**
  19819. * Interface used to define a physics engine
  19820. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19821. */
  19822. export interface IPhysicsEngine {
  19823. /**
  19824. * Gets the gravity vector used by the simulation
  19825. */
  19826. gravity: Vector3;
  19827. /**
  19828. * Sets the gravity vector used by the simulation
  19829. * @param gravity defines the gravity vector to use
  19830. */
  19831. setGravity(gravity: Vector3): void;
  19832. /**
  19833. * Set the time step of the physics engine.
  19834. * Default is 1/60.
  19835. * To slow it down, enter 1/600 for example.
  19836. * To speed it up, 1/30
  19837. * @param newTimeStep the new timestep to apply to this world.
  19838. */
  19839. setTimeStep(newTimeStep: number): void;
  19840. /**
  19841. * Get the time step of the physics engine.
  19842. * @returns the current time step
  19843. */
  19844. getTimeStep(): number;
  19845. /**
  19846. * Release all resources
  19847. */
  19848. dispose(): void;
  19849. /**
  19850. * Gets the name of the current physics plugin
  19851. * @returns the name of the plugin
  19852. */
  19853. getPhysicsPluginName(): string;
  19854. /**
  19855. * Adding a new impostor for the impostor tracking.
  19856. * This will be done by the impostor itself.
  19857. * @param impostor the impostor to add
  19858. */
  19859. addImpostor(impostor: PhysicsImpostor): void;
  19860. /**
  19861. * Remove an impostor from the engine.
  19862. * This impostor and its mesh will not longer be updated by the physics engine.
  19863. * @param impostor the impostor to remove
  19864. */
  19865. removeImpostor(impostor: PhysicsImpostor): void;
  19866. /**
  19867. * Add a joint to the physics engine
  19868. * @param mainImpostor defines the main impostor to which the joint is added.
  19869. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19870. * @param joint defines the joint that will connect both impostors.
  19871. */
  19872. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19873. /**
  19874. * Removes a joint from the simulation
  19875. * @param mainImpostor defines the impostor used with the joint
  19876. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19877. * @param joint defines the joint to remove
  19878. */
  19879. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19880. /**
  19881. * Gets the current plugin used to run the simulation
  19882. * @returns current plugin
  19883. */
  19884. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19885. /**
  19886. * Gets the list of physic impostors
  19887. * @returns an array of PhysicsImpostor
  19888. */
  19889. getImpostors(): Array<PhysicsImpostor>;
  19890. /**
  19891. * Gets the impostor for a physics enabled object
  19892. * @param object defines the object impersonated by the impostor
  19893. * @returns the PhysicsImpostor or null if not found
  19894. */
  19895. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19896. /**
  19897. * Gets the impostor for a physics body object
  19898. * @param body defines physics body used by the impostor
  19899. * @returns the PhysicsImpostor or null if not found
  19900. */
  19901. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19902. /**
  19903. * Does a raycast in the physics world
  19904. * @param from when should the ray start?
  19905. * @param to when should the ray end?
  19906. * @returns PhysicsRaycastResult
  19907. */
  19908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19909. /**
  19910. * Called by the scene. No need to call it.
  19911. * @param delta defines the timespam between frames
  19912. */
  19913. _step(delta: number): void;
  19914. }
  19915. }
  19916. declare module BABYLON {
  19917. /**
  19918. * The interface for the physics imposter parameters
  19919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19920. */
  19921. export interface PhysicsImpostorParameters {
  19922. /**
  19923. * The mass of the physics imposter
  19924. */
  19925. mass: number;
  19926. /**
  19927. * The friction of the physics imposter
  19928. */
  19929. friction?: number;
  19930. /**
  19931. * The coefficient of restitution of the physics imposter
  19932. */
  19933. restitution?: number;
  19934. /**
  19935. * The native options of the physics imposter
  19936. */
  19937. nativeOptions?: any;
  19938. /**
  19939. * Specifies if the parent should be ignored
  19940. */
  19941. ignoreParent?: boolean;
  19942. /**
  19943. * Specifies if bi-directional transformations should be disabled
  19944. */
  19945. disableBidirectionalTransformation?: boolean;
  19946. /**
  19947. * The pressure inside the physics imposter, soft object only
  19948. */
  19949. pressure?: number;
  19950. /**
  19951. * The stiffness the physics imposter, soft object only
  19952. */
  19953. stiffness?: number;
  19954. /**
  19955. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19956. */
  19957. velocityIterations?: number;
  19958. /**
  19959. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19960. */
  19961. positionIterations?: number;
  19962. /**
  19963. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19964. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19965. * Add to fix multiple points
  19966. */
  19967. fixedPoints?: number;
  19968. /**
  19969. * The collision margin around a soft object
  19970. */
  19971. margin?: number;
  19972. /**
  19973. * The collision margin around a soft object
  19974. */
  19975. damping?: number;
  19976. /**
  19977. * The path for a rope based on an extrusion
  19978. */
  19979. path?: any;
  19980. /**
  19981. * The shape of an extrusion used for a rope based on an extrusion
  19982. */
  19983. shape?: any;
  19984. }
  19985. /**
  19986. * Interface for a physics-enabled object
  19987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19988. */
  19989. export interface IPhysicsEnabledObject {
  19990. /**
  19991. * The position of the physics-enabled object
  19992. */
  19993. position: Vector3;
  19994. /**
  19995. * The rotation of the physics-enabled object
  19996. */
  19997. rotationQuaternion: Nullable<Quaternion>;
  19998. /**
  19999. * The scale of the physics-enabled object
  20000. */
  20001. scaling: Vector3;
  20002. /**
  20003. * The rotation of the physics-enabled object
  20004. */
  20005. rotation?: Vector3;
  20006. /**
  20007. * The parent of the physics-enabled object
  20008. */
  20009. parent?: any;
  20010. /**
  20011. * The bounding info of the physics-enabled object
  20012. * @returns The bounding info of the physics-enabled object
  20013. */
  20014. getBoundingInfo(): BoundingInfo;
  20015. /**
  20016. * Computes the world matrix
  20017. * @param force Specifies if the world matrix should be computed by force
  20018. * @returns A world matrix
  20019. */
  20020. computeWorldMatrix(force: boolean): Matrix;
  20021. /**
  20022. * Gets the world matrix
  20023. * @returns A world matrix
  20024. */
  20025. getWorldMatrix?(): Matrix;
  20026. /**
  20027. * Gets the child meshes
  20028. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20029. * @returns An array of abstract meshes
  20030. */
  20031. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20032. /**
  20033. * Gets the vertex data
  20034. * @param kind The type of vertex data
  20035. * @returns A nullable array of numbers, or a float32 array
  20036. */
  20037. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20038. /**
  20039. * Gets the indices from the mesh
  20040. * @returns A nullable array of index arrays
  20041. */
  20042. getIndices?(): Nullable<IndicesArray>;
  20043. /**
  20044. * Gets the scene from the mesh
  20045. * @returns the indices array or null
  20046. */
  20047. getScene?(): Scene;
  20048. /**
  20049. * Gets the absolute position from the mesh
  20050. * @returns the absolute position
  20051. */
  20052. getAbsolutePosition(): Vector3;
  20053. /**
  20054. * Gets the absolute pivot point from the mesh
  20055. * @returns the absolute pivot point
  20056. */
  20057. getAbsolutePivotPoint(): Vector3;
  20058. /**
  20059. * Rotates the mesh
  20060. * @param axis The axis of rotation
  20061. * @param amount The amount of rotation
  20062. * @param space The space of the rotation
  20063. * @returns The rotation transform node
  20064. */
  20065. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20066. /**
  20067. * Translates the mesh
  20068. * @param axis The axis of translation
  20069. * @param distance The distance of translation
  20070. * @param space The space of the translation
  20071. * @returns The transform node
  20072. */
  20073. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20074. /**
  20075. * Sets the absolute position of the mesh
  20076. * @param absolutePosition The absolute position of the mesh
  20077. * @returns The transform node
  20078. */
  20079. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20080. /**
  20081. * Gets the class name of the mesh
  20082. * @returns The class name
  20083. */
  20084. getClassName(): string;
  20085. }
  20086. /**
  20087. * Represents a physics imposter
  20088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20089. */
  20090. export class PhysicsImpostor {
  20091. /**
  20092. * The physics-enabled object used as the physics imposter
  20093. */
  20094. object: IPhysicsEnabledObject;
  20095. /**
  20096. * The type of the physics imposter
  20097. */
  20098. type: number;
  20099. private _options;
  20100. private _scene?;
  20101. /**
  20102. * The default object size of the imposter
  20103. */
  20104. static DEFAULT_OBJECT_SIZE: Vector3;
  20105. /**
  20106. * The identity quaternion of the imposter
  20107. */
  20108. static IDENTITY_QUATERNION: Quaternion;
  20109. /** @hidden */
  20110. _pluginData: any;
  20111. private _physicsEngine;
  20112. private _physicsBody;
  20113. private _bodyUpdateRequired;
  20114. private _onBeforePhysicsStepCallbacks;
  20115. private _onAfterPhysicsStepCallbacks;
  20116. /** @hidden */
  20117. _onPhysicsCollideCallbacks: Array<{
  20118. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20119. otherImpostors: Array<PhysicsImpostor>;
  20120. }>;
  20121. private _deltaPosition;
  20122. private _deltaRotation;
  20123. private _deltaRotationConjugated;
  20124. /** hidden */
  20125. _isFromLine: boolean;
  20126. private _parent;
  20127. private _isDisposed;
  20128. private static _tmpVecs;
  20129. private static _tmpQuat;
  20130. /**
  20131. * Specifies if the physics imposter is disposed
  20132. */
  20133. readonly isDisposed: boolean;
  20134. /**
  20135. * Gets the mass of the physics imposter
  20136. */
  20137. mass: number;
  20138. /**
  20139. * Gets the coefficient of friction
  20140. */
  20141. /**
  20142. * Sets the coefficient of friction
  20143. */
  20144. friction: number;
  20145. /**
  20146. * Gets the coefficient of restitution
  20147. */
  20148. /**
  20149. * Sets the coefficient of restitution
  20150. */
  20151. restitution: number;
  20152. /**
  20153. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20154. */
  20155. /**
  20156. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20157. */
  20158. pressure: number;
  20159. /**
  20160. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20161. */
  20162. /**
  20163. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20164. */
  20165. stiffness: number;
  20166. /**
  20167. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20168. */
  20169. /**
  20170. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20171. */
  20172. velocityIterations: number;
  20173. /**
  20174. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20175. */
  20176. /**
  20177. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20178. */
  20179. positionIterations: number;
  20180. /**
  20181. * The unique id of the physics imposter
  20182. * set by the physics engine when adding this impostor to the array
  20183. */
  20184. uniqueId: number;
  20185. /**
  20186. * @hidden
  20187. */
  20188. soft: boolean;
  20189. /**
  20190. * @hidden
  20191. */
  20192. segments: number;
  20193. private _joints;
  20194. /**
  20195. * Initializes the physics imposter
  20196. * @param object The physics-enabled object used as the physics imposter
  20197. * @param type The type of the physics imposter
  20198. * @param _options The options for the physics imposter
  20199. * @param _scene The Babylon scene
  20200. */
  20201. constructor(
  20202. /**
  20203. * The physics-enabled object used as the physics imposter
  20204. */
  20205. object: IPhysicsEnabledObject,
  20206. /**
  20207. * The type of the physics imposter
  20208. */
  20209. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20210. /**
  20211. * This function will completly initialize this impostor.
  20212. * It will create a new body - but only if this mesh has no parent.
  20213. * If it has, this impostor will not be used other than to define the impostor
  20214. * of the child mesh.
  20215. * @hidden
  20216. */
  20217. _init(): void;
  20218. private _getPhysicsParent;
  20219. /**
  20220. * Should a new body be generated.
  20221. * @returns boolean specifying if body initialization is required
  20222. */
  20223. isBodyInitRequired(): boolean;
  20224. /**
  20225. * Sets the updated scaling
  20226. * @param updated Specifies if the scaling is updated
  20227. */
  20228. setScalingUpdated(): void;
  20229. /**
  20230. * Force a regeneration of this or the parent's impostor's body.
  20231. * Use under cautious - This will remove all joints already implemented.
  20232. */
  20233. forceUpdate(): void;
  20234. /**
  20235. * Gets the body that holds this impostor. Either its own, or its parent.
  20236. */
  20237. /**
  20238. * Set the physics body. Used mainly by the physics engine/plugin
  20239. */
  20240. physicsBody: any;
  20241. /**
  20242. * Get the parent of the physics imposter
  20243. * @returns Physics imposter or null
  20244. */
  20245. /**
  20246. * Sets the parent of the physics imposter
  20247. */
  20248. parent: Nullable<PhysicsImpostor>;
  20249. /**
  20250. * Resets the update flags
  20251. */
  20252. resetUpdateFlags(): void;
  20253. /**
  20254. * Gets the object extend size
  20255. * @returns the object extend size
  20256. */
  20257. getObjectExtendSize(): Vector3;
  20258. /**
  20259. * Gets the object center
  20260. * @returns The object center
  20261. */
  20262. getObjectCenter(): Vector3;
  20263. /**
  20264. * Get a specific parametes from the options parameter
  20265. * @param paramName The object parameter name
  20266. * @returns The object parameter
  20267. */
  20268. getParam(paramName: string): any;
  20269. /**
  20270. * Sets a specific parameter in the options given to the physics plugin
  20271. * @param paramName The parameter name
  20272. * @param value The value of the parameter
  20273. */
  20274. setParam(paramName: string, value: number): void;
  20275. /**
  20276. * Specifically change the body's mass option. Won't recreate the physics body object
  20277. * @param mass The mass of the physics imposter
  20278. */
  20279. setMass(mass: number): void;
  20280. /**
  20281. * Gets the linear velocity
  20282. * @returns linear velocity or null
  20283. */
  20284. getLinearVelocity(): Nullable<Vector3>;
  20285. /**
  20286. * Sets the linear velocity
  20287. * @param velocity linear velocity or null
  20288. */
  20289. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20290. /**
  20291. * Gets the angular velocity
  20292. * @returns angular velocity or null
  20293. */
  20294. getAngularVelocity(): Nullable<Vector3>;
  20295. /**
  20296. * Sets the angular velocity
  20297. * @param velocity The velocity or null
  20298. */
  20299. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20300. /**
  20301. * Execute a function with the physics plugin native code
  20302. * Provide a function the will have two variables - the world object and the physics body object
  20303. * @param func The function to execute with the physics plugin native code
  20304. */
  20305. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20306. /**
  20307. * Register a function that will be executed before the physics world is stepping forward
  20308. * @param func The function to execute before the physics world is stepped forward
  20309. */
  20310. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20311. /**
  20312. * Unregister a function that will be executed before the physics world is stepping forward
  20313. * @param func The function to execute before the physics world is stepped forward
  20314. */
  20315. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20316. /**
  20317. * Register a function that will be executed after the physics step
  20318. * @param func The function to execute after physics step
  20319. */
  20320. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20321. /**
  20322. * Unregisters a function that will be executed after the physics step
  20323. * @param func The function to execute after physics step
  20324. */
  20325. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20326. /**
  20327. * register a function that will be executed when this impostor collides against a different body
  20328. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20329. * @param func Callback that is executed on collision
  20330. */
  20331. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20332. /**
  20333. * Unregisters the physics imposter on contact
  20334. * @param collideAgainst The physics object to collide against
  20335. * @param func Callback to execute on collision
  20336. */
  20337. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20338. private _tmpQuat;
  20339. private _tmpQuat2;
  20340. /**
  20341. * Get the parent rotation
  20342. * @returns The parent rotation
  20343. */
  20344. getParentsRotation(): Quaternion;
  20345. /**
  20346. * this function is executed by the physics engine.
  20347. */
  20348. beforeStep: () => void;
  20349. /**
  20350. * this function is executed by the physics engine
  20351. */
  20352. afterStep: () => void;
  20353. /**
  20354. * Legacy collision detection event support
  20355. */
  20356. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20357. /**
  20358. * event and body object due to cannon's event-based architecture.
  20359. */
  20360. onCollide: (e: {
  20361. body: any;
  20362. }) => void;
  20363. /**
  20364. * Apply a force
  20365. * @param force The force to apply
  20366. * @param contactPoint The contact point for the force
  20367. * @returns The physics imposter
  20368. */
  20369. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20370. /**
  20371. * Apply an impulse
  20372. * @param force The impulse force
  20373. * @param contactPoint The contact point for the impulse force
  20374. * @returns The physics imposter
  20375. */
  20376. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20377. /**
  20378. * A help function to create a joint
  20379. * @param otherImpostor A physics imposter used to create a joint
  20380. * @param jointType The type of joint
  20381. * @param jointData The data for the joint
  20382. * @returns The physics imposter
  20383. */
  20384. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20385. /**
  20386. * Add a joint to this impostor with a different impostor
  20387. * @param otherImpostor A physics imposter used to add a joint
  20388. * @param joint The joint to add
  20389. * @returns The physics imposter
  20390. */
  20391. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20392. /**
  20393. * Add an anchor to a cloth impostor
  20394. * @param otherImpostor rigid impostor to anchor to
  20395. * @param width ratio across width from 0 to 1
  20396. * @param height ratio up height from 0 to 1
  20397. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20398. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20399. * @returns impostor the soft imposter
  20400. */
  20401. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20402. /**
  20403. * Add a hook to a rope impostor
  20404. * @param otherImpostor rigid impostor to anchor to
  20405. * @param length ratio across rope from 0 to 1
  20406. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20407. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20408. * @returns impostor the rope imposter
  20409. */
  20410. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20411. /**
  20412. * Will keep this body still, in a sleep mode.
  20413. * @returns the physics imposter
  20414. */
  20415. sleep(): PhysicsImpostor;
  20416. /**
  20417. * Wake the body up.
  20418. * @returns The physics imposter
  20419. */
  20420. wakeUp(): PhysicsImpostor;
  20421. /**
  20422. * Clones the physics imposter
  20423. * @param newObject The physics imposter clones to this physics-enabled object
  20424. * @returns A nullable physics imposter
  20425. */
  20426. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20427. /**
  20428. * Disposes the physics imposter
  20429. */
  20430. dispose(): void;
  20431. /**
  20432. * Sets the delta position
  20433. * @param position The delta position amount
  20434. */
  20435. setDeltaPosition(position: Vector3): void;
  20436. /**
  20437. * Sets the delta rotation
  20438. * @param rotation The delta rotation amount
  20439. */
  20440. setDeltaRotation(rotation: Quaternion): void;
  20441. /**
  20442. * Gets the box size of the physics imposter and stores the result in the input parameter
  20443. * @param result Stores the box size
  20444. * @returns The physics imposter
  20445. */
  20446. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20447. /**
  20448. * Gets the radius of the physics imposter
  20449. * @returns Radius of the physics imposter
  20450. */
  20451. getRadius(): number;
  20452. /**
  20453. * Sync a bone with this impostor
  20454. * @param bone The bone to sync to the impostor.
  20455. * @param boneMesh The mesh that the bone is influencing.
  20456. * @param jointPivot The pivot of the joint / bone in local space.
  20457. * @param distToJoint Optional distance from the impostor to the joint.
  20458. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20459. */
  20460. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20461. /**
  20462. * Sync impostor to a bone
  20463. * @param bone The bone that the impostor will be synced to.
  20464. * @param boneMesh The mesh that the bone is influencing.
  20465. * @param jointPivot The pivot of the joint / bone in local space.
  20466. * @param distToJoint Optional distance from the impostor to the joint.
  20467. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20468. * @param boneAxis Optional vector3 axis the bone is aligned with
  20469. */
  20470. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20471. /**
  20472. * No-Imposter type
  20473. */
  20474. static NoImpostor: number;
  20475. /**
  20476. * Sphere-Imposter type
  20477. */
  20478. static SphereImpostor: number;
  20479. /**
  20480. * Box-Imposter type
  20481. */
  20482. static BoxImpostor: number;
  20483. /**
  20484. * Plane-Imposter type
  20485. */
  20486. static PlaneImpostor: number;
  20487. /**
  20488. * Mesh-imposter type
  20489. */
  20490. static MeshImpostor: number;
  20491. /**
  20492. * Cylinder-Imposter type
  20493. */
  20494. static CylinderImpostor: number;
  20495. /**
  20496. * Particle-Imposter type
  20497. */
  20498. static ParticleImpostor: number;
  20499. /**
  20500. * Heightmap-Imposter type
  20501. */
  20502. static HeightmapImpostor: number;
  20503. /**
  20504. * ConvexHull-Impostor type (Ammo.js plugin only)
  20505. */
  20506. static ConvexHullImpostor: number;
  20507. /**
  20508. * Rope-Imposter type
  20509. */
  20510. static RopeImpostor: number;
  20511. /**
  20512. * Cloth-Imposter type
  20513. */
  20514. static ClothImpostor: number;
  20515. /**
  20516. * Softbody-Imposter type
  20517. */
  20518. static SoftbodyImpostor: number;
  20519. }
  20520. }
  20521. declare module BABYLON {
  20522. /**
  20523. * Class used to represent a specific level of detail of a mesh
  20524. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20525. */
  20526. export class MeshLODLevel {
  20527. /** Defines the distance where this level should star being displayed */
  20528. distance: number;
  20529. /** Defines the mesh to use to render this level */
  20530. mesh: Nullable<Mesh>;
  20531. /**
  20532. * Creates a new LOD level
  20533. * @param distance defines the distance where this level should star being displayed
  20534. * @param mesh defines the mesh to use to render this level
  20535. */
  20536. constructor(
  20537. /** Defines the distance where this level should star being displayed */
  20538. distance: number,
  20539. /** Defines the mesh to use to render this level */
  20540. mesh: Nullable<Mesh>);
  20541. }
  20542. /**
  20543. * @hidden
  20544. **/
  20545. export class _CreationDataStorage {
  20546. closePath?: boolean;
  20547. closeArray?: boolean;
  20548. idx: number[];
  20549. dashSize: number;
  20550. gapSize: number;
  20551. path3D: Path3D;
  20552. pathArray: Vector3[][];
  20553. arc: number;
  20554. radius: number;
  20555. cap: number;
  20556. tessellation: number;
  20557. }
  20558. /**
  20559. * @hidden
  20560. **/
  20561. class _InstanceDataStorage {
  20562. visibleInstances: any;
  20563. batchCache: _InstancesBatch;
  20564. instancesBufferSize: number;
  20565. instancesBuffer: Nullable<Buffer>;
  20566. instancesData: Float32Array;
  20567. overridenInstanceCount: number;
  20568. isFrozen: boolean;
  20569. previousBatch: _InstancesBatch;
  20570. hardwareInstancedRendering: boolean;
  20571. sideOrientation: number;
  20572. }
  20573. /**
  20574. * @hidden
  20575. **/
  20576. export class _InstancesBatch {
  20577. mustReturn: boolean;
  20578. visibleInstances: Nullable<InstancedMesh[]>[];
  20579. renderSelf: boolean[];
  20580. hardwareInstancedRendering: boolean[];
  20581. }
  20582. /**
  20583. * Class used to represent renderable models
  20584. */
  20585. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20586. /**
  20587. * Mesh side orientation : usually the external or front surface
  20588. */
  20589. static readonly FRONTSIDE: number;
  20590. /**
  20591. * Mesh side orientation : usually the internal or back surface
  20592. */
  20593. static readonly BACKSIDE: number;
  20594. /**
  20595. * Mesh side orientation : both internal and external or front and back surfaces
  20596. */
  20597. static readonly DOUBLESIDE: number;
  20598. /**
  20599. * Mesh side orientation : by default, `FRONTSIDE`
  20600. */
  20601. static readonly DEFAULTSIDE: number;
  20602. /**
  20603. * Mesh cap setting : no cap
  20604. */
  20605. static readonly NO_CAP: number;
  20606. /**
  20607. * Mesh cap setting : one cap at the beginning of the mesh
  20608. */
  20609. static readonly CAP_START: number;
  20610. /**
  20611. * Mesh cap setting : one cap at the end of the mesh
  20612. */
  20613. static readonly CAP_END: number;
  20614. /**
  20615. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20616. */
  20617. static readonly CAP_ALL: number;
  20618. /**
  20619. * Gets the default side orientation.
  20620. * @param orientation the orientation to value to attempt to get
  20621. * @returns the default orientation
  20622. * @hidden
  20623. */
  20624. static _GetDefaultSideOrientation(orientation?: number): number;
  20625. private _onBeforeRenderObservable;
  20626. private _onBeforeBindObservable;
  20627. private _onAfterRenderObservable;
  20628. private _onBeforeDrawObservable;
  20629. /**
  20630. * An event triggered before rendering the mesh
  20631. */
  20632. readonly onBeforeRenderObservable: Observable<Mesh>;
  20633. /**
  20634. * An event triggered before binding the mesh
  20635. */
  20636. readonly onBeforeBindObservable: Observable<Mesh>;
  20637. /**
  20638. * An event triggered after rendering the mesh
  20639. */
  20640. readonly onAfterRenderObservable: Observable<Mesh>;
  20641. /**
  20642. * An event triggered before drawing the mesh
  20643. */
  20644. readonly onBeforeDrawObservable: Observable<Mesh>;
  20645. private _onBeforeDrawObserver;
  20646. /**
  20647. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20648. */
  20649. onBeforeDraw: () => void;
  20650. /**
  20651. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20652. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20653. */
  20654. delayLoadState: number;
  20655. /**
  20656. * Gets the list of instances created from this mesh
  20657. * it is not supposed to be modified manually.
  20658. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20659. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20660. */
  20661. instances: InstancedMesh[];
  20662. /**
  20663. * Gets the file containing delay loading data for this mesh
  20664. */
  20665. delayLoadingFile: string;
  20666. /** @hidden */
  20667. _binaryInfo: any;
  20668. private _LODLevels;
  20669. /**
  20670. * User defined function used to change how LOD level selection is done
  20671. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20672. */
  20673. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20674. private _morphTargetManager;
  20675. /**
  20676. * Gets or sets the morph target manager
  20677. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20678. */
  20679. morphTargetManager: Nullable<MorphTargetManager>;
  20680. /** @hidden */
  20681. _creationDataStorage: Nullable<_CreationDataStorage>;
  20682. /** @hidden */
  20683. _geometry: Nullable<Geometry>;
  20684. /** @hidden */
  20685. _delayInfo: Array<string>;
  20686. /** @hidden */
  20687. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20688. /** @hidden */
  20689. _instanceDataStorage: _InstanceDataStorage;
  20690. private _effectiveMaterial;
  20691. /** @hidden */
  20692. _shouldGenerateFlatShading: boolean;
  20693. private _preActivateId;
  20694. /** @hidden */
  20695. _originalBuilderSideOrientation: number;
  20696. /**
  20697. * Use this property to change the original side orientation defined at construction time
  20698. */
  20699. overrideMaterialSideOrientation: Nullable<number>;
  20700. private _areNormalsFrozen;
  20701. private _sourcePositions;
  20702. private _sourceNormals;
  20703. private _source;
  20704. private meshMap;
  20705. /**
  20706. * Gets the source mesh (the one used to clone this one from)
  20707. */
  20708. readonly source: Nullable<Mesh>;
  20709. /**
  20710. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20711. */
  20712. isUnIndexed: boolean;
  20713. /**
  20714. * @constructor
  20715. * @param name The value used by scene.getMeshByName() to do a lookup.
  20716. * @param scene The scene to add this mesh to.
  20717. * @param parent The parent of this mesh, if it has one
  20718. * @param source An optional Mesh from which geometry is shared, cloned.
  20719. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20720. * When false, achieved by calling a clone(), also passing False.
  20721. * This will make creation of children, recursive.
  20722. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20723. */
  20724. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20725. /**
  20726. * Gets the class name
  20727. * @returns the string "Mesh".
  20728. */
  20729. getClassName(): string;
  20730. /** @hidden */
  20731. readonly _isMesh: boolean;
  20732. /**
  20733. * Returns a description of this mesh
  20734. * @param fullDetails define if full details about this mesh must be used
  20735. * @returns a descriptive string representing this mesh
  20736. */
  20737. toString(fullDetails?: boolean): string;
  20738. /** @hidden */
  20739. _unBindEffect(): void;
  20740. /**
  20741. * Gets a boolean indicating if this mesh has LOD
  20742. */
  20743. readonly hasLODLevels: boolean;
  20744. /**
  20745. * Gets the list of MeshLODLevel associated with the current mesh
  20746. * @returns an array of MeshLODLevel
  20747. */
  20748. getLODLevels(): MeshLODLevel[];
  20749. private _sortLODLevels;
  20750. /**
  20751. * Add a mesh as LOD level triggered at the given distance.
  20752. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20753. * @param distance The distance from the center of the object to show this level
  20754. * @param mesh The mesh to be added as LOD level (can be null)
  20755. * @return This mesh (for chaining)
  20756. */
  20757. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20758. /**
  20759. * Returns the LOD level mesh at the passed distance or null if not found.
  20760. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20761. * @param distance The distance from the center of the object to show this level
  20762. * @returns a Mesh or `null`
  20763. */
  20764. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20765. /**
  20766. * Remove a mesh from the LOD array
  20767. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20768. * @param mesh defines the mesh to be removed
  20769. * @return This mesh (for chaining)
  20770. */
  20771. removeLODLevel(mesh: Mesh): Mesh;
  20772. /**
  20773. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20774. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20775. * @param camera defines the camera to use to compute distance
  20776. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20777. * @return This mesh (for chaining)
  20778. */
  20779. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20780. /**
  20781. * Gets the mesh internal Geometry object
  20782. */
  20783. readonly geometry: Nullable<Geometry>;
  20784. /**
  20785. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20786. * @returns the total number of vertices
  20787. */
  20788. getTotalVertices(): number;
  20789. /**
  20790. * Returns the content of an associated vertex buffer
  20791. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20792. * - VertexBuffer.PositionKind
  20793. * - VertexBuffer.UVKind
  20794. * - VertexBuffer.UV2Kind
  20795. * - VertexBuffer.UV3Kind
  20796. * - VertexBuffer.UV4Kind
  20797. * - VertexBuffer.UV5Kind
  20798. * - VertexBuffer.UV6Kind
  20799. * - VertexBuffer.ColorKind
  20800. * - VertexBuffer.MatricesIndicesKind
  20801. * - VertexBuffer.MatricesIndicesExtraKind
  20802. * - VertexBuffer.MatricesWeightsKind
  20803. * - VertexBuffer.MatricesWeightsExtraKind
  20804. * @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
  20805. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20806. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20807. */
  20808. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20809. /**
  20810. * Returns the mesh VertexBuffer object from the requested `kind`
  20811. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20812. * - VertexBuffer.PositionKind
  20813. * - VertexBuffer.UVKind
  20814. * - VertexBuffer.UV2Kind
  20815. * - VertexBuffer.UV3Kind
  20816. * - VertexBuffer.UV4Kind
  20817. * - VertexBuffer.UV5Kind
  20818. * - VertexBuffer.UV6Kind
  20819. * - VertexBuffer.ColorKind
  20820. * - VertexBuffer.MatricesIndicesKind
  20821. * - VertexBuffer.MatricesIndicesExtraKind
  20822. * - VertexBuffer.MatricesWeightsKind
  20823. * - VertexBuffer.MatricesWeightsExtraKind
  20824. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20825. */
  20826. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20827. /**
  20828. * Tests if a specific vertex buffer is associated with this mesh
  20829. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20830. * - VertexBuffer.PositionKind
  20831. * - VertexBuffer.UVKind
  20832. * - VertexBuffer.UV2Kind
  20833. * - VertexBuffer.UV3Kind
  20834. * - VertexBuffer.UV4Kind
  20835. * - VertexBuffer.UV5Kind
  20836. * - VertexBuffer.UV6Kind
  20837. * - VertexBuffer.ColorKind
  20838. * - VertexBuffer.MatricesIndicesKind
  20839. * - VertexBuffer.MatricesIndicesExtraKind
  20840. * - VertexBuffer.MatricesWeightsKind
  20841. * - VertexBuffer.MatricesWeightsExtraKind
  20842. * @returns a boolean
  20843. */
  20844. isVerticesDataPresent(kind: string): boolean;
  20845. /**
  20846. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20847. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20848. * - VertexBuffer.PositionKind
  20849. * - VertexBuffer.UVKind
  20850. * - VertexBuffer.UV2Kind
  20851. * - VertexBuffer.UV3Kind
  20852. * - VertexBuffer.UV4Kind
  20853. * - VertexBuffer.UV5Kind
  20854. * - VertexBuffer.UV6Kind
  20855. * - VertexBuffer.ColorKind
  20856. * - VertexBuffer.MatricesIndicesKind
  20857. * - VertexBuffer.MatricesIndicesExtraKind
  20858. * - VertexBuffer.MatricesWeightsKind
  20859. * - VertexBuffer.MatricesWeightsExtraKind
  20860. * @returns a boolean
  20861. */
  20862. isVertexBufferUpdatable(kind: string): boolean;
  20863. /**
  20864. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20865. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20866. * - VertexBuffer.PositionKind
  20867. * - VertexBuffer.UVKind
  20868. * - VertexBuffer.UV2Kind
  20869. * - VertexBuffer.UV3Kind
  20870. * - VertexBuffer.UV4Kind
  20871. * - VertexBuffer.UV5Kind
  20872. * - VertexBuffer.UV6Kind
  20873. * - VertexBuffer.ColorKind
  20874. * - VertexBuffer.MatricesIndicesKind
  20875. * - VertexBuffer.MatricesIndicesExtraKind
  20876. * - VertexBuffer.MatricesWeightsKind
  20877. * - VertexBuffer.MatricesWeightsExtraKind
  20878. * @returns an array of strings
  20879. */
  20880. getVerticesDataKinds(): string[];
  20881. /**
  20882. * Returns a positive integer : the total number of indices in this mesh geometry.
  20883. * @returns the numner of indices or zero if the mesh has no geometry.
  20884. */
  20885. getTotalIndices(): number;
  20886. /**
  20887. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20888. * @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.
  20889. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20890. * @returns the indices array or an empty array if the mesh has no geometry
  20891. */
  20892. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20893. readonly isBlocked: boolean;
  20894. /**
  20895. * Determine if the current mesh is ready to be rendered
  20896. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20897. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20898. * @returns true if all associated assets are ready (material, textures, shaders)
  20899. */
  20900. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20901. /**
  20902. * 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.
  20903. */
  20904. readonly areNormalsFrozen: boolean;
  20905. /**
  20906. * 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.
  20907. * @returns the current mesh
  20908. */
  20909. freezeNormals(): Mesh;
  20910. /**
  20911. * 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
  20912. * @returns the current mesh
  20913. */
  20914. unfreezeNormals(): Mesh;
  20915. /**
  20916. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20917. */
  20918. overridenInstanceCount: number;
  20919. /** @hidden */
  20920. _preActivate(): Mesh;
  20921. /** @hidden */
  20922. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20923. /** @hidden */
  20924. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20925. /**
  20926. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20927. * This means the mesh underlying bounding box and sphere are recomputed.
  20928. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20929. * @returns the current mesh
  20930. */
  20931. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20932. /** @hidden */
  20933. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20934. /**
  20935. * This function will subdivide the mesh into multiple submeshes
  20936. * @param count defines the expected number of submeshes
  20937. */
  20938. subdivide(count: number): void;
  20939. /**
  20940. * Copy a FloatArray into a specific associated vertex buffer
  20941. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20942. * - VertexBuffer.PositionKind
  20943. * - VertexBuffer.UVKind
  20944. * - VertexBuffer.UV2Kind
  20945. * - VertexBuffer.UV3Kind
  20946. * - VertexBuffer.UV4Kind
  20947. * - VertexBuffer.UV5Kind
  20948. * - VertexBuffer.UV6Kind
  20949. * - VertexBuffer.ColorKind
  20950. * - VertexBuffer.MatricesIndicesKind
  20951. * - VertexBuffer.MatricesIndicesExtraKind
  20952. * - VertexBuffer.MatricesWeightsKind
  20953. * - VertexBuffer.MatricesWeightsExtraKind
  20954. * @param data defines the data source
  20955. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20956. * @param stride defines the data stride size (can be null)
  20957. * @returns the current mesh
  20958. */
  20959. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20960. /**
  20961. * Flags an associated vertex buffer as updatable
  20962. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20963. * - VertexBuffer.PositionKind
  20964. * - VertexBuffer.UVKind
  20965. * - VertexBuffer.UV2Kind
  20966. * - VertexBuffer.UV3Kind
  20967. * - VertexBuffer.UV4Kind
  20968. * - VertexBuffer.UV5Kind
  20969. * - VertexBuffer.UV6Kind
  20970. * - VertexBuffer.ColorKind
  20971. * - VertexBuffer.MatricesIndicesKind
  20972. * - VertexBuffer.MatricesIndicesExtraKind
  20973. * - VertexBuffer.MatricesWeightsKind
  20974. * - VertexBuffer.MatricesWeightsExtraKind
  20975. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20976. */
  20977. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20978. /**
  20979. * Sets the mesh global Vertex Buffer
  20980. * @param buffer defines the buffer to use
  20981. * @returns the current mesh
  20982. */
  20983. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20984. /**
  20985. * Update a specific associated vertex buffer
  20986. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20987. * - VertexBuffer.PositionKind
  20988. * - VertexBuffer.UVKind
  20989. * - VertexBuffer.UV2Kind
  20990. * - VertexBuffer.UV3Kind
  20991. * - VertexBuffer.UV4Kind
  20992. * - VertexBuffer.UV5Kind
  20993. * - VertexBuffer.UV6Kind
  20994. * - VertexBuffer.ColorKind
  20995. * - VertexBuffer.MatricesIndicesKind
  20996. * - VertexBuffer.MatricesIndicesExtraKind
  20997. * - VertexBuffer.MatricesWeightsKind
  20998. * - VertexBuffer.MatricesWeightsExtraKind
  20999. * @param data defines the data source
  21000. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21001. * @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)
  21002. * @returns the current mesh
  21003. */
  21004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21005. /**
  21006. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21007. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21008. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21009. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21010. * @returns the current mesh
  21011. */
  21012. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21013. /**
  21014. * Creates a un-shared specific occurence of the geometry for the mesh.
  21015. * @returns the current mesh
  21016. */
  21017. makeGeometryUnique(): Mesh;
  21018. /**
  21019. * Set the index buffer of this mesh
  21020. * @param indices defines the source data
  21021. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21022. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21023. * @returns the current mesh
  21024. */
  21025. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21026. /**
  21027. * Update the current index buffer
  21028. * @param indices defines the source data
  21029. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21030. * @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)
  21031. * @returns the current mesh
  21032. */
  21033. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21034. /**
  21035. * Invert the geometry to move from a right handed system to a left handed one.
  21036. * @returns the current mesh
  21037. */
  21038. toLeftHanded(): Mesh;
  21039. /** @hidden */
  21040. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21041. /** @hidden */
  21042. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21043. /**
  21044. * Registers for this mesh a javascript function called just before the rendering process
  21045. * @param func defines the function to call before rendering this mesh
  21046. * @returns the current mesh
  21047. */
  21048. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21049. /**
  21050. * Disposes a previously registered javascript function called before the rendering
  21051. * @param func defines the function to remove
  21052. * @returns the current mesh
  21053. */
  21054. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21055. /**
  21056. * Registers for this mesh a javascript function called just after the rendering is complete
  21057. * @param func defines the function to call after rendering this mesh
  21058. * @returns the current mesh
  21059. */
  21060. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21061. /**
  21062. * Disposes a previously registered javascript function called after the rendering.
  21063. * @param func defines the function to remove
  21064. * @returns the current mesh
  21065. */
  21066. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21067. /** @hidden */
  21068. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21069. /** @hidden */
  21070. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21071. /** @hidden */
  21072. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21073. /** @hidden */
  21074. _freeze(): void;
  21075. /** @hidden */
  21076. _unFreeze(): void;
  21077. /**
  21078. * 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
  21079. * @param subMesh defines the subMesh to render
  21080. * @param enableAlphaMode defines if alpha mode can be changed
  21081. * @returns the current mesh
  21082. */
  21083. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21084. private _onBeforeDraw;
  21085. /**
  21086. * Renormalize the mesh and patch it up if there are no weights
  21087. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21088. * However in the case of zero weights then we set just a single influence to 1.
  21089. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21090. */
  21091. cleanMatrixWeights(): void;
  21092. private normalizeSkinFourWeights;
  21093. private normalizeSkinWeightsAndExtra;
  21094. /**
  21095. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21096. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21097. * the user know there was an issue with importing the mesh
  21098. * @returns a validation object with skinned, valid and report string
  21099. */
  21100. validateSkinning(): {
  21101. skinned: boolean;
  21102. valid: boolean;
  21103. report: string;
  21104. };
  21105. /** @hidden */
  21106. _checkDelayState(): Mesh;
  21107. private _queueLoad;
  21108. /**
  21109. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21110. * A mesh is in the frustum if its bounding box intersects the frustum
  21111. * @param frustumPlanes defines the frustum to test
  21112. * @returns true if the mesh is in the frustum planes
  21113. */
  21114. isInFrustum(frustumPlanes: Plane[]): boolean;
  21115. /**
  21116. * Sets the mesh material by the material or multiMaterial `id` property
  21117. * @param id is a string identifying the material or the multiMaterial
  21118. * @returns the current mesh
  21119. */
  21120. setMaterialByID(id: string): Mesh;
  21121. /**
  21122. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21123. * @returns an array of IAnimatable
  21124. */
  21125. getAnimatables(): IAnimatable[];
  21126. /**
  21127. * Modifies the mesh geometry according to the passed transformation matrix.
  21128. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21129. * The mesh normals are modified using the same transformation.
  21130. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21131. * @param transform defines the transform matrix to use
  21132. * @see http://doc.babylonjs.com/resources/baking_transformations
  21133. * @returns the current mesh
  21134. */
  21135. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21136. /**
  21137. * Modifies the mesh geometry according to its own current World Matrix.
  21138. * The mesh World Matrix is then reset.
  21139. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21140. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21141. * @see http://doc.babylonjs.com/resources/baking_transformations
  21142. * @returns the current mesh
  21143. */
  21144. bakeCurrentTransformIntoVertices(): Mesh;
  21145. /** @hidden */
  21146. readonly _positions: Nullable<Vector3[]>;
  21147. /** @hidden */
  21148. _resetPointsArrayCache(): Mesh;
  21149. /** @hidden */
  21150. _generatePointsArray(): boolean;
  21151. /**
  21152. * Returns a new Mesh object generated from the current mesh properties.
  21153. * This method must not get confused with createInstance()
  21154. * @param name is a string, the name given to the new mesh
  21155. * @param newParent can be any Node object (default `null`)
  21156. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21157. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21158. * @returns a new mesh
  21159. */
  21160. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21161. /**
  21162. * Releases resources associated with this mesh.
  21163. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21164. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21165. */
  21166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21167. /**
  21168. * Modifies the mesh geometry according to a displacement map.
  21169. * 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.
  21170. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21171. * @param url is a string, the URL from the image file is to be downloaded.
  21172. * @param minHeight is the lower limit of the displacement.
  21173. * @param maxHeight is the upper limit of the displacement.
  21174. * @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.
  21175. * @param uvOffset is an optional vector2 used to offset UV.
  21176. * @param uvScale is an optional vector2 used to scale UV.
  21177. * @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.
  21178. * @returns the Mesh.
  21179. */
  21180. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21181. /**
  21182. * Modifies the mesh geometry according to a displacementMap buffer.
  21183. * 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.
  21184. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21185. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21186. * @param heightMapWidth is the width of the buffer image.
  21187. * @param heightMapHeight is the height of the buffer image.
  21188. * @param minHeight is the lower limit of the displacement.
  21189. * @param maxHeight is the upper limit of the displacement.
  21190. * @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.
  21191. * @param uvOffset is an optional vector2 used to offset UV.
  21192. * @param uvScale is an optional vector2 used to scale UV.
  21193. * @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.
  21194. * @returns the Mesh.
  21195. */
  21196. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21197. /**
  21198. * Modify the mesh to get a flat shading rendering.
  21199. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21200. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21201. * @returns current mesh
  21202. */
  21203. convertToFlatShadedMesh(): Mesh;
  21204. /**
  21205. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21206. * In other words, more vertices, no more indices and a single bigger VBO.
  21207. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21208. * @returns current mesh
  21209. */
  21210. convertToUnIndexedMesh(): Mesh;
  21211. /**
  21212. * Inverses facet orientations.
  21213. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21214. * @param flipNormals will also inverts the normals
  21215. * @returns current mesh
  21216. */
  21217. flipFaces(flipNormals?: boolean): Mesh;
  21218. /**
  21219. * Increase the number of facets and hence vertices in a mesh
  21220. * Vertex normals are interpolated from existing vertex normals
  21221. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21222. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21223. */
  21224. increaseVertices(numberPerEdge: number): void;
  21225. /**
  21226. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21227. * This will undo any application of covertToFlatShadedMesh
  21228. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21229. */
  21230. forceSharedVertices(): void;
  21231. /** @hidden */
  21232. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21233. /** @hidden */
  21234. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21235. /**
  21236. * Creates a new InstancedMesh object from the mesh model.
  21237. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21238. * @param name defines the name of the new instance
  21239. * @returns a new InstancedMesh
  21240. */
  21241. createInstance(name: string): InstancedMesh;
  21242. /**
  21243. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21244. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21245. * @returns the current mesh
  21246. */
  21247. synchronizeInstances(): Mesh;
  21248. /**
  21249. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21250. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21251. * This should be used together with the simplification to avoid disappearing triangles.
  21252. * @param successCallback an optional success callback to be called after the optimization finished.
  21253. * @returns the current mesh
  21254. */
  21255. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21256. /**
  21257. * Serialize current mesh
  21258. * @param serializationObject defines the object which will receive the serialization data
  21259. */
  21260. serialize(serializationObject: any): void;
  21261. /** @hidden */
  21262. _syncGeometryWithMorphTargetManager(): void;
  21263. /** @hidden */
  21264. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21265. /**
  21266. * Returns a new Mesh object parsed from the source provided.
  21267. * @param parsedMesh is the source
  21268. * @param scene defines the hosting scene
  21269. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21270. * @returns a new Mesh
  21271. */
  21272. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21273. /**
  21274. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21275. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21276. * @param name defines the name of the mesh to create
  21277. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21278. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21279. * @param closePath creates a seam between the first and the last points of each path of the path array
  21280. * @param offset is taken in account only if the `pathArray` is containing a single path
  21281. * @param scene defines the hosting scene
  21282. * @param updatable defines if the mesh must be flagged as updatable
  21283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21284. * @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)
  21285. * @returns a new Mesh
  21286. */
  21287. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21288. /**
  21289. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21290. * @param name defines the name of the mesh to create
  21291. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21292. * @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
  21293. * @param scene defines the hosting scene
  21294. * @param updatable defines if the mesh must be flagged as updatable
  21295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21296. * @returns a new Mesh
  21297. */
  21298. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21299. /**
  21300. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21301. * @param name defines the name of the mesh to create
  21302. * @param size sets the size (float) of each box side (default 1)
  21303. * @param scene defines the hosting scene
  21304. * @param updatable defines if the mesh must be flagged as updatable
  21305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21306. * @returns a new Mesh
  21307. */
  21308. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21309. /**
  21310. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21311. * @param name defines the name of the mesh to create
  21312. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21313. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21314. * @param scene defines the hosting scene
  21315. * @param updatable defines if the mesh must be flagged as updatable
  21316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21317. * @returns a new Mesh
  21318. */
  21319. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21320. /**
  21321. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21322. * @param name defines the name of the mesh to create
  21323. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21324. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21325. * @param scene defines the hosting scene
  21326. * @returns a new Mesh
  21327. */
  21328. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21329. /**
  21330. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21331. * @param name defines the name of the mesh to create
  21332. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21333. * @param diameterTop set the top cap diameter (floats, default 1)
  21334. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21335. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21336. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21337. * @param scene defines the hosting scene
  21338. * @param updatable defines if the mesh must be flagged as updatable
  21339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21340. * @returns a new Mesh
  21341. */
  21342. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21343. /**
  21344. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21345. * @param name defines the name of the mesh to create
  21346. * @param diameter sets the diameter size (float) of the torus (default 1)
  21347. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21348. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21349. * @param scene defines the hosting scene
  21350. * @param updatable defines if the mesh must be flagged as updatable
  21351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21352. * @returns a new Mesh
  21353. */
  21354. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21355. /**
  21356. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21357. * @param name defines the name of the mesh to create
  21358. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21359. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21360. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21361. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21362. * @param p the number of windings on X axis (positive integers, default 2)
  21363. * @param q the number of windings on Y axis (positive integers, default 3)
  21364. * @param scene defines the hosting scene
  21365. * @param updatable defines if the mesh must be flagged as updatable
  21366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21367. * @returns a new Mesh
  21368. */
  21369. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21370. /**
  21371. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21372. * @param name defines the name of the mesh to create
  21373. * @param points is an array successive Vector3
  21374. * @param scene defines the hosting scene
  21375. * @param updatable defines if the mesh must be flagged as updatable
  21376. * @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).
  21377. * @returns a new Mesh
  21378. */
  21379. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21380. /**
  21381. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21382. * @param name defines the name of the mesh to create
  21383. * @param points is an array successive Vector3
  21384. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21385. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21386. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21387. * @param scene defines the hosting scene
  21388. * @param updatable defines if the mesh must be flagged as updatable
  21389. * @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)
  21390. * @returns a new Mesh
  21391. */
  21392. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21393. /**
  21394. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21395. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21396. * 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.
  21397. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21398. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21399. * Remember you can only change the shape positions, not their number when updating a polygon.
  21400. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21401. * @param name defines the name of the mesh to create
  21402. * @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
  21403. * @param scene defines the hosting scene
  21404. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21405. * @param updatable defines if the mesh must be flagged as updatable
  21406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21407. * @param earcutInjection can be used to inject your own earcut reference
  21408. * @returns a new Mesh
  21409. */
  21410. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21411. /**
  21412. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21413. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21414. * @param name defines the name of the mesh to create
  21415. * @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
  21416. * @param depth defines the height of extrusion
  21417. * @param scene defines the hosting scene
  21418. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21419. * @param updatable defines if the mesh must be flagged as updatable
  21420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21421. * @param earcutInjection can be used to inject your own earcut reference
  21422. * @returns a new Mesh
  21423. */
  21424. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21425. /**
  21426. * Creates an extruded shape mesh.
  21427. * 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
  21428. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21429. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21430. * @param name defines the name of the mesh to create
  21431. * @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
  21432. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21433. * @param scale is the value to scale the shape
  21434. * @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
  21435. * @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
  21436. * @param scene defines the hosting scene
  21437. * @param updatable defines if the mesh must be flagged as updatable
  21438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21439. * @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)
  21440. * @returns a new Mesh
  21441. */
  21442. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21443. /**
  21444. * Creates an custom extruded shape mesh.
  21445. * The custom extrusion is a parametric shape.
  21446. * It has no predefined shape. Its final shape will depend on the input parameters.
  21447. * Please consider using the same method from the MeshBuilder class instead
  21448. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21449. * @param name defines the name of the mesh to create
  21450. * @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
  21451. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21452. * @param scaleFunction is a custom Javascript function called on each path point
  21453. * @param rotationFunction is a custom Javascript function called on each path point
  21454. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21455. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21456. * @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
  21457. * @param scene defines the hosting scene
  21458. * @param updatable defines if the mesh must be flagged as updatable
  21459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21460. * @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)
  21461. * @returns a new Mesh
  21462. */
  21463. 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;
  21464. /**
  21465. * Creates lathe mesh.
  21466. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21467. * Please consider using the same method from the MeshBuilder class instead
  21468. * @param name defines the name of the mesh to create
  21469. * @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
  21470. * @param radius is the radius value of the lathe
  21471. * @param tessellation is the side number of the lathe.
  21472. * @param scene defines the hosting scene
  21473. * @param updatable defines if the mesh must be flagged as updatable
  21474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21475. * @returns a new Mesh
  21476. */
  21477. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21478. /**
  21479. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21480. * @param name defines the name of the mesh to create
  21481. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21482. * @param scene defines the hosting scene
  21483. * @param updatable defines if the mesh must be flagged as updatable
  21484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21485. * @returns a new Mesh
  21486. */
  21487. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21488. /**
  21489. * Creates a ground mesh.
  21490. * Please consider using the same method from the MeshBuilder class instead
  21491. * @param name defines the name of the mesh to create
  21492. * @param width set the width of the ground
  21493. * @param height set the height of the ground
  21494. * @param subdivisions sets the number of subdivisions per side
  21495. * @param scene defines the hosting scene
  21496. * @param updatable defines if the mesh must be flagged as updatable
  21497. * @returns a new Mesh
  21498. */
  21499. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21500. /**
  21501. * Creates a tiled ground mesh.
  21502. * Please consider using the same method from the MeshBuilder class instead
  21503. * @param name defines the name of the mesh to create
  21504. * @param xmin set the ground minimum X coordinate
  21505. * @param zmin set the ground minimum Y coordinate
  21506. * @param xmax set the ground maximum X coordinate
  21507. * @param zmax set the ground maximum Z coordinate
  21508. * @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
  21509. * @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
  21510. * @param scene defines the hosting scene
  21511. * @param updatable defines if the mesh must be flagged as updatable
  21512. * @returns a new Mesh
  21513. */
  21514. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21515. w: number;
  21516. h: number;
  21517. }, precision: {
  21518. w: number;
  21519. h: number;
  21520. }, scene: Scene, updatable?: boolean): Mesh;
  21521. /**
  21522. * Creates a ground mesh from a height map.
  21523. * Please consider using the same method from the MeshBuilder class instead
  21524. * @see http://doc.babylonjs.com/babylon101/height_map
  21525. * @param name defines the name of the mesh to create
  21526. * @param url sets the URL of the height map image resource
  21527. * @param width set the ground width size
  21528. * @param height set the ground height size
  21529. * @param subdivisions sets the number of subdivision per side
  21530. * @param minHeight is the minimum altitude on the ground
  21531. * @param maxHeight is the maximum altitude on the ground
  21532. * @param scene defines the hosting scene
  21533. * @param updatable defines if the mesh must be flagged as updatable
  21534. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21535. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21536. * @returns a new Mesh
  21537. */
  21538. 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;
  21539. /**
  21540. * Creates a tube mesh.
  21541. * The tube is a parametric shape.
  21542. * It has no predefined shape. Its final shape will depend on the input parameters.
  21543. * Please consider using the same method from the MeshBuilder class instead
  21544. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21545. * @param name defines the name of the mesh to create
  21546. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21547. * @param radius sets the tube radius size
  21548. * @param tessellation is the number of sides on the tubular surface
  21549. * @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
  21550. * @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
  21551. * @param scene defines the hosting scene
  21552. * @param updatable defines if the mesh must be flagged as updatable
  21553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21554. * @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)
  21555. * @returns a new Mesh
  21556. */
  21557. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21558. (i: number, distance: number): number;
  21559. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21560. /**
  21561. * Creates a polyhedron mesh.
  21562. * Please consider using the same method from the MeshBuilder class instead.
  21563. * * 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
  21564. * * The parameter `size` (positive float, default 1) sets the polygon size
  21565. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21566. * * 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`
  21567. * * 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
  21568. * * 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)`)
  21569. * * 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
  21570. * * 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
  21571. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21572. * * 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
  21573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21574. * @param name defines the name of the mesh to create
  21575. * @param options defines the options used to create the mesh
  21576. * @param scene defines the hosting scene
  21577. * @returns a new Mesh
  21578. */
  21579. static CreatePolyhedron(name: string, options: {
  21580. type?: number;
  21581. size?: number;
  21582. sizeX?: number;
  21583. sizeY?: number;
  21584. sizeZ?: number;
  21585. custom?: any;
  21586. faceUV?: Vector4[];
  21587. faceColors?: Color4[];
  21588. updatable?: boolean;
  21589. sideOrientation?: number;
  21590. }, scene: Scene): Mesh;
  21591. /**
  21592. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21593. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21594. * * 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`)
  21595. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21596. * * 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
  21597. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21598. * * 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
  21599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21600. * @param name defines the name of the mesh
  21601. * @param options defines the options used to create the mesh
  21602. * @param scene defines the hosting scene
  21603. * @returns a new Mesh
  21604. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21605. */
  21606. static CreateIcoSphere(name: string, options: {
  21607. radius?: number;
  21608. flat?: boolean;
  21609. subdivisions?: number;
  21610. sideOrientation?: number;
  21611. updatable?: boolean;
  21612. }, scene: Scene): Mesh;
  21613. /**
  21614. * Creates a decal mesh.
  21615. * Please consider using the same method from the MeshBuilder class instead.
  21616. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21617. * @param name defines the name of the mesh
  21618. * @param sourceMesh defines the mesh receiving the decal
  21619. * @param position sets the position of the decal in world coordinates
  21620. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21621. * @param size sets the decal scaling
  21622. * @param angle sets the angle to rotate the decal
  21623. * @returns a new Mesh
  21624. */
  21625. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21626. /**
  21627. * Prepare internal position array for software CPU skinning
  21628. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21629. */
  21630. setPositionsForCPUSkinning(): Float32Array;
  21631. /**
  21632. * Prepare internal normal array for software CPU skinning
  21633. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21634. */
  21635. setNormalsForCPUSkinning(): Float32Array;
  21636. /**
  21637. * Updates the vertex buffer by applying transformation from the bones
  21638. * @param skeleton defines the skeleton to apply to current mesh
  21639. * @returns the current mesh
  21640. */
  21641. applySkeleton(skeleton: Skeleton): Mesh;
  21642. /**
  21643. * 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
  21644. * @param meshes defines the list of meshes to scan
  21645. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21646. */
  21647. static MinMax(meshes: AbstractMesh[]): {
  21648. min: Vector3;
  21649. max: Vector3;
  21650. };
  21651. /**
  21652. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21653. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21654. * @returns a vector3
  21655. */
  21656. static Center(meshesOrMinMaxVector: {
  21657. min: Vector3;
  21658. max: Vector3;
  21659. } | AbstractMesh[]): Vector3;
  21660. /**
  21661. * Merge the array of meshes into a single mesh for performance reasons.
  21662. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21663. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21664. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21665. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21666. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21667. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21668. * @returns a new mesh
  21669. */
  21670. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21671. /** @hidden */
  21672. addInstance(instance: InstancedMesh): void;
  21673. /** @hidden */
  21674. removeInstance(instance: InstancedMesh): void;
  21675. }
  21676. }
  21677. declare module BABYLON {
  21678. /**
  21679. * Base class for the main features of a material in Babylon.js
  21680. */
  21681. export class Material implements IAnimatable {
  21682. /**
  21683. * Returns the triangle fill mode
  21684. */
  21685. static readonly TriangleFillMode: number;
  21686. /**
  21687. * Returns the wireframe mode
  21688. */
  21689. static readonly WireFrameFillMode: number;
  21690. /**
  21691. * Returns the point fill mode
  21692. */
  21693. static readonly PointFillMode: number;
  21694. /**
  21695. * Returns the point list draw mode
  21696. */
  21697. static readonly PointListDrawMode: number;
  21698. /**
  21699. * Returns the line list draw mode
  21700. */
  21701. static readonly LineListDrawMode: number;
  21702. /**
  21703. * Returns the line loop draw mode
  21704. */
  21705. static readonly LineLoopDrawMode: number;
  21706. /**
  21707. * Returns the line strip draw mode
  21708. */
  21709. static readonly LineStripDrawMode: number;
  21710. /**
  21711. * Returns the triangle strip draw mode
  21712. */
  21713. static readonly TriangleStripDrawMode: number;
  21714. /**
  21715. * Returns the triangle fan draw mode
  21716. */
  21717. static readonly TriangleFanDrawMode: number;
  21718. /**
  21719. * Stores the clock-wise side orientation
  21720. */
  21721. static readonly ClockWiseSideOrientation: number;
  21722. /**
  21723. * Stores the counter clock-wise side orientation
  21724. */
  21725. static readonly CounterClockWiseSideOrientation: number;
  21726. /**
  21727. * The dirty texture flag value
  21728. */
  21729. static readonly TextureDirtyFlag: number;
  21730. /**
  21731. * The dirty light flag value
  21732. */
  21733. static readonly LightDirtyFlag: number;
  21734. /**
  21735. * The dirty fresnel flag value
  21736. */
  21737. static readonly FresnelDirtyFlag: number;
  21738. /**
  21739. * The dirty attribute flag value
  21740. */
  21741. static readonly AttributesDirtyFlag: number;
  21742. /**
  21743. * The dirty misc flag value
  21744. */
  21745. static readonly MiscDirtyFlag: number;
  21746. /**
  21747. * The all dirty flag value
  21748. */
  21749. static readonly AllDirtyFlag: number;
  21750. /**
  21751. * The ID of the material
  21752. */
  21753. id: string;
  21754. /**
  21755. * Gets or sets the unique id of the material
  21756. */
  21757. uniqueId: number;
  21758. /**
  21759. * The name of the material
  21760. */
  21761. name: string;
  21762. /**
  21763. * Gets or sets user defined metadata
  21764. */
  21765. metadata: any;
  21766. /**
  21767. * For internal use only. Please do not use.
  21768. */
  21769. reservedDataStore: any;
  21770. /**
  21771. * Specifies if the ready state should be checked on each call
  21772. */
  21773. checkReadyOnEveryCall: boolean;
  21774. /**
  21775. * Specifies if the ready state should be checked once
  21776. */
  21777. checkReadyOnlyOnce: boolean;
  21778. /**
  21779. * The state of the material
  21780. */
  21781. state: string;
  21782. /**
  21783. * The alpha value of the material
  21784. */
  21785. protected _alpha: number;
  21786. /**
  21787. * List of inspectable custom properties (used by the Inspector)
  21788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21789. */
  21790. inspectableCustomProperties: IInspectable[];
  21791. /**
  21792. * Sets the alpha value of the material
  21793. */
  21794. /**
  21795. * Gets the alpha value of the material
  21796. */
  21797. alpha: number;
  21798. /**
  21799. * Specifies if back face culling is enabled
  21800. */
  21801. protected _backFaceCulling: boolean;
  21802. /**
  21803. * Sets the back-face culling state
  21804. */
  21805. /**
  21806. * Gets the back-face culling state
  21807. */
  21808. backFaceCulling: boolean;
  21809. /**
  21810. * Stores the value for side orientation
  21811. */
  21812. sideOrientation: number;
  21813. /**
  21814. * Callback triggered when the material is compiled
  21815. */
  21816. onCompiled: Nullable<(effect: Effect) => void>;
  21817. /**
  21818. * Callback triggered when an error occurs
  21819. */
  21820. onError: Nullable<(effect: Effect, errors: string) => void>;
  21821. /**
  21822. * Callback triggered to get the render target textures
  21823. */
  21824. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21825. /**
  21826. * Gets a boolean indicating that current material needs to register RTT
  21827. */
  21828. readonly hasRenderTargetTextures: boolean;
  21829. /**
  21830. * Specifies if the material should be serialized
  21831. */
  21832. doNotSerialize: boolean;
  21833. /**
  21834. * @hidden
  21835. */
  21836. _storeEffectOnSubMeshes: boolean;
  21837. /**
  21838. * Stores the animations for the material
  21839. */
  21840. animations: Nullable<Array<Animation>>;
  21841. /**
  21842. * An event triggered when the material is disposed
  21843. */
  21844. onDisposeObservable: Observable<Material>;
  21845. /**
  21846. * An observer which watches for dispose events
  21847. */
  21848. private _onDisposeObserver;
  21849. private _onUnBindObservable;
  21850. /**
  21851. * Called during a dispose event
  21852. */
  21853. onDispose: () => void;
  21854. private _onBindObservable;
  21855. /**
  21856. * An event triggered when the material is bound
  21857. */
  21858. readonly onBindObservable: Observable<AbstractMesh>;
  21859. /**
  21860. * An observer which watches for bind events
  21861. */
  21862. private _onBindObserver;
  21863. /**
  21864. * Called during a bind event
  21865. */
  21866. onBind: (Mesh: AbstractMesh) => void;
  21867. /**
  21868. * An event triggered when the material is unbound
  21869. */
  21870. readonly onUnBindObservable: Observable<Material>;
  21871. /**
  21872. * Stores the value of the alpha mode
  21873. */
  21874. private _alphaMode;
  21875. /**
  21876. * Sets the value of the alpha mode.
  21877. *
  21878. * | Value | Type | Description |
  21879. * | --- | --- | --- |
  21880. * | 0 | ALPHA_DISABLE | |
  21881. * | 1 | ALPHA_ADD | |
  21882. * | 2 | ALPHA_COMBINE | |
  21883. * | 3 | ALPHA_SUBTRACT | |
  21884. * | 4 | ALPHA_MULTIPLY | |
  21885. * | 5 | ALPHA_MAXIMIZED | |
  21886. * | 6 | ALPHA_ONEONE | |
  21887. * | 7 | ALPHA_PREMULTIPLIED | |
  21888. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21889. * | 9 | ALPHA_INTERPOLATE | |
  21890. * | 10 | ALPHA_SCREENMODE | |
  21891. *
  21892. */
  21893. /**
  21894. * Gets the value of the alpha mode
  21895. */
  21896. alphaMode: number;
  21897. /**
  21898. * Stores the state of the need depth pre-pass value
  21899. */
  21900. private _needDepthPrePass;
  21901. /**
  21902. * Sets the need depth pre-pass value
  21903. */
  21904. /**
  21905. * Gets the depth pre-pass value
  21906. */
  21907. needDepthPrePass: boolean;
  21908. /**
  21909. * Specifies if depth writing should be disabled
  21910. */
  21911. disableDepthWrite: boolean;
  21912. /**
  21913. * Specifies if depth writing should be forced
  21914. */
  21915. forceDepthWrite: boolean;
  21916. /**
  21917. * Specifies if there should be a separate pass for culling
  21918. */
  21919. separateCullingPass: boolean;
  21920. /**
  21921. * Stores the state specifing if fog should be enabled
  21922. */
  21923. private _fogEnabled;
  21924. /**
  21925. * Sets the state for enabling fog
  21926. */
  21927. /**
  21928. * Gets the value of the fog enabled state
  21929. */
  21930. fogEnabled: boolean;
  21931. /**
  21932. * Stores the size of points
  21933. */
  21934. pointSize: number;
  21935. /**
  21936. * Stores the z offset value
  21937. */
  21938. zOffset: number;
  21939. /**
  21940. * Gets a value specifying if wireframe mode is enabled
  21941. */
  21942. /**
  21943. * Sets the state of wireframe mode
  21944. */
  21945. wireframe: boolean;
  21946. /**
  21947. * Gets the value specifying if point clouds are enabled
  21948. */
  21949. /**
  21950. * Sets the state of point cloud mode
  21951. */
  21952. pointsCloud: boolean;
  21953. /**
  21954. * Gets the material fill mode
  21955. */
  21956. /**
  21957. * Sets the material fill mode
  21958. */
  21959. fillMode: number;
  21960. /**
  21961. * @hidden
  21962. * Stores the effects for the material
  21963. */
  21964. _effect: Nullable<Effect>;
  21965. /**
  21966. * @hidden
  21967. * Specifies if the material was previously ready
  21968. */
  21969. _wasPreviouslyReady: boolean;
  21970. /**
  21971. * Specifies if uniform buffers should be used
  21972. */
  21973. private _useUBO;
  21974. /**
  21975. * Stores a reference to the scene
  21976. */
  21977. private _scene;
  21978. /**
  21979. * Stores the fill mode state
  21980. */
  21981. private _fillMode;
  21982. /**
  21983. * Specifies if the depth write state should be cached
  21984. */
  21985. private _cachedDepthWriteState;
  21986. /**
  21987. * Stores the uniform buffer
  21988. */
  21989. protected _uniformBuffer: UniformBuffer;
  21990. /** @hidden */
  21991. _indexInSceneMaterialArray: number;
  21992. /** @hidden */
  21993. meshMap: Nullable<{
  21994. [id: string]: AbstractMesh | undefined;
  21995. }>;
  21996. /**
  21997. * Creates a material instance
  21998. * @param name defines the name of the material
  21999. * @param scene defines the scene to reference
  22000. * @param doNotAdd specifies if the material should be added to the scene
  22001. */
  22002. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22003. /**
  22004. * Returns a string representation of the current material
  22005. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22006. * @returns a string with material information
  22007. */
  22008. toString(fullDetails?: boolean): string;
  22009. /**
  22010. * Gets the class name of the material
  22011. * @returns a string with the class name of the material
  22012. */
  22013. getClassName(): string;
  22014. /**
  22015. * Specifies if updates for the material been locked
  22016. */
  22017. readonly isFrozen: boolean;
  22018. /**
  22019. * Locks updates for the material
  22020. */
  22021. freeze(): void;
  22022. /**
  22023. * Unlocks updates for the material
  22024. */
  22025. unfreeze(): void;
  22026. /**
  22027. * Specifies if the material is ready to be used
  22028. * @param mesh defines the mesh to check
  22029. * @param useInstances specifies if instances should be used
  22030. * @returns a boolean indicating if the material is ready to be used
  22031. */
  22032. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22033. /**
  22034. * Specifies that the submesh is ready to be used
  22035. * @param mesh defines the mesh to check
  22036. * @param subMesh defines which submesh to check
  22037. * @param useInstances specifies that instances should be used
  22038. * @returns a boolean indicating that the submesh is ready or not
  22039. */
  22040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22041. /**
  22042. * Returns the material effect
  22043. * @returns the effect associated with the material
  22044. */
  22045. getEffect(): Nullable<Effect>;
  22046. /**
  22047. * Returns the current scene
  22048. * @returns a Scene
  22049. */
  22050. getScene(): Scene;
  22051. /**
  22052. * Specifies if the material will require alpha blending
  22053. * @returns a boolean specifying if alpha blending is needed
  22054. */
  22055. needAlphaBlending(): boolean;
  22056. /**
  22057. * Specifies if the mesh will require alpha blending
  22058. * @param mesh defines the mesh to check
  22059. * @returns a boolean specifying if alpha blending is needed for the mesh
  22060. */
  22061. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22062. /**
  22063. * Specifies if this material should be rendered in alpha test mode
  22064. * @returns a boolean specifying if an alpha test is needed.
  22065. */
  22066. needAlphaTesting(): boolean;
  22067. /**
  22068. * Gets the texture used for the alpha test
  22069. * @returns the texture to use for alpha testing
  22070. */
  22071. getAlphaTestTexture(): Nullable<BaseTexture>;
  22072. /**
  22073. * Marks the material to indicate that it needs to be re-calculated
  22074. */
  22075. markDirty(): void;
  22076. /** @hidden */
  22077. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22078. /**
  22079. * Binds the material to the mesh
  22080. * @param world defines the world transformation matrix
  22081. * @param mesh defines the mesh to bind the material to
  22082. */
  22083. bind(world: Matrix, mesh?: Mesh): void;
  22084. /**
  22085. * Binds the submesh to the material
  22086. * @param world defines the world transformation matrix
  22087. * @param mesh defines the mesh containing the submesh
  22088. * @param subMesh defines the submesh to bind the material to
  22089. */
  22090. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22091. /**
  22092. * Binds the world matrix to the material
  22093. * @param world defines the world transformation matrix
  22094. */
  22095. bindOnlyWorldMatrix(world: Matrix): void;
  22096. /**
  22097. * Binds the scene's uniform buffer to the effect.
  22098. * @param effect defines the effect to bind to the scene uniform buffer
  22099. * @param sceneUbo defines the uniform buffer storing scene data
  22100. */
  22101. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22102. /**
  22103. * Binds the view matrix to the effect
  22104. * @param effect defines the effect to bind the view matrix to
  22105. */
  22106. bindView(effect: Effect): void;
  22107. /**
  22108. * Binds the view projection matrix to the effect
  22109. * @param effect defines the effect to bind the view projection matrix to
  22110. */
  22111. bindViewProjection(effect: Effect): void;
  22112. /**
  22113. * Specifies if material alpha testing should be turned on for the mesh
  22114. * @param mesh defines the mesh to check
  22115. */
  22116. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22117. /**
  22118. * Processes to execute after binding the material to a mesh
  22119. * @param mesh defines the rendered mesh
  22120. */
  22121. protected _afterBind(mesh?: Mesh): void;
  22122. /**
  22123. * Unbinds the material from the mesh
  22124. */
  22125. unbind(): void;
  22126. /**
  22127. * Gets the active textures from the material
  22128. * @returns an array of textures
  22129. */
  22130. getActiveTextures(): BaseTexture[];
  22131. /**
  22132. * Specifies if the material uses a texture
  22133. * @param texture defines the texture to check against the material
  22134. * @returns a boolean specifying if the material uses the texture
  22135. */
  22136. hasTexture(texture: BaseTexture): boolean;
  22137. /**
  22138. * Makes a duplicate of the material, and gives it a new name
  22139. * @param name defines the new name for the duplicated material
  22140. * @returns the cloned material
  22141. */
  22142. clone(name: string): Nullable<Material>;
  22143. /**
  22144. * Gets the meshes bound to the material
  22145. * @returns an array of meshes bound to the material
  22146. */
  22147. getBindedMeshes(): AbstractMesh[];
  22148. /**
  22149. * Force shader compilation
  22150. * @param mesh defines the mesh associated with this material
  22151. * @param onCompiled defines a function to execute once the material is compiled
  22152. * @param options defines the options to configure the compilation
  22153. */
  22154. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22155. clipPlane: boolean;
  22156. }>): void;
  22157. /**
  22158. * Force shader compilation
  22159. * @param mesh defines the mesh that will use this material
  22160. * @param options defines additional options for compiling the shaders
  22161. * @returns a promise that resolves when the compilation completes
  22162. */
  22163. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22164. clipPlane: boolean;
  22165. }>): Promise<void>;
  22166. private static readonly _ImageProcessingDirtyCallBack;
  22167. private static readonly _TextureDirtyCallBack;
  22168. private static readonly _FresnelDirtyCallBack;
  22169. private static readonly _MiscDirtyCallBack;
  22170. private static readonly _LightsDirtyCallBack;
  22171. private static readonly _AttributeDirtyCallBack;
  22172. private static _FresnelAndMiscDirtyCallBack;
  22173. private static _TextureAndMiscDirtyCallBack;
  22174. private static readonly _DirtyCallbackArray;
  22175. private static readonly _RunDirtyCallBacks;
  22176. /**
  22177. * Marks a define in the material to indicate that it needs to be re-computed
  22178. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22179. */
  22180. markAsDirty(flag: number): void;
  22181. /**
  22182. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22183. * @param func defines a function which checks material defines against the submeshes
  22184. */
  22185. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22186. /**
  22187. * Indicates that image processing needs to be re-calculated for all submeshes
  22188. */
  22189. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22190. /**
  22191. * Indicates that textures need to be re-calculated for all submeshes
  22192. */
  22193. protected _markAllSubMeshesAsTexturesDirty(): void;
  22194. /**
  22195. * Indicates that fresnel needs to be re-calculated for all submeshes
  22196. */
  22197. protected _markAllSubMeshesAsFresnelDirty(): void;
  22198. /**
  22199. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22200. */
  22201. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22202. /**
  22203. * Indicates that lights need to be re-calculated for all submeshes
  22204. */
  22205. protected _markAllSubMeshesAsLightsDirty(): void;
  22206. /**
  22207. * Indicates that attributes need to be re-calculated for all submeshes
  22208. */
  22209. protected _markAllSubMeshesAsAttributesDirty(): void;
  22210. /**
  22211. * Indicates that misc needs to be re-calculated for all submeshes
  22212. */
  22213. protected _markAllSubMeshesAsMiscDirty(): void;
  22214. /**
  22215. * Indicates that textures and misc need to be re-calculated for all submeshes
  22216. */
  22217. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22218. /**
  22219. * Disposes the material
  22220. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22221. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22222. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22223. */
  22224. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22225. /** @hidden */
  22226. private releaseVertexArrayObject;
  22227. /**
  22228. * Serializes this material
  22229. * @returns the serialized material object
  22230. */
  22231. serialize(): any;
  22232. /**
  22233. * Creates a material from parsed material data
  22234. * @param parsedMaterial defines parsed material data
  22235. * @param scene defines the hosting scene
  22236. * @param rootUrl defines the root URL to use to load textures
  22237. * @returns a new material
  22238. */
  22239. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22240. }
  22241. }
  22242. declare module BABYLON {
  22243. /**
  22244. * Base class for submeshes
  22245. */
  22246. export class BaseSubMesh {
  22247. /** @hidden */
  22248. _materialDefines: Nullable<MaterialDefines>;
  22249. /** @hidden */
  22250. _materialEffect: Nullable<Effect>;
  22251. /**
  22252. * Gets associated effect
  22253. */
  22254. readonly effect: Nullable<Effect>;
  22255. /**
  22256. * Sets associated effect (effect used to render this submesh)
  22257. * @param effect defines the effect to associate with
  22258. * @param defines defines the set of defines used to compile this effect
  22259. */
  22260. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22261. }
  22262. /**
  22263. * Defines a subdivision inside a mesh
  22264. */
  22265. export class SubMesh extends BaseSubMesh implements ICullable {
  22266. /** the material index to use */
  22267. materialIndex: number;
  22268. /** vertex index start */
  22269. verticesStart: number;
  22270. /** vertices count */
  22271. verticesCount: number;
  22272. /** index start */
  22273. indexStart: number;
  22274. /** indices count */
  22275. indexCount: number;
  22276. /** @hidden */
  22277. _linesIndexCount: number;
  22278. private _mesh;
  22279. private _renderingMesh;
  22280. private _boundingInfo;
  22281. private _linesIndexBuffer;
  22282. /** @hidden */
  22283. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22284. /** @hidden */
  22285. _trianglePlanes: Plane[];
  22286. /** @hidden */
  22287. _lastColliderTransformMatrix: Nullable<Matrix>;
  22288. /** @hidden */
  22289. _renderId: number;
  22290. /** @hidden */
  22291. _alphaIndex: number;
  22292. /** @hidden */
  22293. _distanceToCamera: number;
  22294. /** @hidden */
  22295. _id: number;
  22296. private _currentMaterial;
  22297. /**
  22298. * Add a new submesh to a mesh
  22299. * @param materialIndex defines the material index to use
  22300. * @param verticesStart defines vertex index start
  22301. * @param verticesCount defines vertices count
  22302. * @param indexStart defines index start
  22303. * @param indexCount defines indices count
  22304. * @param mesh defines the parent mesh
  22305. * @param renderingMesh defines an optional rendering mesh
  22306. * @param createBoundingBox defines if bounding box should be created for this submesh
  22307. * @returns the new submesh
  22308. */
  22309. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22310. /**
  22311. * Creates a new submesh
  22312. * @param materialIndex defines the material index to use
  22313. * @param verticesStart defines vertex index start
  22314. * @param verticesCount defines vertices count
  22315. * @param indexStart defines index start
  22316. * @param indexCount defines indices count
  22317. * @param mesh defines the parent mesh
  22318. * @param renderingMesh defines an optional rendering mesh
  22319. * @param createBoundingBox defines if bounding box should be created for this submesh
  22320. */
  22321. constructor(
  22322. /** the material index to use */
  22323. materialIndex: number,
  22324. /** vertex index start */
  22325. verticesStart: number,
  22326. /** vertices count */
  22327. verticesCount: number,
  22328. /** index start */
  22329. indexStart: number,
  22330. /** indices count */
  22331. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22332. /**
  22333. * Returns true if this submesh covers the entire parent mesh
  22334. * @ignorenaming
  22335. */
  22336. readonly IsGlobal: boolean;
  22337. /**
  22338. * Returns the submesh BoudingInfo object
  22339. * @returns current bounding info (or mesh's one if the submesh is global)
  22340. */
  22341. getBoundingInfo(): BoundingInfo;
  22342. /**
  22343. * Sets the submesh BoundingInfo
  22344. * @param boundingInfo defines the new bounding info to use
  22345. * @returns the SubMesh
  22346. */
  22347. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22348. /**
  22349. * Returns the mesh of the current submesh
  22350. * @return the parent mesh
  22351. */
  22352. getMesh(): AbstractMesh;
  22353. /**
  22354. * Returns the rendering mesh of the submesh
  22355. * @returns the rendering mesh (could be different from parent mesh)
  22356. */
  22357. getRenderingMesh(): Mesh;
  22358. /**
  22359. * Returns the submesh material
  22360. * @returns null or the current material
  22361. */
  22362. getMaterial(): Nullable<Material>;
  22363. /**
  22364. * Sets a new updated BoundingInfo object to the submesh
  22365. * @returns the SubMesh
  22366. */
  22367. refreshBoundingInfo(): SubMesh;
  22368. /** @hidden */
  22369. _checkCollision(collider: Collider): boolean;
  22370. /**
  22371. * Updates the submesh BoundingInfo
  22372. * @param world defines the world matrix to use to update the bounding info
  22373. * @returns the submesh
  22374. */
  22375. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22376. /**
  22377. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22378. * @param frustumPlanes defines the frustum planes
  22379. * @returns true if the submesh is intersecting with the frustum
  22380. */
  22381. isInFrustum(frustumPlanes: Plane[]): boolean;
  22382. /**
  22383. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22384. * @param frustumPlanes defines the frustum planes
  22385. * @returns true if the submesh is inside the frustum
  22386. */
  22387. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22388. /**
  22389. * Renders the submesh
  22390. * @param enableAlphaMode defines if alpha needs to be used
  22391. * @returns the submesh
  22392. */
  22393. render(enableAlphaMode: boolean): SubMesh;
  22394. /**
  22395. * @hidden
  22396. */
  22397. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22398. /**
  22399. * Checks if the submesh intersects with a ray
  22400. * @param ray defines the ray to test
  22401. * @returns true is the passed ray intersects the submesh bounding box
  22402. */
  22403. canIntersects(ray: Ray): boolean;
  22404. /**
  22405. * Intersects current submesh with a ray
  22406. * @param ray defines the ray to test
  22407. * @param positions defines mesh's positions array
  22408. * @param indices defines mesh's indices array
  22409. * @param fastCheck defines if only bounding info should be used
  22410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22411. * @returns intersection info or null if no intersection
  22412. */
  22413. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22414. /** @hidden */
  22415. private _intersectLines;
  22416. /** @hidden */
  22417. private _intersectTriangles;
  22418. /** @hidden */
  22419. _rebuild(): void;
  22420. /**
  22421. * Creates a new submesh from the passed mesh
  22422. * @param newMesh defines the new hosting mesh
  22423. * @param newRenderingMesh defines an optional rendering mesh
  22424. * @returns the new submesh
  22425. */
  22426. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22427. /**
  22428. * Release associated resources
  22429. */
  22430. dispose(): void;
  22431. /**
  22432. * Gets the class name
  22433. * @returns the string "SubMesh".
  22434. */
  22435. getClassName(): string;
  22436. /**
  22437. * Creates a new submesh from indices data
  22438. * @param materialIndex the index of the main mesh material
  22439. * @param startIndex the index where to start the copy in the mesh indices array
  22440. * @param indexCount the number of indices to copy then from the startIndex
  22441. * @param mesh the main mesh to create the submesh from
  22442. * @param renderingMesh the optional rendering mesh
  22443. * @returns a new submesh
  22444. */
  22445. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22446. }
  22447. }
  22448. declare module BABYLON {
  22449. /**
  22450. * Class used to store geometry data (vertex buffers + index buffer)
  22451. */
  22452. export class Geometry implements IGetSetVerticesData {
  22453. /**
  22454. * Gets or sets the ID of the geometry
  22455. */
  22456. id: string;
  22457. /**
  22458. * Gets or sets the unique ID of the geometry
  22459. */
  22460. uniqueId: number;
  22461. /**
  22462. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22463. */
  22464. delayLoadState: number;
  22465. /**
  22466. * Gets the file containing the data to load when running in delay load state
  22467. */
  22468. delayLoadingFile: Nullable<string>;
  22469. /**
  22470. * Callback called when the geometry is updated
  22471. */
  22472. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22473. private _scene;
  22474. private _engine;
  22475. private _meshes;
  22476. private _totalVertices;
  22477. /** @hidden */
  22478. _indices: IndicesArray;
  22479. /** @hidden */
  22480. _vertexBuffers: {
  22481. [key: string]: VertexBuffer;
  22482. };
  22483. private _isDisposed;
  22484. private _extend;
  22485. private _boundingBias;
  22486. /** @hidden */
  22487. _delayInfo: Array<string>;
  22488. private _indexBuffer;
  22489. private _indexBufferIsUpdatable;
  22490. /** @hidden */
  22491. _boundingInfo: Nullable<BoundingInfo>;
  22492. /** @hidden */
  22493. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22494. /** @hidden */
  22495. _softwareSkinningFrameId: number;
  22496. private _vertexArrayObjects;
  22497. private _updatable;
  22498. /** @hidden */
  22499. _positions: Nullable<Vector3[]>;
  22500. /**
  22501. * 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
  22502. */
  22503. /**
  22504. * 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
  22505. */
  22506. boundingBias: Vector2;
  22507. /**
  22508. * Static function used to attach a new empty geometry to a mesh
  22509. * @param mesh defines the mesh to attach the geometry to
  22510. * @returns the new Geometry
  22511. */
  22512. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22513. /**
  22514. * Creates a new geometry
  22515. * @param id defines the unique ID
  22516. * @param scene defines the hosting scene
  22517. * @param vertexData defines the VertexData used to get geometry data
  22518. * @param updatable defines if geometry must be updatable (false by default)
  22519. * @param mesh defines the mesh that will be associated with the geometry
  22520. */
  22521. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22522. /**
  22523. * Gets the current extend of the geometry
  22524. */
  22525. readonly extend: {
  22526. minimum: Vector3;
  22527. maximum: Vector3;
  22528. };
  22529. /**
  22530. * Gets the hosting scene
  22531. * @returns the hosting Scene
  22532. */
  22533. getScene(): Scene;
  22534. /**
  22535. * Gets the hosting engine
  22536. * @returns the hosting Engine
  22537. */
  22538. getEngine(): Engine;
  22539. /**
  22540. * Defines if the geometry is ready to use
  22541. * @returns true if the geometry is ready to be used
  22542. */
  22543. isReady(): boolean;
  22544. /**
  22545. * Gets a value indicating that the geometry should not be serialized
  22546. */
  22547. readonly doNotSerialize: boolean;
  22548. /** @hidden */
  22549. _rebuild(): void;
  22550. /**
  22551. * Affects all geometry data in one call
  22552. * @param vertexData defines the geometry data
  22553. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22554. */
  22555. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22556. /**
  22557. * Set specific vertex data
  22558. * @param kind defines the data kind (Position, normal, etc...)
  22559. * @param data defines the vertex data to use
  22560. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22561. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22562. */
  22563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22564. /**
  22565. * Removes a specific vertex data
  22566. * @param kind defines the data kind (Position, normal, etc...)
  22567. */
  22568. removeVerticesData(kind: string): void;
  22569. /**
  22570. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22571. * @param buffer defines the vertex buffer to use
  22572. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22573. */
  22574. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22575. /**
  22576. * Update a specific vertex buffer
  22577. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22578. * It will do nothing if the buffer is not updatable
  22579. * @param kind defines the data kind (Position, normal, etc...)
  22580. * @param data defines the data to use
  22581. * @param offset defines the offset in the target buffer where to store the data
  22582. * @param useBytes set to true if the offset is in bytes
  22583. */
  22584. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22585. /**
  22586. * Update a specific vertex buffer
  22587. * This function will create a new buffer if the current one is not updatable
  22588. * @param kind defines the data kind (Position, normal, etc...)
  22589. * @param data defines the data to use
  22590. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22591. */
  22592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22593. private _updateBoundingInfo;
  22594. /** @hidden */
  22595. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22596. /**
  22597. * Gets total number of vertices
  22598. * @returns the total number of vertices
  22599. */
  22600. getTotalVertices(): number;
  22601. /**
  22602. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22603. * @param kind defines the data kind (Position, normal, etc...)
  22604. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22605. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22606. * @returns a float array containing vertex data
  22607. */
  22608. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22609. /**
  22610. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22611. * @param kind defines the data kind (Position, normal, etc...)
  22612. * @returns true if the vertex buffer with the specified kind is updatable
  22613. */
  22614. isVertexBufferUpdatable(kind: string): boolean;
  22615. /**
  22616. * Gets a specific vertex buffer
  22617. * @param kind defines the data kind (Position, normal, etc...)
  22618. * @returns a VertexBuffer
  22619. */
  22620. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22621. /**
  22622. * Returns all vertex buffers
  22623. * @return an object holding all vertex buffers indexed by kind
  22624. */
  22625. getVertexBuffers(): Nullable<{
  22626. [key: string]: VertexBuffer;
  22627. }>;
  22628. /**
  22629. * Gets a boolean indicating if specific vertex buffer is present
  22630. * @param kind defines the data kind (Position, normal, etc...)
  22631. * @returns true if data is present
  22632. */
  22633. isVerticesDataPresent(kind: string): boolean;
  22634. /**
  22635. * Gets a list of all attached data kinds (Position, normal, etc...)
  22636. * @returns a list of string containing all kinds
  22637. */
  22638. getVerticesDataKinds(): string[];
  22639. /**
  22640. * Update index buffer
  22641. * @param indices defines the indices to store in the index buffer
  22642. * @param offset defines the offset in the target buffer where to store the data
  22643. * @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)
  22644. */
  22645. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22646. /**
  22647. * Creates a new index buffer
  22648. * @param indices defines the indices to store in the index buffer
  22649. * @param totalVertices defines the total number of vertices (could be null)
  22650. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22651. */
  22652. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22653. /**
  22654. * Return the total number of indices
  22655. * @returns the total number of indices
  22656. */
  22657. getTotalIndices(): number;
  22658. /**
  22659. * Gets the index buffer array
  22660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22662. * @returns the index buffer array
  22663. */
  22664. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22665. /**
  22666. * Gets the index buffer
  22667. * @return the index buffer
  22668. */
  22669. getIndexBuffer(): Nullable<WebGLBuffer>;
  22670. /** @hidden */
  22671. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22672. /**
  22673. * Release the associated resources for a specific mesh
  22674. * @param mesh defines the source mesh
  22675. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22676. */
  22677. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22678. /**
  22679. * Apply current geometry to a given mesh
  22680. * @param mesh defines the mesh to apply geometry to
  22681. */
  22682. applyToMesh(mesh: Mesh): void;
  22683. private _updateExtend;
  22684. private _applyToMesh;
  22685. private notifyUpdate;
  22686. /**
  22687. * Load the geometry if it was flagged as delay loaded
  22688. * @param scene defines the hosting scene
  22689. * @param onLoaded defines a callback called when the geometry is loaded
  22690. */
  22691. load(scene: Scene, onLoaded?: () => void): void;
  22692. private _queueLoad;
  22693. /**
  22694. * Invert the geometry to move from a right handed system to a left handed one.
  22695. */
  22696. toLeftHanded(): void;
  22697. /** @hidden */
  22698. _resetPointsArrayCache(): void;
  22699. /** @hidden */
  22700. _generatePointsArray(): boolean;
  22701. /**
  22702. * Gets a value indicating if the geometry is disposed
  22703. * @returns true if the geometry was disposed
  22704. */
  22705. isDisposed(): boolean;
  22706. private _disposeVertexArrayObjects;
  22707. /**
  22708. * Free all associated resources
  22709. */
  22710. dispose(): void;
  22711. /**
  22712. * Clone the current geometry into a new geometry
  22713. * @param id defines the unique ID of the new geometry
  22714. * @returns a new geometry object
  22715. */
  22716. copy(id: string): Geometry;
  22717. /**
  22718. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22719. * @return a JSON representation of the current geometry data (without the vertices data)
  22720. */
  22721. serialize(): any;
  22722. private toNumberArray;
  22723. /**
  22724. * Serialize all vertices data into a JSON oject
  22725. * @returns a JSON representation of the current geometry data
  22726. */
  22727. serializeVerticeData(): any;
  22728. /**
  22729. * Extracts a clone of a mesh geometry
  22730. * @param mesh defines the source mesh
  22731. * @param id defines the unique ID of the new geometry object
  22732. * @returns the new geometry object
  22733. */
  22734. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22735. /**
  22736. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22737. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22738. * Be aware Math.random() could cause collisions, but:
  22739. * "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"
  22740. * @returns a string containing a new GUID
  22741. */
  22742. static RandomId(): string;
  22743. /** @hidden */
  22744. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22745. private static _CleanMatricesWeights;
  22746. /**
  22747. * Create a new geometry from persisted data (Using .babylon file format)
  22748. * @param parsedVertexData defines the persisted data
  22749. * @param scene defines the hosting scene
  22750. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22751. * @returns the new geometry object
  22752. */
  22753. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22754. }
  22755. }
  22756. declare module BABYLON {
  22757. /**
  22758. * Define an interface for all classes that will get and set the data on vertices
  22759. */
  22760. export interface IGetSetVerticesData {
  22761. /**
  22762. * Gets a boolean indicating if specific vertex data is present
  22763. * @param kind defines the vertex data kind to use
  22764. * @returns true is data kind is present
  22765. */
  22766. isVerticesDataPresent(kind: string): boolean;
  22767. /**
  22768. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22769. * @param kind defines the data kind (Position, normal, etc...)
  22770. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22771. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22772. * @returns a float array containing vertex data
  22773. */
  22774. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22775. /**
  22776. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22777. * @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.
  22778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22779. * @returns the indices array or an empty array if the mesh has no geometry
  22780. */
  22781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22782. /**
  22783. * Set specific vertex data
  22784. * @param kind defines the data kind (Position, normal, etc...)
  22785. * @param data defines the vertex data to use
  22786. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22787. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22788. */
  22789. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22790. /**
  22791. * Update a specific associated vertex buffer
  22792. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22793. * - VertexBuffer.PositionKind
  22794. * - VertexBuffer.UVKind
  22795. * - VertexBuffer.UV2Kind
  22796. * - VertexBuffer.UV3Kind
  22797. * - VertexBuffer.UV4Kind
  22798. * - VertexBuffer.UV5Kind
  22799. * - VertexBuffer.UV6Kind
  22800. * - VertexBuffer.ColorKind
  22801. * - VertexBuffer.MatricesIndicesKind
  22802. * - VertexBuffer.MatricesIndicesExtraKind
  22803. * - VertexBuffer.MatricesWeightsKind
  22804. * - VertexBuffer.MatricesWeightsExtraKind
  22805. * @param data defines the data source
  22806. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22807. * @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)
  22808. */
  22809. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22810. /**
  22811. * Creates a new index buffer
  22812. * @param indices defines the indices to store in the index buffer
  22813. * @param totalVertices defines the total number of vertices (could be null)
  22814. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22815. */
  22816. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22817. }
  22818. /**
  22819. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22820. */
  22821. export class VertexData {
  22822. /**
  22823. * Mesh side orientation : usually the external or front surface
  22824. */
  22825. static readonly FRONTSIDE: number;
  22826. /**
  22827. * Mesh side orientation : usually the internal or back surface
  22828. */
  22829. static readonly BACKSIDE: number;
  22830. /**
  22831. * Mesh side orientation : both internal and external or front and back surfaces
  22832. */
  22833. static readonly DOUBLESIDE: number;
  22834. /**
  22835. * Mesh side orientation : by default, `FRONTSIDE`
  22836. */
  22837. static readonly DEFAULTSIDE: number;
  22838. /**
  22839. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22840. */
  22841. positions: Nullable<FloatArray>;
  22842. /**
  22843. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22844. */
  22845. normals: Nullable<FloatArray>;
  22846. /**
  22847. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22848. */
  22849. tangents: Nullable<FloatArray>;
  22850. /**
  22851. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22852. */
  22853. uvs: Nullable<FloatArray>;
  22854. /**
  22855. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22856. */
  22857. uvs2: Nullable<FloatArray>;
  22858. /**
  22859. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22860. */
  22861. uvs3: Nullable<FloatArray>;
  22862. /**
  22863. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22864. */
  22865. uvs4: Nullable<FloatArray>;
  22866. /**
  22867. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22868. */
  22869. uvs5: Nullable<FloatArray>;
  22870. /**
  22871. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22872. */
  22873. uvs6: Nullable<FloatArray>;
  22874. /**
  22875. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22876. */
  22877. colors: Nullable<FloatArray>;
  22878. /**
  22879. * 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).
  22880. */
  22881. matricesIndices: Nullable<FloatArray>;
  22882. /**
  22883. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22884. */
  22885. matricesWeights: Nullable<FloatArray>;
  22886. /**
  22887. * An array extending the number of possible indices
  22888. */
  22889. matricesIndicesExtra: Nullable<FloatArray>;
  22890. /**
  22891. * An array extending the number of possible weights when the number of indices is extended
  22892. */
  22893. matricesWeightsExtra: Nullable<FloatArray>;
  22894. /**
  22895. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22896. */
  22897. indices: Nullable<IndicesArray>;
  22898. /**
  22899. * Uses the passed data array to set the set the values for the specified kind of data
  22900. * @param data a linear array of floating numbers
  22901. * @param kind the type of data that is being set, eg positions, colors etc
  22902. */
  22903. set(data: FloatArray, kind: string): void;
  22904. /**
  22905. * Associates the vertexData to the passed Mesh.
  22906. * Sets it as updatable or not (default `false`)
  22907. * @param mesh the mesh the vertexData is applied to
  22908. * @param updatable when used and having the value true allows new data to update the vertexData
  22909. * @returns the VertexData
  22910. */
  22911. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22912. /**
  22913. * Associates the vertexData to the passed Geometry.
  22914. * Sets it as updatable or not (default `false`)
  22915. * @param geometry the geometry the vertexData is applied to
  22916. * @param updatable when used and having the value true allows new data to update the vertexData
  22917. * @returns VertexData
  22918. */
  22919. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22920. /**
  22921. * Updates the associated mesh
  22922. * @param mesh the mesh to be updated
  22923. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22924. * @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
  22925. * @returns VertexData
  22926. */
  22927. updateMesh(mesh: Mesh): VertexData;
  22928. /**
  22929. * Updates the associated geometry
  22930. * @param geometry the geometry to be updated
  22931. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22932. * @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
  22933. * @returns VertexData.
  22934. */
  22935. updateGeometry(geometry: Geometry): VertexData;
  22936. private _applyTo;
  22937. private _update;
  22938. /**
  22939. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22940. * @param matrix the transforming matrix
  22941. * @returns the VertexData
  22942. */
  22943. transform(matrix: Matrix): VertexData;
  22944. /**
  22945. * Merges the passed VertexData into the current one
  22946. * @param other the VertexData to be merged into the current one
  22947. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22948. * @returns the modified VertexData
  22949. */
  22950. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22951. private _mergeElement;
  22952. private _validate;
  22953. /**
  22954. * Serializes the VertexData
  22955. * @returns a serialized object
  22956. */
  22957. serialize(): any;
  22958. /**
  22959. * Extracts the vertexData from a mesh
  22960. * @param mesh the mesh from which to extract the VertexData
  22961. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22962. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22963. * @returns the object VertexData associated to the passed mesh
  22964. */
  22965. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22966. /**
  22967. * Extracts the vertexData from the geometry
  22968. * @param geometry the geometry from which to extract the VertexData
  22969. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22970. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22971. * @returns the object VertexData associated to the passed mesh
  22972. */
  22973. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22974. private static _ExtractFrom;
  22975. /**
  22976. * Creates the VertexData for a Ribbon
  22977. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22978. * * pathArray array of paths, each of which an array of successive Vector3
  22979. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22980. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22981. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22986. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22987. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22988. * @returns the VertexData of the ribbon
  22989. */
  22990. static CreateRibbon(options: {
  22991. pathArray: Vector3[][];
  22992. closeArray?: boolean;
  22993. closePath?: boolean;
  22994. offset?: number;
  22995. sideOrientation?: number;
  22996. frontUVs?: Vector4;
  22997. backUVs?: Vector4;
  22998. invertUV?: boolean;
  22999. uvs?: Vector2[];
  23000. colors?: Color4[];
  23001. }): VertexData;
  23002. /**
  23003. * Creates the VertexData for a box
  23004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23005. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23006. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23007. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23008. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23009. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23010. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23012. * * 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)
  23013. * * 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)
  23014. * @returns the VertexData of the box
  23015. */
  23016. static CreateBox(options: {
  23017. size?: number;
  23018. width?: number;
  23019. height?: number;
  23020. depth?: number;
  23021. faceUV?: Vector4[];
  23022. faceColors?: Color4[];
  23023. sideOrientation?: number;
  23024. frontUVs?: Vector4;
  23025. backUVs?: Vector4;
  23026. }): VertexData;
  23027. /**
  23028. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23029. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23030. * * segments sets the number of horizontal strips optional, default 32
  23031. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23032. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23033. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23034. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23035. * * 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
  23036. * * 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
  23037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23038. * * 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)
  23039. * * 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)
  23040. * @returns the VertexData of the ellipsoid
  23041. */
  23042. static CreateSphere(options: {
  23043. segments?: number;
  23044. diameter?: number;
  23045. diameterX?: number;
  23046. diameterY?: number;
  23047. diameterZ?: number;
  23048. arc?: number;
  23049. slice?: number;
  23050. sideOrientation?: number;
  23051. frontUVs?: Vector4;
  23052. backUVs?: Vector4;
  23053. }): VertexData;
  23054. /**
  23055. * Creates the VertexData for a cylinder, cone or prism
  23056. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23057. * * height sets the height (y direction) of the cylinder, optional, default 2
  23058. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23059. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23060. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23061. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23062. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23063. * * 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
  23064. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23065. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23066. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23067. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23069. * * 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)
  23070. * * 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)
  23071. * @returns the VertexData of the cylinder, cone or prism
  23072. */
  23073. static CreateCylinder(options: {
  23074. height?: number;
  23075. diameterTop?: number;
  23076. diameterBottom?: number;
  23077. diameter?: number;
  23078. tessellation?: number;
  23079. subdivisions?: number;
  23080. arc?: number;
  23081. faceColors?: Color4[];
  23082. faceUV?: Vector4[];
  23083. hasRings?: boolean;
  23084. enclose?: boolean;
  23085. sideOrientation?: number;
  23086. frontUVs?: Vector4;
  23087. backUVs?: Vector4;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a torus
  23091. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23092. * * diameter the diameter of the torus, optional default 1
  23093. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23094. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23096. * * 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)
  23097. * * 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)
  23098. * @returns the VertexData of the torus
  23099. */
  23100. static CreateTorus(options: {
  23101. diameter?: number;
  23102. thickness?: number;
  23103. tessellation?: number;
  23104. sideOrientation?: number;
  23105. frontUVs?: Vector4;
  23106. backUVs?: Vector4;
  23107. }): VertexData;
  23108. /**
  23109. * Creates the VertexData of the LineSystem
  23110. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23111. * - lines an array of lines, each line being an array of successive Vector3
  23112. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23113. * @returns the VertexData of the LineSystem
  23114. */
  23115. static CreateLineSystem(options: {
  23116. lines: Vector3[][];
  23117. colors?: Nullable<Color4[][]>;
  23118. }): VertexData;
  23119. /**
  23120. * Create the VertexData for a DashedLines
  23121. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23122. * - points an array successive Vector3
  23123. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23124. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23125. * - dashNb the intended total number of dashes, optional, default 200
  23126. * @returns the VertexData for the DashedLines
  23127. */
  23128. static CreateDashedLines(options: {
  23129. points: Vector3[];
  23130. dashSize?: number;
  23131. gapSize?: number;
  23132. dashNb?: number;
  23133. }): VertexData;
  23134. /**
  23135. * Creates the VertexData for a Ground
  23136. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23137. * - width the width (x direction) of the ground, optional, default 1
  23138. * - height the height (z direction) of the ground, optional, default 1
  23139. * - subdivisions the number of subdivisions per side, optional, default 1
  23140. * @returns the VertexData of the Ground
  23141. */
  23142. static CreateGround(options: {
  23143. width?: number;
  23144. height?: number;
  23145. subdivisions?: number;
  23146. subdivisionsX?: number;
  23147. subdivisionsY?: number;
  23148. }): VertexData;
  23149. /**
  23150. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23151. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23152. * * xmin the ground minimum X coordinate, optional, default -1
  23153. * * zmin the ground minimum Z coordinate, optional, default -1
  23154. * * xmax the ground maximum X coordinate, optional, default 1
  23155. * * zmax the ground maximum Z coordinate, optional, default 1
  23156. * * 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}
  23157. * * 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}
  23158. * @returns the VertexData of the TiledGround
  23159. */
  23160. static CreateTiledGround(options: {
  23161. xmin: number;
  23162. zmin: number;
  23163. xmax: number;
  23164. zmax: number;
  23165. subdivisions?: {
  23166. w: number;
  23167. h: number;
  23168. };
  23169. precision?: {
  23170. w: number;
  23171. h: number;
  23172. };
  23173. }): VertexData;
  23174. /**
  23175. * Creates the VertexData of the Ground designed from a heightmap
  23176. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23177. * * width the width (x direction) of the ground
  23178. * * height the height (z direction) of the ground
  23179. * * subdivisions the number of subdivisions per side
  23180. * * minHeight the minimum altitude on the ground, optional, default 0
  23181. * * maxHeight the maximum altitude on the ground, optional default 1
  23182. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23183. * * buffer the array holding the image color data
  23184. * * bufferWidth the width of image
  23185. * * bufferHeight the height of image
  23186. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23187. * @returns the VertexData of the Ground designed from a heightmap
  23188. */
  23189. static CreateGroundFromHeightMap(options: {
  23190. width: number;
  23191. height: number;
  23192. subdivisions: number;
  23193. minHeight: number;
  23194. maxHeight: number;
  23195. colorFilter: Color3;
  23196. buffer: Uint8Array;
  23197. bufferWidth: number;
  23198. bufferHeight: number;
  23199. alphaFilter: number;
  23200. }): VertexData;
  23201. /**
  23202. * Creates the VertexData for a Plane
  23203. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23204. * * size sets the width and height of the plane to the value of size, optional default 1
  23205. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23206. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23208. * * 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)
  23209. * * 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)
  23210. * @returns the VertexData of the box
  23211. */
  23212. static CreatePlane(options: {
  23213. size?: number;
  23214. width?: number;
  23215. height?: number;
  23216. sideOrientation?: number;
  23217. frontUVs?: Vector4;
  23218. backUVs?: Vector4;
  23219. }): VertexData;
  23220. /**
  23221. * Creates the VertexData of the Disc or regular Polygon
  23222. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23223. * * radius the radius of the disc, optional default 0.5
  23224. * * tessellation the number of polygon sides, optional, default 64
  23225. * * 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
  23226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23227. * * 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)
  23228. * * 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)
  23229. * @returns the VertexData of the box
  23230. */
  23231. static CreateDisc(options: {
  23232. radius?: number;
  23233. tessellation?: number;
  23234. arc?: number;
  23235. sideOrientation?: number;
  23236. frontUVs?: Vector4;
  23237. backUVs?: Vector4;
  23238. }): VertexData;
  23239. /**
  23240. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23241. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23242. * @param polygon a mesh built from polygonTriangulation.build()
  23243. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23244. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23245. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23246. * @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)
  23247. * @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)
  23248. * @returns the VertexData of the Polygon
  23249. */
  23250. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23251. /**
  23252. * Creates the VertexData of the IcoSphere
  23253. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23254. * * radius the radius of the IcoSphere, optional default 1
  23255. * * radiusX allows stretching in the x direction, optional, default radius
  23256. * * radiusY allows stretching in the y direction, optional, default radius
  23257. * * radiusZ allows stretching in the z direction, optional, default radius
  23258. * * flat when true creates a flat shaded mesh, optional, default true
  23259. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23261. * * 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)
  23262. * * 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)
  23263. * @returns the VertexData of the IcoSphere
  23264. */
  23265. static CreateIcoSphere(options: {
  23266. radius?: number;
  23267. radiusX?: number;
  23268. radiusY?: number;
  23269. radiusZ?: number;
  23270. flat?: boolean;
  23271. subdivisions?: number;
  23272. sideOrientation?: number;
  23273. frontUVs?: Vector4;
  23274. backUVs?: Vector4;
  23275. }): VertexData;
  23276. /**
  23277. * Creates the VertexData for a Polyhedron
  23278. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23279. * * type provided types are:
  23280. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23281. * * 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)
  23282. * * size the size of the IcoSphere, optional default 1
  23283. * * sizeX allows stretching in the x direction, optional, default size
  23284. * * sizeY allows stretching in the y direction, optional, default size
  23285. * * sizeZ allows stretching in the z direction, optional, default size
  23286. * * 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
  23287. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23288. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23289. * * flat when true creates a flat shaded mesh, optional, default true
  23290. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23292. * * 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)
  23293. * * 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)
  23294. * @returns the VertexData of the Polyhedron
  23295. */
  23296. static CreatePolyhedron(options: {
  23297. type?: number;
  23298. size?: number;
  23299. sizeX?: number;
  23300. sizeY?: number;
  23301. sizeZ?: number;
  23302. custom?: any;
  23303. faceUV?: Vector4[];
  23304. faceColors?: Color4[];
  23305. flat?: boolean;
  23306. sideOrientation?: number;
  23307. frontUVs?: Vector4;
  23308. backUVs?: Vector4;
  23309. }): VertexData;
  23310. /**
  23311. * Creates the VertexData for a TorusKnot
  23312. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23313. * * radius the radius of the torus knot, optional, default 2
  23314. * * tube the thickness of the tube, optional, default 0.5
  23315. * * radialSegments the number of sides on each tube segments, optional, default 32
  23316. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23317. * * p the number of windings around the z axis, optional, default 2
  23318. * * q the number of windings around the x axis, optional, default 3
  23319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23320. * * 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)
  23321. * * 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)
  23322. * @returns the VertexData of the Torus Knot
  23323. */
  23324. static CreateTorusKnot(options: {
  23325. radius?: number;
  23326. tube?: number;
  23327. radialSegments?: number;
  23328. tubularSegments?: number;
  23329. p?: number;
  23330. q?: number;
  23331. sideOrientation?: number;
  23332. frontUVs?: Vector4;
  23333. backUVs?: Vector4;
  23334. }): VertexData;
  23335. /**
  23336. * Compute normals for given positions and indices
  23337. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23338. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23339. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23340. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23341. * * facetNormals : optional array of facet normals (vector3)
  23342. * * facetPositions : optional array of facet positions (vector3)
  23343. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23344. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23345. * * bInfo : optional bounding info, required for facetPartitioning computation
  23346. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23347. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23348. * * useRightHandedSystem: optional boolean to for right handed system computation
  23349. * * depthSort : optional boolean to enable the facet depth sort computation
  23350. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23351. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23352. */
  23353. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23354. facetNormals?: any;
  23355. facetPositions?: any;
  23356. facetPartitioning?: any;
  23357. ratio?: number;
  23358. bInfo?: any;
  23359. bbSize?: Vector3;
  23360. subDiv?: any;
  23361. useRightHandedSystem?: boolean;
  23362. depthSort?: boolean;
  23363. distanceTo?: Vector3;
  23364. depthSortedFacets?: any;
  23365. }): void;
  23366. /** @hidden */
  23367. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23368. /**
  23369. * Applies VertexData created from the imported parameters to the geometry
  23370. * @param parsedVertexData the parsed data from an imported file
  23371. * @param geometry the geometry to apply the VertexData to
  23372. */
  23373. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23374. }
  23375. }
  23376. declare module BABYLON {
  23377. /**
  23378. * Class containing static functions to help procedurally build meshes
  23379. */
  23380. export class DiscBuilder {
  23381. /**
  23382. * Creates a plane polygonal mesh. By default, this is a disc
  23383. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23384. * * 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
  23385. * * 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
  23386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23387. * * 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
  23388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23389. * @param name defines the name of the mesh
  23390. * @param options defines the options used to create the mesh
  23391. * @param scene defines the hosting scene
  23392. * @returns the plane polygonal mesh
  23393. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23394. */
  23395. static CreateDisc(name: string, options: {
  23396. radius?: number;
  23397. tessellation?: number;
  23398. arc?: number;
  23399. updatable?: boolean;
  23400. sideOrientation?: number;
  23401. frontUVs?: Vector4;
  23402. backUVs?: Vector4;
  23403. }, scene?: Nullable<Scene>): Mesh;
  23404. }
  23405. }
  23406. declare module BABYLON {
  23407. /**
  23408. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23409. *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.
  23410. * The SPS is also a particle system. It provides some methods to manage the particles.
  23411. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23412. *
  23413. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23414. */
  23415. export class SolidParticleSystem implements IDisposable {
  23416. /**
  23417. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23418. * Example : var p = SPS.particles[i];
  23419. */
  23420. particles: SolidParticle[];
  23421. /**
  23422. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23423. */
  23424. nbParticles: number;
  23425. /**
  23426. * If the particles must ever face the camera (default false). Useful for planar particles.
  23427. */
  23428. billboard: boolean;
  23429. /**
  23430. * Recompute normals when adding a shape
  23431. */
  23432. recomputeNormals: boolean;
  23433. /**
  23434. * This a counter ofr your own usage. It's not set by any SPS functions.
  23435. */
  23436. counter: number;
  23437. /**
  23438. * The SPS name. This name is also given to the underlying mesh.
  23439. */
  23440. name: string;
  23441. /**
  23442. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23443. */
  23444. mesh: Mesh;
  23445. /**
  23446. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23447. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23448. */
  23449. vars: any;
  23450. /**
  23451. * This array is populated when the SPS is set as 'pickable'.
  23452. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23453. * Each element of this array is an object `{idx: int, faceId: int}`.
  23454. * `idx` is the picked particle index in the `SPS.particles` array
  23455. * `faceId` is the picked face index counted within this particle.
  23456. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23457. */
  23458. pickedParticles: {
  23459. idx: number;
  23460. faceId: number;
  23461. }[];
  23462. /**
  23463. * This array is populated when `enableDepthSort` is set to true.
  23464. * Each element of this array is an instance of the class DepthSortedParticle.
  23465. */
  23466. depthSortedParticles: DepthSortedParticle[];
  23467. /**
  23468. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23469. * @hidden
  23470. */
  23471. _bSphereOnly: boolean;
  23472. /**
  23473. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23474. * @hidden
  23475. */
  23476. _bSphereRadiusFactor: number;
  23477. private _scene;
  23478. private _positions;
  23479. private _indices;
  23480. private _normals;
  23481. private _colors;
  23482. private _uvs;
  23483. private _indices32;
  23484. private _positions32;
  23485. private _normals32;
  23486. private _fixedNormal32;
  23487. private _colors32;
  23488. private _uvs32;
  23489. private _index;
  23490. private _updatable;
  23491. private _pickable;
  23492. private _isVisibilityBoxLocked;
  23493. private _alwaysVisible;
  23494. private _depthSort;
  23495. private _shapeCounter;
  23496. private _copy;
  23497. private _color;
  23498. private _computeParticleColor;
  23499. private _computeParticleTexture;
  23500. private _computeParticleRotation;
  23501. private _computeParticleVertex;
  23502. private _computeBoundingBox;
  23503. private _depthSortParticles;
  23504. private _camera;
  23505. private _mustUnrotateFixedNormals;
  23506. private _particlesIntersect;
  23507. private _needs32Bits;
  23508. /**
  23509. * Creates a SPS (Solid Particle System) object.
  23510. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23511. * @param scene (Scene) is the scene in which the SPS is added.
  23512. * @param options defines the options of the sps e.g.
  23513. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23514. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23515. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23516. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23517. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23518. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23519. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23520. */
  23521. constructor(name: string, scene: Scene, options?: {
  23522. updatable?: boolean;
  23523. isPickable?: boolean;
  23524. enableDepthSort?: boolean;
  23525. particleIntersection?: boolean;
  23526. boundingSphereOnly?: boolean;
  23527. bSphereRadiusFactor?: number;
  23528. });
  23529. /**
  23530. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23531. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23532. * @returns the created mesh
  23533. */
  23534. buildMesh(): Mesh;
  23535. /**
  23536. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23537. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23538. * Thus the particles generated from `digest()` have their property `position` set yet.
  23539. * @param mesh ( Mesh ) is the mesh to be digested
  23540. * @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
  23541. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23542. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23543. * @returns the current SPS
  23544. */
  23545. digest(mesh: Mesh, options?: {
  23546. facetNb?: number;
  23547. number?: number;
  23548. delta?: number;
  23549. }): SolidParticleSystem;
  23550. private _unrotateFixedNormals;
  23551. private _resetCopy;
  23552. private _meshBuilder;
  23553. private _posToShape;
  23554. private _uvsToShapeUV;
  23555. private _addParticle;
  23556. /**
  23557. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23558. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23559. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23560. * @param nb (positive integer) the number of particles to be created from this model
  23561. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23562. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23563. * @returns the number of shapes in the system
  23564. */
  23565. addShape(mesh: Mesh, nb: number, options?: {
  23566. positionFunction?: any;
  23567. vertexFunction?: any;
  23568. }): number;
  23569. private _rebuildParticle;
  23570. /**
  23571. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23572. * @returns the SPS.
  23573. */
  23574. rebuildMesh(): SolidParticleSystem;
  23575. /**
  23576. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23577. * This method calls `updateParticle()` for each particle of the SPS.
  23578. * For an animated SPS, it is usually called within the render loop.
  23579. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23580. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23581. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23582. * @returns the SPS.
  23583. */
  23584. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23585. /**
  23586. * Disposes the SPS.
  23587. */
  23588. dispose(): void;
  23589. /**
  23590. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23591. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23592. * @returns the SPS.
  23593. */
  23594. refreshVisibleSize(): SolidParticleSystem;
  23595. /**
  23596. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23597. * @param size the size (float) of the visibility box
  23598. * note : this doesn't lock the SPS mesh bounding box.
  23599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23600. */
  23601. setVisibilityBox(size: number): void;
  23602. /**
  23603. * Gets whether the SPS as always visible or not
  23604. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23605. */
  23606. /**
  23607. * Sets the SPS as always visible or not
  23608. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23609. */
  23610. isAlwaysVisible: boolean;
  23611. /**
  23612. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23613. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23614. */
  23615. /**
  23616. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23618. */
  23619. isVisibilityBoxLocked: boolean;
  23620. /**
  23621. * Tells to `setParticles()` to compute the particle rotations or not.
  23622. * Default value : true. The SPS is faster when it's set to false.
  23623. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23624. */
  23625. /**
  23626. * Gets if `setParticles()` computes the particle rotations or not.
  23627. * Default value : true. The SPS is faster when it's set to false.
  23628. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23629. */
  23630. computeParticleRotation: boolean;
  23631. /**
  23632. * Tells to `setParticles()` to compute the particle colors or not.
  23633. * Default value : true. The SPS is faster when it's set to false.
  23634. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23635. */
  23636. /**
  23637. * Gets if `setParticles()` computes the particle colors or not.
  23638. * Default value : true. The SPS is faster when it's set to false.
  23639. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23640. */
  23641. computeParticleColor: boolean;
  23642. /**
  23643. * Gets if `setParticles()` computes the particle textures or not.
  23644. * Default value : true. The SPS is faster when it's set to false.
  23645. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23646. */
  23647. computeParticleTexture: boolean;
  23648. /**
  23649. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23650. * Default value : false. The SPS is faster when it's set to false.
  23651. * Note : the particle custom vertex positions aren't stored values.
  23652. */
  23653. /**
  23654. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23655. * Default value : false. The SPS is faster when it's set to false.
  23656. * Note : the particle custom vertex positions aren't stored values.
  23657. */
  23658. computeParticleVertex: boolean;
  23659. /**
  23660. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23661. */
  23662. /**
  23663. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23664. */
  23665. computeBoundingBox: boolean;
  23666. /**
  23667. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23668. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23669. * Default : `true`
  23670. */
  23671. /**
  23672. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23673. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23674. * Default : `true`
  23675. */
  23676. depthSortParticles: boolean;
  23677. /**
  23678. * This function does nothing. It may be overwritten to set all the particle first values.
  23679. * The SPS doesn't call this function, you may have to call it by your own.
  23680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23681. */
  23682. initParticles(): void;
  23683. /**
  23684. * This function does nothing. It may be overwritten to recycle a particle.
  23685. * The SPS doesn't call this function, you may have to call it by your own.
  23686. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23687. * @param particle The particle to recycle
  23688. * @returns the recycled particle
  23689. */
  23690. recycleParticle(particle: SolidParticle): SolidParticle;
  23691. /**
  23692. * Updates a particle : this function should be overwritten by the user.
  23693. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23694. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23695. * @example : just set a particle position or velocity and recycle conditions
  23696. * @param particle The particle to update
  23697. * @returns the updated particle
  23698. */
  23699. updateParticle(particle: SolidParticle): SolidParticle;
  23700. /**
  23701. * Updates a vertex of a particle : it can be overwritten by the user.
  23702. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23703. * @param particle the current particle
  23704. * @param vertex the current index of the current particle
  23705. * @param pt the index of the current vertex in the particle shape
  23706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23707. * @example : just set a vertex particle position
  23708. * @returns the updated vertex
  23709. */
  23710. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23711. /**
  23712. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23713. * This does nothing and may be overwritten by the user.
  23714. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23715. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23716. * @param update the boolean update value actually passed to setParticles()
  23717. */
  23718. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23719. /**
  23720. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23721. * This will be passed three parameters.
  23722. * This does nothing and may be overwritten by the user.
  23723. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23724. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23725. * @param update the boolean update value actually passed to setParticles()
  23726. */
  23727. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23728. }
  23729. }
  23730. declare module BABYLON {
  23731. /**
  23732. * Represents one particle of a solid particle system.
  23733. */
  23734. export class SolidParticle {
  23735. /**
  23736. * particle global index
  23737. */
  23738. idx: number;
  23739. /**
  23740. * The color of the particle
  23741. */
  23742. color: Nullable<Color4>;
  23743. /**
  23744. * The world space position of the particle.
  23745. */
  23746. position: Vector3;
  23747. /**
  23748. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23749. */
  23750. rotation: Vector3;
  23751. /**
  23752. * The world space rotation quaternion of the particle.
  23753. */
  23754. rotationQuaternion: Nullable<Quaternion>;
  23755. /**
  23756. * The scaling of the particle.
  23757. */
  23758. scaling: Vector3;
  23759. /**
  23760. * The uvs of the particle.
  23761. */
  23762. uvs: Vector4;
  23763. /**
  23764. * The current speed of the particle.
  23765. */
  23766. velocity: Vector3;
  23767. /**
  23768. * The pivot point in the particle local space.
  23769. */
  23770. pivot: Vector3;
  23771. /**
  23772. * Must the particle be translated from its pivot point in its local space ?
  23773. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23774. * Default : false
  23775. */
  23776. translateFromPivot: boolean;
  23777. /**
  23778. * Is the particle active or not ?
  23779. */
  23780. alive: boolean;
  23781. /**
  23782. * Is the particle visible or not ?
  23783. */
  23784. isVisible: boolean;
  23785. /**
  23786. * Index of this particle in the global "positions" array (Internal use)
  23787. * @hidden
  23788. */
  23789. _pos: number;
  23790. /**
  23791. * @hidden Index of this particle in the global "indices" array (Internal use)
  23792. */
  23793. _ind: number;
  23794. /**
  23795. * @hidden ModelShape of this particle (Internal use)
  23796. */
  23797. _model: ModelShape;
  23798. /**
  23799. * ModelShape id of this particle
  23800. */
  23801. shapeId: number;
  23802. /**
  23803. * Index of the particle in its shape id (Internal use)
  23804. */
  23805. idxInShape: number;
  23806. /**
  23807. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23808. */
  23809. _modelBoundingInfo: BoundingInfo;
  23810. /**
  23811. * @hidden Particle BoundingInfo object (Internal use)
  23812. */
  23813. _boundingInfo: BoundingInfo;
  23814. /**
  23815. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23816. */
  23817. _sps: SolidParticleSystem;
  23818. /**
  23819. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23820. */
  23821. _stillInvisible: boolean;
  23822. /**
  23823. * @hidden Last computed particle rotation matrix
  23824. */
  23825. _rotationMatrix: number[];
  23826. /**
  23827. * Parent particle Id, if any.
  23828. * Default null.
  23829. */
  23830. parentId: Nullable<number>;
  23831. /**
  23832. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23833. * The possible values are :
  23834. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23835. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23836. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23837. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23838. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23839. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23840. * */
  23841. cullingStrategy: number;
  23842. /**
  23843. * @hidden Internal global position in the SPS.
  23844. */
  23845. _globalPosition: Vector3;
  23846. /**
  23847. * Creates a Solid Particle object.
  23848. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23849. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23850. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23851. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23852. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23853. * @param shapeId (integer) is the model shape identifier in the SPS.
  23854. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23855. * @param sps defines the sps it is associated to
  23856. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23857. */
  23858. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23859. /**
  23860. * Legacy support, changed scale to scaling
  23861. */
  23862. /**
  23863. * Legacy support, changed scale to scaling
  23864. */
  23865. scale: Vector3;
  23866. /**
  23867. * Legacy support, changed quaternion to rotationQuaternion
  23868. */
  23869. /**
  23870. * Legacy support, changed quaternion to rotationQuaternion
  23871. */
  23872. quaternion: Nullable<Quaternion>;
  23873. /**
  23874. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23875. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23876. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23877. * @returns true if it intersects
  23878. */
  23879. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23880. /**
  23881. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23882. * A particle is in the frustum if its bounding box intersects the frustum
  23883. * @param frustumPlanes defines the frustum to test
  23884. * @returns true if the particle is in the frustum planes
  23885. */
  23886. isInFrustum(frustumPlanes: Plane[]): boolean;
  23887. /**
  23888. * get the rotation matrix of the particle
  23889. * @hidden
  23890. */
  23891. getRotationMatrix(m: Matrix): void;
  23892. }
  23893. /**
  23894. * Represents the shape of the model used by one particle of a solid particle system.
  23895. * SPS internal tool, don't use it manually.
  23896. */
  23897. export class ModelShape {
  23898. /**
  23899. * The shape id
  23900. * @hidden
  23901. */
  23902. shapeID: number;
  23903. /**
  23904. * flat array of model positions (internal use)
  23905. * @hidden
  23906. */
  23907. _shape: Vector3[];
  23908. /**
  23909. * flat array of model UVs (internal use)
  23910. * @hidden
  23911. */
  23912. _shapeUV: number[];
  23913. /**
  23914. * length of the shape in the model indices array (internal use)
  23915. * @hidden
  23916. */
  23917. _indicesLength: number;
  23918. /**
  23919. * Custom position function (internal use)
  23920. * @hidden
  23921. */
  23922. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23923. /**
  23924. * Custom vertex function (internal use)
  23925. * @hidden
  23926. */
  23927. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23928. /**
  23929. * 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.
  23930. * SPS internal tool, don't use it manually.
  23931. * @hidden
  23932. */
  23933. 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>);
  23934. }
  23935. /**
  23936. * Represents a Depth Sorted Particle in the solid particle system.
  23937. */
  23938. export class DepthSortedParticle {
  23939. /**
  23940. * Index of the particle in the "indices" array
  23941. */
  23942. ind: number;
  23943. /**
  23944. * Length of the particle shape in the "indices" array
  23945. */
  23946. indicesLength: number;
  23947. /**
  23948. * Squared distance from the particle to the camera
  23949. */
  23950. sqDistance: number;
  23951. }
  23952. }
  23953. declare module BABYLON {
  23954. /**
  23955. * Class used to store all common mesh properties
  23956. */
  23957. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23958. /** No occlusion */
  23959. static OCCLUSION_TYPE_NONE: number;
  23960. /** Occlusion set to optimisitic */
  23961. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23962. /** Occlusion set to strict */
  23963. static OCCLUSION_TYPE_STRICT: number;
  23964. /** Use an accurante occlusion algorithm */
  23965. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23966. /** Use a conservative occlusion algorithm */
  23967. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23968. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23969. * Test order :
  23970. * Is the bounding sphere outside the frustum ?
  23971. * If not, are the bounding box vertices outside the frustum ?
  23972. * It not, then the cullable object is in the frustum.
  23973. */
  23974. static readonly CULLINGSTRATEGY_STANDARD: number;
  23975. /** Culling strategy : Bounding Sphere Only.
  23976. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23977. * It's also less accurate than the standard because some not visible objects can still be selected.
  23978. * Test : is the bounding sphere outside the frustum ?
  23979. * If not, then the cullable object is in the frustum.
  23980. */
  23981. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23982. /** Culling strategy : Optimistic Inclusion.
  23983. * This in an inclusion test first, then the standard exclusion test.
  23984. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23985. * 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.
  23986. * Anyway, it's as accurate as the standard strategy.
  23987. * Test :
  23988. * Is the cullable object bounding sphere center in the frustum ?
  23989. * If not, apply the default culling strategy.
  23990. */
  23991. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23992. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23993. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23994. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23995. * 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.
  23996. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23997. * Test :
  23998. * Is the cullable object bounding sphere center in the frustum ?
  23999. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24000. */
  24001. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24002. /**
  24003. * No billboard
  24004. */
  24005. static readonly BILLBOARDMODE_NONE: number;
  24006. /** Billboard on X axis */
  24007. static readonly BILLBOARDMODE_X: number;
  24008. /** Billboard on Y axis */
  24009. static readonly BILLBOARDMODE_Y: number;
  24010. /** Billboard on Z axis */
  24011. static readonly BILLBOARDMODE_Z: number;
  24012. /** Billboard on all axes */
  24013. static readonly BILLBOARDMODE_ALL: number;
  24014. private _facetData;
  24015. /**
  24016. * The culling strategy to use to check whether the mesh must be rendered or not.
  24017. * This value can be changed at any time and will be used on the next render mesh selection.
  24018. * The possible values are :
  24019. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24020. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24021. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24022. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24023. * Please read each static variable documentation to get details about the culling process.
  24024. * */
  24025. cullingStrategy: number;
  24026. /**
  24027. * Gets the number of facets in the mesh
  24028. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24029. */
  24030. readonly facetNb: number;
  24031. /**
  24032. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24033. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24034. */
  24035. partitioningSubdivisions: number;
  24036. /**
  24037. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24038. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24040. */
  24041. partitioningBBoxRatio: number;
  24042. /**
  24043. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24044. * Works only for updatable meshes.
  24045. * Doesn't work with multi-materials
  24046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24047. */
  24048. mustDepthSortFacets: boolean;
  24049. /**
  24050. * The location (Vector3) where the facet depth sort must be computed from.
  24051. * By default, the active camera position.
  24052. * Used only when facet depth sort is enabled
  24053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24054. */
  24055. facetDepthSortFrom: Vector3;
  24056. /**
  24057. * gets a boolean indicating if facetData is enabled
  24058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24059. */
  24060. readonly isFacetDataEnabled: boolean;
  24061. /** @hidden */
  24062. _updateNonUniformScalingState(value: boolean): boolean;
  24063. /**
  24064. * An event triggered when this mesh collides with another one
  24065. */
  24066. onCollideObservable: Observable<AbstractMesh>;
  24067. private _onCollideObserver;
  24068. /** Set a function to call when this mesh collides with another one */
  24069. onCollide: () => void;
  24070. /**
  24071. * An event triggered when the collision's position changes
  24072. */
  24073. onCollisionPositionChangeObservable: Observable<Vector3>;
  24074. private _onCollisionPositionChangeObserver;
  24075. /** Set a function to call when the collision's position changes */
  24076. onCollisionPositionChange: () => void;
  24077. /**
  24078. * An event triggered when material is changed
  24079. */
  24080. onMaterialChangedObservable: Observable<AbstractMesh>;
  24081. /**
  24082. * Gets or sets the orientation for POV movement & rotation
  24083. */
  24084. definedFacingForward: boolean;
  24085. /** @hidden */
  24086. _occlusionQuery: Nullable<WebGLQuery>;
  24087. private _visibility;
  24088. /** @hidden */
  24089. _isActive: boolean;
  24090. /** @hidden */
  24091. _renderingGroup: Nullable<RenderingGroup>;
  24092. /**
  24093. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24094. */
  24095. /**
  24096. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24097. */
  24098. visibility: number;
  24099. /** Gets or sets the alpha index used to sort transparent meshes
  24100. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24101. */
  24102. alphaIndex: number;
  24103. /**
  24104. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24105. */
  24106. isVisible: boolean;
  24107. /**
  24108. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24109. */
  24110. isPickable: boolean;
  24111. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24112. showSubMeshesBoundingBox: boolean;
  24113. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24115. */
  24116. isBlocker: boolean;
  24117. /**
  24118. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24119. */
  24120. enablePointerMoveEvents: boolean;
  24121. /**
  24122. * Specifies the rendering group id for this mesh (0 by default)
  24123. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24124. */
  24125. renderingGroupId: number;
  24126. private _material;
  24127. /** Gets or sets current material */
  24128. material: Nullable<Material>;
  24129. private _receiveShadows;
  24130. /**
  24131. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24132. * @see http://doc.babylonjs.com/babylon101/shadows
  24133. */
  24134. receiveShadows: boolean;
  24135. /** Defines color to use when rendering outline */
  24136. outlineColor: Color3;
  24137. /** Define width to use when rendering outline */
  24138. outlineWidth: number;
  24139. /** Defines color to use when rendering overlay */
  24140. overlayColor: Color3;
  24141. /** Defines alpha to use when rendering overlay */
  24142. overlayAlpha: number;
  24143. private _hasVertexAlpha;
  24144. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24145. hasVertexAlpha: boolean;
  24146. private _useVertexColors;
  24147. /** 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) */
  24148. useVertexColors: boolean;
  24149. private _computeBonesUsingShaders;
  24150. /**
  24151. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24152. */
  24153. computeBonesUsingShaders: boolean;
  24154. private _numBoneInfluencers;
  24155. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24156. numBoneInfluencers: number;
  24157. private _applyFog;
  24158. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24159. applyFog: boolean;
  24160. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24161. useOctreeForRenderingSelection: boolean;
  24162. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24163. useOctreeForPicking: boolean;
  24164. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24165. useOctreeForCollisions: boolean;
  24166. private _layerMask;
  24167. /**
  24168. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24169. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24170. */
  24171. layerMask: number;
  24172. /**
  24173. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24174. */
  24175. alwaysSelectAsActiveMesh: boolean;
  24176. /**
  24177. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24178. */
  24179. doNotSyncBoundingInfo: boolean;
  24180. /**
  24181. * Gets or sets the current action manager
  24182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24183. */
  24184. actionManager: Nullable<AbstractActionManager>;
  24185. private _checkCollisions;
  24186. private _collisionMask;
  24187. private _collisionGroup;
  24188. /**
  24189. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24191. */
  24192. ellipsoid: Vector3;
  24193. /**
  24194. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24195. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24196. */
  24197. ellipsoidOffset: Vector3;
  24198. private _collider;
  24199. private _oldPositionForCollisions;
  24200. private _diffPositionForCollisions;
  24201. /**
  24202. * Gets or sets a collision mask used to mask collisions (default is -1).
  24203. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24204. */
  24205. collisionMask: number;
  24206. /**
  24207. * Gets or sets the current collision group mask (-1 by default).
  24208. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24209. */
  24210. collisionGroup: number;
  24211. /**
  24212. * Defines edge width used when edgesRenderer is enabled
  24213. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24214. */
  24215. edgesWidth: number;
  24216. /**
  24217. * Defines edge color used when edgesRenderer is enabled
  24218. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24219. */
  24220. edgesColor: Color4;
  24221. /** @hidden */
  24222. _edgesRenderer: Nullable<IEdgesRenderer>;
  24223. /** @hidden */
  24224. _masterMesh: Nullable<AbstractMesh>;
  24225. /** @hidden */
  24226. _boundingInfo: Nullable<BoundingInfo>;
  24227. /** @hidden */
  24228. _renderId: number;
  24229. /**
  24230. * Gets or sets the list of subMeshes
  24231. * @see http://doc.babylonjs.com/how_to/multi_materials
  24232. */
  24233. subMeshes: SubMesh[];
  24234. /** @hidden */
  24235. _intersectionsInProgress: AbstractMesh[];
  24236. /** @hidden */
  24237. _unIndexed: boolean;
  24238. /** @hidden */
  24239. _lightSources: Light[];
  24240. /** @hidden */
  24241. readonly _positions: Nullable<Vector3[]>;
  24242. /** @hidden */
  24243. _waitingActions: Nullable<any>;
  24244. /** @hidden */
  24245. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24246. private _skeleton;
  24247. /** @hidden */
  24248. _bonesTransformMatrices: Nullable<Float32Array>;
  24249. /**
  24250. * Gets or sets a skeleton to apply skining transformations
  24251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24252. */
  24253. skeleton: Nullable<Skeleton>;
  24254. /**
  24255. * An event triggered when the mesh is rebuilt.
  24256. */
  24257. onRebuildObservable: Observable<AbstractMesh>;
  24258. /**
  24259. * Creates a new AbstractMesh
  24260. * @param name defines the name of the mesh
  24261. * @param scene defines the hosting scene
  24262. */
  24263. constructor(name: string, scene?: Nullable<Scene>);
  24264. /**
  24265. * Returns the string "AbstractMesh"
  24266. * @returns "AbstractMesh"
  24267. */
  24268. getClassName(): string;
  24269. /**
  24270. * Gets a string representation of the current mesh
  24271. * @param fullDetails defines a boolean indicating if full details must be included
  24272. * @returns a string representation of the current mesh
  24273. */
  24274. toString(fullDetails?: boolean): string;
  24275. /**
  24276. * @hidden
  24277. */
  24278. protected _getEffectiveParent(): Nullable<Node>;
  24279. /** @hidden */
  24280. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24281. /** @hidden */
  24282. _rebuild(): void;
  24283. /** @hidden */
  24284. _resyncLightSources(): void;
  24285. /** @hidden */
  24286. _resyncLighSource(light: Light): void;
  24287. /** @hidden */
  24288. _unBindEffect(): void;
  24289. /** @hidden */
  24290. _removeLightSource(light: Light): void;
  24291. private _markSubMeshesAsDirty;
  24292. /** @hidden */
  24293. _markSubMeshesAsLightDirty(): void;
  24294. /** @hidden */
  24295. _markSubMeshesAsAttributesDirty(): void;
  24296. /** @hidden */
  24297. _markSubMeshesAsMiscDirty(): void;
  24298. /**
  24299. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24300. */
  24301. scaling: Vector3;
  24302. /**
  24303. * Returns true if the mesh is blocked. Implemented by child classes
  24304. */
  24305. readonly isBlocked: boolean;
  24306. /**
  24307. * Returns the mesh itself by default. Implemented by child classes
  24308. * @param camera defines the camera to use to pick the right LOD level
  24309. * @returns the currentAbstractMesh
  24310. */
  24311. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24312. /**
  24313. * Returns 0 by default. Implemented by child classes
  24314. * @returns an integer
  24315. */
  24316. getTotalVertices(): number;
  24317. /**
  24318. * Returns a positive integer : the total number of indices in this mesh geometry.
  24319. * @returns the numner of indices or zero if the mesh has no geometry.
  24320. */
  24321. getTotalIndices(): number;
  24322. /**
  24323. * Returns null by default. Implemented by child classes
  24324. * @returns null
  24325. */
  24326. getIndices(): Nullable<IndicesArray>;
  24327. /**
  24328. * Returns the array of the requested vertex data kind. Implemented by child classes
  24329. * @param kind defines the vertex data kind to use
  24330. * @returns null
  24331. */
  24332. getVerticesData(kind: string): Nullable<FloatArray>;
  24333. /**
  24334. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24335. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24336. * Note that a new underlying VertexBuffer object is created each call.
  24337. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24338. * @param kind defines vertex data kind:
  24339. * * VertexBuffer.PositionKind
  24340. * * VertexBuffer.UVKind
  24341. * * VertexBuffer.UV2Kind
  24342. * * VertexBuffer.UV3Kind
  24343. * * VertexBuffer.UV4Kind
  24344. * * VertexBuffer.UV5Kind
  24345. * * VertexBuffer.UV6Kind
  24346. * * VertexBuffer.ColorKind
  24347. * * VertexBuffer.MatricesIndicesKind
  24348. * * VertexBuffer.MatricesIndicesExtraKind
  24349. * * VertexBuffer.MatricesWeightsKind
  24350. * * VertexBuffer.MatricesWeightsExtraKind
  24351. * @param data defines the data source
  24352. * @param updatable defines if the data must be flagged as updatable (or static)
  24353. * @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
  24354. * @returns the current mesh
  24355. */
  24356. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24357. /**
  24358. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24359. * If the mesh has no geometry, it is simply returned as it is.
  24360. * @param kind defines vertex data kind:
  24361. * * VertexBuffer.PositionKind
  24362. * * VertexBuffer.UVKind
  24363. * * VertexBuffer.UV2Kind
  24364. * * VertexBuffer.UV3Kind
  24365. * * VertexBuffer.UV4Kind
  24366. * * VertexBuffer.UV5Kind
  24367. * * VertexBuffer.UV6Kind
  24368. * * VertexBuffer.ColorKind
  24369. * * VertexBuffer.MatricesIndicesKind
  24370. * * VertexBuffer.MatricesIndicesExtraKind
  24371. * * VertexBuffer.MatricesWeightsKind
  24372. * * VertexBuffer.MatricesWeightsExtraKind
  24373. * @param data defines the data source
  24374. * @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
  24375. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24376. * @returns the current mesh
  24377. */
  24378. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24379. /**
  24380. * Sets the mesh indices,
  24381. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24382. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24383. * @param totalVertices Defines the total number of vertices
  24384. * @returns the current mesh
  24385. */
  24386. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24387. /**
  24388. * Gets a boolean indicating if specific vertex data is present
  24389. * @param kind defines the vertex data kind to use
  24390. * @returns true is data kind is present
  24391. */
  24392. isVerticesDataPresent(kind: string): boolean;
  24393. /**
  24394. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24395. * @returns a BoundingInfo
  24396. */
  24397. getBoundingInfo(): BoundingInfo;
  24398. /**
  24399. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24400. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24401. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24402. * @returns the current mesh
  24403. */
  24404. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24405. /**
  24406. * Overwrite the current bounding info
  24407. * @param boundingInfo defines the new bounding info
  24408. * @returns the current mesh
  24409. */
  24410. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24411. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24412. readonly useBones: boolean;
  24413. /** @hidden */
  24414. _preActivate(): void;
  24415. /** @hidden */
  24416. _preActivateForIntermediateRendering(renderId: number): void;
  24417. /** @hidden */
  24418. _activate(renderId: number): boolean;
  24419. /** @hidden */
  24420. _freeze(): void;
  24421. /** @hidden */
  24422. _unFreeze(): void;
  24423. /**
  24424. * Gets the current world matrix
  24425. * @returns a Matrix
  24426. */
  24427. getWorldMatrix(): Matrix;
  24428. /** @hidden */
  24429. _getWorldMatrixDeterminant(): number;
  24430. /**
  24431. * Perform relative position change from the point of view of behind the front of the mesh.
  24432. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24433. * Supports definition of mesh facing forward or backward
  24434. * @param amountRight defines the distance on the right axis
  24435. * @param amountUp defines the distance on the up axis
  24436. * @param amountForward defines the distance on the forward axis
  24437. * @returns the current mesh
  24438. */
  24439. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24440. /**
  24441. * Calculate relative position change from the point of view of behind the front of the mesh.
  24442. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24443. * Supports definition of mesh facing forward or backward
  24444. * @param amountRight defines the distance on the right axis
  24445. * @param amountUp defines the distance on the up axis
  24446. * @param amountForward defines the distance on the forward axis
  24447. * @returns the new displacement vector
  24448. */
  24449. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24450. /**
  24451. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24452. * Supports definition of mesh facing forward or backward
  24453. * @param flipBack defines the flip
  24454. * @param twirlClockwise defines the twirl
  24455. * @param tiltRight defines the tilt
  24456. * @returns the current mesh
  24457. */
  24458. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24459. /**
  24460. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24461. * Supports definition of mesh facing forward or backward.
  24462. * @param flipBack defines the flip
  24463. * @param twirlClockwise defines the twirl
  24464. * @param tiltRight defines the tilt
  24465. * @returns the new rotation vector
  24466. */
  24467. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24468. /**
  24469. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24470. * This means the mesh underlying bounding box and sphere are recomputed.
  24471. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24472. * @returns the current mesh
  24473. */
  24474. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24475. /** @hidden */
  24476. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24477. /** @hidden */
  24478. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24479. /** @hidden */
  24480. _updateBoundingInfo(): AbstractMesh;
  24481. /** @hidden */
  24482. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24483. /** @hidden */
  24484. protected _afterComputeWorldMatrix(): void;
  24485. /** @hidden */
  24486. readonly _effectiveMesh: AbstractMesh;
  24487. /**
  24488. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24489. * A mesh is in the frustum if its bounding box intersects the frustum
  24490. * @param frustumPlanes defines the frustum to test
  24491. * @returns true if the mesh is in the frustum planes
  24492. */
  24493. isInFrustum(frustumPlanes: Plane[]): boolean;
  24494. /**
  24495. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24496. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24497. * @param frustumPlanes defines the frustum to test
  24498. * @returns true if the mesh is completely in the frustum planes
  24499. */
  24500. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24501. /**
  24502. * True if the mesh intersects another mesh or a SolidParticle object
  24503. * @param mesh defines a target mesh or SolidParticle to test
  24504. * @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)
  24505. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24506. * @returns true if there is an intersection
  24507. */
  24508. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24509. /**
  24510. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24511. * @param point defines the point to test
  24512. * @returns true if there is an intersection
  24513. */
  24514. intersectsPoint(point: Vector3): boolean;
  24515. /**
  24516. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24518. */
  24519. checkCollisions: boolean;
  24520. /**
  24521. * Gets Collider object used to compute collisions (not physics)
  24522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24523. */
  24524. readonly collider: Nullable<Collider>;
  24525. /**
  24526. * Move the mesh using collision engine
  24527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24528. * @param displacement defines the requested displacement vector
  24529. * @returns the current mesh
  24530. */
  24531. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24532. private _onCollisionPositionChange;
  24533. /** @hidden */
  24534. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24535. /** @hidden */
  24536. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24537. /** @hidden */
  24538. _checkCollision(collider: Collider): AbstractMesh;
  24539. /** @hidden */
  24540. _generatePointsArray(): boolean;
  24541. /**
  24542. * Checks if the passed Ray intersects with the mesh
  24543. * @param ray defines the ray to use
  24544. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24545. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24546. * @returns the picking info
  24547. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24548. */
  24549. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24550. /**
  24551. * Clones the current mesh
  24552. * @param name defines the mesh name
  24553. * @param newParent defines the new mesh parent
  24554. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24555. * @returns the new mesh
  24556. */
  24557. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24558. /**
  24559. * Disposes all the submeshes of the current meshnp
  24560. * @returns the current mesh
  24561. */
  24562. releaseSubMeshes(): AbstractMesh;
  24563. /**
  24564. * Releases resources associated with this abstract mesh.
  24565. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24566. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24567. */
  24568. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24569. /**
  24570. * Adds the passed mesh as a child to the current mesh
  24571. * @param mesh defines the child mesh
  24572. * @returns the current mesh
  24573. */
  24574. addChild(mesh: AbstractMesh): AbstractMesh;
  24575. /**
  24576. * Removes the passed mesh from the current mesh children list
  24577. * @param mesh defines the child mesh
  24578. * @returns the current mesh
  24579. */
  24580. removeChild(mesh: AbstractMesh): AbstractMesh;
  24581. /** @hidden */
  24582. private _initFacetData;
  24583. /**
  24584. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24585. * This method can be called within the render loop.
  24586. * 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
  24587. * @returns the current mesh
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24589. */
  24590. updateFacetData(): AbstractMesh;
  24591. /**
  24592. * Returns the facetLocalNormals array.
  24593. * The normals are expressed in the mesh local spac
  24594. * @returns an array of Vector3
  24595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24596. */
  24597. getFacetLocalNormals(): Vector3[];
  24598. /**
  24599. * Returns the facetLocalPositions array.
  24600. * The facet positions are expressed in the mesh local space
  24601. * @returns an array of Vector3
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24603. */
  24604. getFacetLocalPositions(): Vector3[];
  24605. /**
  24606. * Returns the facetLocalPartioning array
  24607. * @returns an array of array of numbers
  24608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24609. */
  24610. getFacetLocalPartitioning(): number[][];
  24611. /**
  24612. * Returns the i-th facet position in the world system.
  24613. * This method allocates a new Vector3 per call
  24614. * @param i defines the facet index
  24615. * @returns a new Vector3
  24616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24617. */
  24618. getFacetPosition(i: number): Vector3;
  24619. /**
  24620. * Sets the reference Vector3 with the i-th facet position in the world system
  24621. * @param i defines the facet index
  24622. * @param ref defines the target vector
  24623. * @returns the current mesh
  24624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24625. */
  24626. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24627. /**
  24628. * Returns the i-th facet normal in the world system.
  24629. * This method allocates a new Vector3 per call
  24630. * @param i defines the facet index
  24631. * @returns a new Vector3
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24633. */
  24634. getFacetNormal(i: number): Vector3;
  24635. /**
  24636. * Sets the reference Vector3 with the i-th facet normal in the world system
  24637. * @param i defines the facet index
  24638. * @param ref defines the target vector
  24639. * @returns the current mesh
  24640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24641. */
  24642. getFacetNormalToRef(i: number, ref: Vector3): this;
  24643. /**
  24644. * 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)
  24645. * @param x defines x coordinate
  24646. * @param y defines y coordinate
  24647. * @param z defines z coordinate
  24648. * @returns the array of facet indexes
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24650. */
  24651. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24652. /**
  24653. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24654. * @param projected sets as the (x,y,z) world projection on the facet
  24655. * @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
  24656. * @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
  24657. * @param x defines x coordinate
  24658. * @param y defines y coordinate
  24659. * @param z defines z coordinate
  24660. * @returns the face index if found (or null instead)
  24661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24662. */
  24663. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24664. /**
  24665. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24666. * @param projected sets as the (x,y,z) local projection on the facet
  24667. * @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
  24668. * @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
  24669. * @param x defines x coordinate
  24670. * @param y defines y coordinate
  24671. * @param z defines z coordinate
  24672. * @returns the face index if found (or null instead)
  24673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24674. */
  24675. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24676. /**
  24677. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24678. * @returns the parameters
  24679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24680. */
  24681. getFacetDataParameters(): any;
  24682. /**
  24683. * Disables the feature FacetData and frees the related memory
  24684. * @returns the current mesh
  24685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24686. */
  24687. disableFacetData(): AbstractMesh;
  24688. /**
  24689. * Updates the AbstractMesh indices array
  24690. * @param indices defines the data source
  24691. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24692. * @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)
  24693. * @returns the current mesh
  24694. */
  24695. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24696. /**
  24697. * Creates new normals data for the mesh
  24698. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24699. * @returns the current mesh
  24700. */
  24701. createNormals(updatable: boolean): AbstractMesh;
  24702. /**
  24703. * Align the mesh with a normal
  24704. * @param normal defines the normal to use
  24705. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24706. * @returns the current mesh
  24707. */
  24708. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24709. /** @hidden */
  24710. _checkOcclusionQuery(): boolean;
  24711. }
  24712. }
  24713. declare module BABYLON {
  24714. /**
  24715. * Interface used to define ActionEvent
  24716. */
  24717. export interface IActionEvent {
  24718. /** The mesh or sprite that triggered the action */
  24719. source: any;
  24720. /** The X mouse cursor position at the time of the event */
  24721. pointerX: number;
  24722. /** The Y mouse cursor position at the time of the event */
  24723. pointerY: number;
  24724. /** The mesh that is currently pointed at (can be null) */
  24725. meshUnderPointer: Nullable<AbstractMesh>;
  24726. /** the original (browser) event that triggered the ActionEvent */
  24727. sourceEvent?: any;
  24728. /** additional data for the event */
  24729. additionalData?: any;
  24730. }
  24731. /**
  24732. * ActionEvent is the event being sent when an action is triggered.
  24733. */
  24734. export class ActionEvent implements IActionEvent {
  24735. /** The mesh or sprite that triggered the action */
  24736. source: any;
  24737. /** The X mouse cursor position at the time of the event */
  24738. pointerX: number;
  24739. /** The Y mouse cursor position at the time of the event */
  24740. pointerY: number;
  24741. /** The mesh that is currently pointed at (can be null) */
  24742. meshUnderPointer: Nullable<AbstractMesh>;
  24743. /** the original (browser) event that triggered the ActionEvent */
  24744. sourceEvent?: any;
  24745. /** additional data for the event */
  24746. additionalData?: any;
  24747. /**
  24748. * Creates a new ActionEvent
  24749. * @param source The mesh or sprite that triggered the action
  24750. * @param pointerX The X mouse cursor position at the time of the event
  24751. * @param pointerY The Y mouse cursor position at the time of the event
  24752. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24753. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24754. * @param additionalData additional data for the event
  24755. */
  24756. constructor(
  24757. /** The mesh or sprite that triggered the action */
  24758. source: any,
  24759. /** The X mouse cursor position at the time of the event */
  24760. pointerX: number,
  24761. /** The Y mouse cursor position at the time of the event */
  24762. pointerY: number,
  24763. /** The mesh that is currently pointed at (can be null) */
  24764. meshUnderPointer: Nullable<AbstractMesh>,
  24765. /** the original (browser) event that triggered the ActionEvent */
  24766. sourceEvent?: any,
  24767. /** additional data for the event */
  24768. additionalData?: any);
  24769. /**
  24770. * Helper function to auto-create an ActionEvent from a source mesh.
  24771. * @param source The source mesh that triggered the event
  24772. * @param evt The original (browser) event
  24773. * @param additionalData additional data for the event
  24774. * @returns the new ActionEvent
  24775. */
  24776. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24777. /**
  24778. * Helper function to auto-create an ActionEvent from a source sprite
  24779. * @param source The source sprite that triggered the event
  24780. * @param scene Scene associated with the sprite
  24781. * @param evt The original (browser) event
  24782. * @param additionalData additional data for the event
  24783. * @returns the new ActionEvent
  24784. */
  24785. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24786. /**
  24787. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24788. * @param scene the scene where the event occurred
  24789. * @param evt The original (browser) event
  24790. * @returns the new ActionEvent
  24791. */
  24792. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24793. /**
  24794. * Helper function to auto-create an ActionEvent from a primitive
  24795. * @param prim defines the target primitive
  24796. * @param pointerPos defines the pointer position
  24797. * @param evt The original (browser) event
  24798. * @param additionalData additional data for the event
  24799. * @returns the new ActionEvent
  24800. */
  24801. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24802. }
  24803. }
  24804. declare module BABYLON {
  24805. /**
  24806. * Abstract class used to decouple action Manager from scene and meshes.
  24807. * Do not instantiate.
  24808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24809. */
  24810. export abstract class AbstractActionManager implements IDisposable {
  24811. /** Gets the list of active triggers */
  24812. static Triggers: {
  24813. [key: string]: number;
  24814. };
  24815. /** Gets the cursor to use when hovering items */
  24816. hoverCursor: string;
  24817. /** Gets the list of actions */
  24818. actions: IAction[];
  24819. /**
  24820. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24821. */
  24822. isRecursive: boolean;
  24823. /**
  24824. * Releases all associated resources
  24825. */
  24826. abstract dispose(): void;
  24827. /**
  24828. * Does this action manager has pointer triggers
  24829. */
  24830. abstract readonly hasPointerTriggers: boolean;
  24831. /**
  24832. * Does this action manager has pick triggers
  24833. */
  24834. abstract readonly hasPickTriggers: boolean;
  24835. /**
  24836. * Process a specific trigger
  24837. * @param trigger defines the trigger to process
  24838. * @param evt defines the event details to be processed
  24839. */
  24840. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24841. /**
  24842. * Does this action manager handles actions of any of the given triggers
  24843. * @param triggers defines the triggers to be tested
  24844. * @return a boolean indicating whether one (or more) of the triggers is handled
  24845. */
  24846. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24847. /**
  24848. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24849. * speed.
  24850. * @param triggerA defines the trigger to be tested
  24851. * @param triggerB defines the trigger to be tested
  24852. * @return a boolean indicating whether one (or more) of the triggers is handled
  24853. */
  24854. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24855. /**
  24856. * Does this action manager handles actions of a given trigger
  24857. * @param trigger defines the trigger to be tested
  24858. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24859. * @return whether the trigger is handled
  24860. */
  24861. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24862. /**
  24863. * Serialize this manager to a JSON object
  24864. * @param name defines the property name to store this manager
  24865. * @returns a JSON representation of this manager
  24866. */
  24867. abstract serialize(name: string): any;
  24868. /**
  24869. * Registers an action to this action manager
  24870. * @param action defines the action to be registered
  24871. * @return the action amended (prepared) after registration
  24872. */
  24873. abstract registerAction(action: IAction): Nullable<IAction>;
  24874. /**
  24875. * Unregisters an action to this action manager
  24876. * @param action defines the action to be unregistered
  24877. * @return a boolean indicating whether the action has been unregistered
  24878. */
  24879. abstract unregisterAction(action: IAction): Boolean;
  24880. /**
  24881. * Does exist one action manager with at least one trigger
  24882. **/
  24883. static readonly HasTriggers: boolean;
  24884. /**
  24885. * Does exist one action manager with at least one pick trigger
  24886. **/
  24887. static readonly HasPickTriggers: boolean;
  24888. /**
  24889. * Does exist one action manager that handles actions of a given trigger
  24890. * @param trigger defines the trigger to be tested
  24891. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24892. **/
  24893. static HasSpecificTrigger(trigger: number): boolean;
  24894. }
  24895. }
  24896. declare module BABYLON {
  24897. /**
  24898. * Defines how a node can be built from a string name.
  24899. */
  24900. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24901. /**
  24902. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24903. */
  24904. export class Node implements IBehaviorAware<Node> {
  24905. /** @hidden */
  24906. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24907. private static _NodeConstructors;
  24908. /**
  24909. * Add a new node constructor
  24910. * @param type defines the type name of the node to construct
  24911. * @param constructorFunc defines the constructor function
  24912. */
  24913. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24914. /**
  24915. * Returns a node constructor based on type name
  24916. * @param type defines the type name
  24917. * @param name defines the new node name
  24918. * @param scene defines the hosting scene
  24919. * @param options defines optional options to transmit to constructors
  24920. * @returns the new constructor or null
  24921. */
  24922. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24923. /**
  24924. * Gets or sets the name of the node
  24925. */
  24926. name: string;
  24927. /**
  24928. * Gets or sets the id of the node
  24929. */
  24930. id: string;
  24931. /**
  24932. * Gets or sets the unique id of the node
  24933. */
  24934. uniqueId: number;
  24935. /**
  24936. * Gets or sets a string used to store user defined state for the node
  24937. */
  24938. state: string;
  24939. /**
  24940. * Gets or sets an object used to store user defined information for the node
  24941. */
  24942. metadata: any;
  24943. /**
  24944. * For internal use only. Please do not use.
  24945. */
  24946. reservedDataStore: any;
  24947. /**
  24948. * List of inspectable custom properties (used by the Inspector)
  24949. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24950. */
  24951. inspectableCustomProperties: IInspectable[];
  24952. /**
  24953. * Gets or sets a boolean used to define if the node must be serialized
  24954. */
  24955. doNotSerialize: boolean;
  24956. /** @hidden */
  24957. _isDisposed: boolean;
  24958. /**
  24959. * Gets a list of Animations associated with the node
  24960. */
  24961. animations: Animation[];
  24962. protected _ranges: {
  24963. [name: string]: Nullable<AnimationRange>;
  24964. };
  24965. /**
  24966. * Callback raised when the node is ready to be used
  24967. */
  24968. onReady: Nullable<(node: Node) => void>;
  24969. private _isEnabled;
  24970. private _isParentEnabled;
  24971. private _isReady;
  24972. /** @hidden */
  24973. _currentRenderId: number;
  24974. private _parentUpdateId;
  24975. /** @hidden */
  24976. _childUpdateId: number;
  24977. /** @hidden */
  24978. _waitingParentId: Nullable<string>;
  24979. /** @hidden */
  24980. _scene: Scene;
  24981. /** @hidden */
  24982. _cache: any;
  24983. private _parentNode;
  24984. private _children;
  24985. /** @hidden */
  24986. _worldMatrix: Matrix;
  24987. /** @hidden */
  24988. _worldMatrixDeterminant: number;
  24989. /** @hidden */
  24990. _worldMatrixDeterminantIsDirty: boolean;
  24991. /** @hidden */
  24992. private _sceneRootNodesIndex;
  24993. /**
  24994. * Gets a boolean indicating if the node has been disposed
  24995. * @returns true if the node was disposed
  24996. */
  24997. isDisposed(): boolean;
  24998. /**
  24999. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25000. * @see https://doc.babylonjs.com/how_to/parenting
  25001. */
  25002. parent: Nullable<Node>;
  25003. private addToSceneRootNodes;
  25004. private removeFromSceneRootNodes;
  25005. private _animationPropertiesOverride;
  25006. /**
  25007. * Gets or sets the animation properties override
  25008. */
  25009. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25010. /**
  25011. * Gets a string idenfifying the name of the class
  25012. * @returns "Node" string
  25013. */
  25014. getClassName(): string;
  25015. /** @hidden */
  25016. readonly _isNode: boolean;
  25017. /**
  25018. * An event triggered when the mesh is disposed
  25019. */
  25020. onDisposeObservable: Observable<Node>;
  25021. private _onDisposeObserver;
  25022. /**
  25023. * Sets a callback that will be raised when the node will be disposed
  25024. */
  25025. onDispose: () => void;
  25026. /**
  25027. * Creates a new Node
  25028. * @param name the name and id to be given to this node
  25029. * @param scene the scene this node will be added to
  25030. * @param addToRootNodes the node will be added to scene.rootNodes
  25031. */
  25032. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25033. /**
  25034. * Gets the scene of the node
  25035. * @returns a scene
  25036. */
  25037. getScene(): Scene;
  25038. /**
  25039. * Gets the engine of the node
  25040. * @returns a Engine
  25041. */
  25042. getEngine(): Engine;
  25043. private _behaviors;
  25044. /**
  25045. * Attach a behavior to the node
  25046. * @see http://doc.babylonjs.com/features/behaviour
  25047. * @param behavior defines the behavior to attach
  25048. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25049. * @returns the current Node
  25050. */
  25051. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25052. /**
  25053. * Remove an attached behavior
  25054. * @see http://doc.babylonjs.com/features/behaviour
  25055. * @param behavior defines the behavior to attach
  25056. * @returns the current Node
  25057. */
  25058. removeBehavior(behavior: Behavior<Node>): Node;
  25059. /**
  25060. * Gets the list of attached behaviors
  25061. * @see http://doc.babylonjs.com/features/behaviour
  25062. */
  25063. readonly behaviors: Behavior<Node>[];
  25064. /**
  25065. * Gets an attached behavior by name
  25066. * @param name defines the name of the behavior to look for
  25067. * @see http://doc.babylonjs.com/features/behaviour
  25068. * @returns null if behavior was not found else the requested behavior
  25069. */
  25070. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25071. /**
  25072. * Returns the latest update of the World matrix
  25073. * @returns a Matrix
  25074. */
  25075. getWorldMatrix(): Matrix;
  25076. /** @hidden */
  25077. _getWorldMatrixDeterminant(): number;
  25078. /**
  25079. * Returns directly the latest state of the mesh World matrix.
  25080. * A Matrix is returned.
  25081. */
  25082. readonly worldMatrixFromCache: Matrix;
  25083. /** @hidden */
  25084. _initCache(): void;
  25085. /** @hidden */
  25086. updateCache(force?: boolean): void;
  25087. /** @hidden */
  25088. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25089. /** @hidden */
  25090. _updateCache(ignoreParentClass?: boolean): void;
  25091. /** @hidden */
  25092. _isSynchronized(): boolean;
  25093. /** @hidden */
  25094. _markSyncedWithParent(): void;
  25095. /** @hidden */
  25096. isSynchronizedWithParent(): boolean;
  25097. /** @hidden */
  25098. isSynchronized(): boolean;
  25099. /**
  25100. * Is this node ready to be used/rendered
  25101. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25102. * @return true if the node is ready
  25103. */
  25104. isReady(completeCheck?: boolean): boolean;
  25105. /**
  25106. * Is this node enabled?
  25107. * 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
  25108. * @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
  25109. * @return whether this node (and its parent) is enabled
  25110. */
  25111. isEnabled(checkAncestors?: boolean): boolean;
  25112. /** @hidden */
  25113. protected _syncParentEnabledState(): void;
  25114. /**
  25115. * Set the enabled state of this node
  25116. * @param value defines the new enabled state
  25117. */
  25118. setEnabled(value: boolean): void;
  25119. /**
  25120. * Is this node a descendant of the given node?
  25121. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25122. * @param ancestor defines the parent node to inspect
  25123. * @returns a boolean indicating if this node is a descendant of the given node
  25124. */
  25125. isDescendantOf(ancestor: Node): boolean;
  25126. /** @hidden */
  25127. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25128. /**
  25129. * Will return all nodes that have this node as ascendant
  25130. * @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
  25131. * @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
  25132. * @return all children nodes of all types
  25133. */
  25134. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25135. /**
  25136. * Get all child-meshes of this node
  25137. * @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)
  25138. * @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
  25139. * @returns an array of AbstractMesh
  25140. */
  25141. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25142. /**
  25143. * Get all direct children of this node
  25144. * @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
  25145. * @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)
  25146. * @returns an array of Node
  25147. */
  25148. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25149. /** @hidden */
  25150. _setReady(state: boolean): void;
  25151. /**
  25152. * Get an animation by name
  25153. * @param name defines the name of the animation to look for
  25154. * @returns null if not found else the requested animation
  25155. */
  25156. getAnimationByName(name: string): Nullable<Animation>;
  25157. /**
  25158. * Creates an animation range for this node
  25159. * @param name defines the name of the range
  25160. * @param from defines the starting key
  25161. * @param to defines the end key
  25162. */
  25163. createAnimationRange(name: string, from: number, to: number): void;
  25164. /**
  25165. * Delete a specific animation range
  25166. * @param name defines the name of the range to delete
  25167. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25168. */
  25169. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25170. /**
  25171. * Get an animation range by name
  25172. * @param name defines the name of the animation range to look for
  25173. * @returns null if not found else the requested animation range
  25174. */
  25175. getAnimationRange(name: string): Nullable<AnimationRange>;
  25176. /**
  25177. * Gets the list of all animation ranges defined on this node
  25178. * @returns an array
  25179. */
  25180. getAnimationRanges(): Nullable<AnimationRange>[];
  25181. /**
  25182. * Will start the animation sequence
  25183. * @param name defines the range frames for animation sequence
  25184. * @param loop defines if the animation should loop (false by default)
  25185. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25186. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25187. * @returns the object created for this animation. If range does not exist, it will return null
  25188. */
  25189. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25190. /**
  25191. * Serialize animation ranges into a JSON compatible object
  25192. * @returns serialization object
  25193. */
  25194. serializeAnimationRanges(): any;
  25195. /**
  25196. * Computes the world matrix of the node
  25197. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25198. * @returns the world matrix
  25199. */
  25200. computeWorldMatrix(force?: boolean): Matrix;
  25201. /**
  25202. * Releases resources associated with this node.
  25203. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25204. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25205. */
  25206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25207. /**
  25208. * Parse animation range data from a serialization object and store them into a given node
  25209. * @param node defines where to store the animation ranges
  25210. * @param parsedNode defines the serialization object to read data from
  25211. * @param scene defines the hosting scene
  25212. */
  25213. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25214. /**
  25215. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25216. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25217. * @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
  25218. * @returns the new bounding vectors
  25219. */
  25220. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25221. min: Vector3;
  25222. max: Vector3;
  25223. };
  25224. }
  25225. }
  25226. declare module BABYLON {
  25227. /**
  25228. * @hidden
  25229. */
  25230. export class _IAnimationState {
  25231. key: number;
  25232. repeatCount: number;
  25233. workValue?: any;
  25234. loopMode?: number;
  25235. offsetValue?: any;
  25236. highLimitValue?: any;
  25237. }
  25238. /**
  25239. * Class used to store any kind of animation
  25240. */
  25241. export class Animation {
  25242. /**Name of the animation */
  25243. name: string;
  25244. /**Property to animate */
  25245. targetProperty: string;
  25246. /**The frames per second of the animation */
  25247. framePerSecond: number;
  25248. /**The data type of the animation */
  25249. dataType: number;
  25250. /**The loop mode of the animation */
  25251. loopMode?: number | undefined;
  25252. /**Specifies if blending should be enabled */
  25253. enableBlending?: boolean | undefined;
  25254. /**
  25255. * Use matrix interpolation instead of using direct key value when animating matrices
  25256. */
  25257. static AllowMatricesInterpolation: boolean;
  25258. /**
  25259. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25260. */
  25261. static AllowMatrixDecomposeForInterpolation: boolean;
  25262. /**
  25263. * Stores the key frames of the animation
  25264. */
  25265. private _keys;
  25266. /**
  25267. * Stores the easing function of the animation
  25268. */
  25269. private _easingFunction;
  25270. /**
  25271. * @hidden Internal use only
  25272. */
  25273. _runtimeAnimations: RuntimeAnimation[];
  25274. /**
  25275. * The set of event that will be linked to this animation
  25276. */
  25277. private _events;
  25278. /**
  25279. * Stores an array of target property paths
  25280. */
  25281. targetPropertyPath: string[];
  25282. /**
  25283. * Stores the blending speed of the animation
  25284. */
  25285. blendingSpeed: number;
  25286. /**
  25287. * Stores the animation ranges for the animation
  25288. */
  25289. private _ranges;
  25290. /**
  25291. * @hidden Internal use
  25292. */
  25293. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25294. /**
  25295. * Sets up an animation
  25296. * @param property The property to animate
  25297. * @param animationType The animation type to apply
  25298. * @param framePerSecond The frames per second of the animation
  25299. * @param easingFunction The easing function used in the animation
  25300. * @returns The created animation
  25301. */
  25302. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25303. /**
  25304. * Create and start an animation on a node
  25305. * @param name defines the name of the global animation that will be run on all nodes
  25306. * @param node defines the root node where the animation will take place
  25307. * @param targetProperty defines property to animate
  25308. * @param framePerSecond defines the number of frame per second yo use
  25309. * @param totalFrame defines the number of frames in total
  25310. * @param from defines the initial value
  25311. * @param to defines the final value
  25312. * @param loopMode defines which loop mode you want to use (off by default)
  25313. * @param easingFunction defines the easing function to use (linear by default)
  25314. * @param onAnimationEnd defines the callback to call when animation end
  25315. * @returns the animatable created for this animation
  25316. */
  25317. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25318. /**
  25319. * Create and start an animation on a node and its descendants
  25320. * @param name defines the name of the global animation that will be run on all nodes
  25321. * @param node defines the root node where the animation will take place
  25322. * @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
  25323. * @param targetProperty defines property to animate
  25324. * @param framePerSecond defines the number of frame per second to use
  25325. * @param totalFrame defines the number of frames in total
  25326. * @param from defines the initial value
  25327. * @param to defines the final value
  25328. * @param loopMode defines which loop mode you want to use (off by default)
  25329. * @param easingFunction defines the easing function to use (linear by default)
  25330. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25331. * @returns the list of animatables created for all nodes
  25332. * @example https://www.babylonjs-playground.com/#MH0VLI
  25333. */
  25334. 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[]>;
  25335. /**
  25336. * Creates a new animation, merges it with the existing animations and starts it
  25337. * @param name Name of the animation
  25338. * @param node Node which contains the scene that begins the animations
  25339. * @param targetProperty Specifies which property to animate
  25340. * @param framePerSecond The frames per second of the animation
  25341. * @param totalFrame The total number of frames
  25342. * @param from The frame at the beginning of the animation
  25343. * @param to The frame at the end of the animation
  25344. * @param loopMode Specifies the loop mode of the animation
  25345. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25346. * @param onAnimationEnd Callback to run once the animation is complete
  25347. * @returns Nullable animation
  25348. */
  25349. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25350. /**
  25351. * Transition property of an host to the target Value
  25352. * @param property The property to transition
  25353. * @param targetValue The target Value of the property
  25354. * @param host The object where the property to animate belongs
  25355. * @param scene Scene used to run the animation
  25356. * @param frameRate Framerate (in frame/s) to use
  25357. * @param transition The transition type we want to use
  25358. * @param duration The duration of the animation, in milliseconds
  25359. * @param onAnimationEnd Callback trigger at the end of the animation
  25360. * @returns Nullable animation
  25361. */
  25362. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25363. /**
  25364. * Return the array of runtime animations currently using this animation
  25365. */
  25366. readonly runtimeAnimations: RuntimeAnimation[];
  25367. /**
  25368. * Specifies if any of the runtime animations are currently running
  25369. */
  25370. readonly hasRunningRuntimeAnimations: boolean;
  25371. /**
  25372. * Initializes the animation
  25373. * @param name Name of the animation
  25374. * @param targetProperty Property to animate
  25375. * @param framePerSecond The frames per second of the animation
  25376. * @param dataType The data type of the animation
  25377. * @param loopMode The loop mode of the animation
  25378. * @param enableBlending Specifies if blending should be enabled
  25379. */
  25380. constructor(
  25381. /**Name of the animation */
  25382. name: string,
  25383. /**Property to animate */
  25384. targetProperty: string,
  25385. /**The frames per second of the animation */
  25386. framePerSecond: number,
  25387. /**The data type of the animation */
  25388. dataType: number,
  25389. /**The loop mode of the animation */
  25390. loopMode?: number | undefined,
  25391. /**Specifies if blending should be enabled */
  25392. enableBlending?: boolean | undefined);
  25393. /**
  25394. * Converts the animation to a string
  25395. * @param fullDetails support for multiple levels of logging within scene loading
  25396. * @returns String form of the animation
  25397. */
  25398. toString(fullDetails?: boolean): string;
  25399. /**
  25400. * Add an event to this animation
  25401. * @param event Event to add
  25402. */
  25403. addEvent(event: AnimationEvent): void;
  25404. /**
  25405. * Remove all events found at the given frame
  25406. * @param frame The frame to remove events from
  25407. */
  25408. removeEvents(frame: number): void;
  25409. /**
  25410. * Retrieves all the events from the animation
  25411. * @returns Events from the animation
  25412. */
  25413. getEvents(): AnimationEvent[];
  25414. /**
  25415. * Creates an animation range
  25416. * @param name Name of the animation range
  25417. * @param from Starting frame of the animation range
  25418. * @param to Ending frame of the animation
  25419. */
  25420. createRange(name: string, from: number, to: number): void;
  25421. /**
  25422. * Deletes an animation range by name
  25423. * @param name Name of the animation range to delete
  25424. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25425. */
  25426. deleteRange(name: string, deleteFrames?: boolean): void;
  25427. /**
  25428. * Gets the animation range by name, or null if not defined
  25429. * @param name Name of the animation range
  25430. * @returns Nullable animation range
  25431. */
  25432. getRange(name: string): Nullable<AnimationRange>;
  25433. /**
  25434. * Gets the key frames from the animation
  25435. * @returns The key frames of the animation
  25436. */
  25437. getKeys(): Array<IAnimationKey>;
  25438. /**
  25439. * Gets the highest frame rate of the animation
  25440. * @returns Highest frame rate of the animation
  25441. */
  25442. getHighestFrame(): number;
  25443. /**
  25444. * Gets the easing function of the animation
  25445. * @returns Easing function of the animation
  25446. */
  25447. getEasingFunction(): IEasingFunction;
  25448. /**
  25449. * Sets the easing function of the animation
  25450. * @param easingFunction A custom mathematical formula for animation
  25451. */
  25452. setEasingFunction(easingFunction: EasingFunction): void;
  25453. /**
  25454. * Interpolates a scalar linearly
  25455. * @param startValue Start value of the animation curve
  25456. * @param endValue End value of the animation curve
  25457. * @param gradient Scalar amount to interpolate
  25458. * @returns Interpolated scalar value
  25459. */
  25460. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25461. /**
  25462. * Interpolates a scalar cubically
  25463. * @param startValue Start value of the animation curve
  25464. * @param outTangent End tangent of the animation
  25465. * @param endValue End value of the animation curve
  25466. * @param inTangent Start tangent of the animation curve
  25467. * @param gradient Scalar amount to interpolate
  25468. * @returns Interpolated scalar value
  25469. */
  25470. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25471. /**
  25472. * Interpolates a quaternion using a spherical linear interpolation
  25473. * @param startValue Start value of the animation curve
  25474. * @param endValue End value of the animation curve
  25475. * @param gradient Scalar amount to interpolate
  25476. * @returns Interpolated quaternion value
  25477. */
  25478. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25479. /**
  25480. * Interpolates a quaternion cubically
  25481. * @param startValue Start value of the animation curve
  25482. * @param outTangent End tangent of the animation curve
  25483. * @param endValue End value of the animation curve
  25484. * @param inTangent Start tangent of the animation curve
  25485. * @param gradient Scalar amount to interpolate
  25486. * @returns Interpolated quaternion value
  25487. */
  25488. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25489. /**
  25490. * Interpolates a Vector3 linearl
  25491. * @param startValue Start value of the animation curve
  25492. * @param endValue End value of the animation curve
  25493. * @param gradient Scalar amount to interpolate
  25494. * @returns Interpolated scalar value
  25495. */
  25496. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25497. /**
  25498. * Interpolates a Vector3 cubically
  25499. * @param startValue Start value of the animation curve
  25500. * @param outTangent End tangent of the animation
  25501. * @param endValue End value of the animation curve
  25502. * @param inTangent Start tangent of the animation curve
  25503. * @param gradient Scalar amount to interpolate
  25504. * @returns InterpolatedVector3 value
  25505. */
  25506. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25507. /**
  25508. * Interpolates a Vector2 linearly
  25509. * @param startValue Start value of the animation curve
  25510. * @param endValue End value of the animation curve
  25511. * @param gradient Scalar amount to interpolate
  25512. * @returns Interpolated Vector2 value
  25513. */
  25514. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25515. /**
  25516. * Interpolates a Vector2 cubically
  25517. * @param startValue Start value of the animation curve
  25518. * @param outTangent End tangent of the animation
  25519. * @param endValue End value of the animation curve
  25520. * @param inTangent Start tangent of the animation curve
  25521. * @param gradient Scalar amount to interpolate
  25522. * @returns Interpolated Vector2 value
  25523. */
  25524. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25525. /**
  25526. * Interpolates a size linearly
  25527. * @param startValue Start value of the animation curve
  25528. * @param endValue End value of the animation curve
  25529. * @param gradient Scalar amount to interpolate
  25530. * @returns Interpolated Size value
  25531. */
  25532. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25533. /**
  25534. * Interpolates a Color3 linearly
  25535. * @param startValue Start value of the animation curve
  25536. * @param endValue End value of the animation curve
  25537. * @param gradient Scalar amount to interpolate
  25538. * @returns Interpolated Color3 value
  25539. */
  25540. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25541. /**
  25542. * @hidden Internal use only
  25543. */
  25544. _getKeyValue(value: any): any;
  25545. /**
  25546. * @hidden Internal use only
  25547. */
  25548. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25549. /**
  25550. * Defines the function to use to interpolate matrices
  25551. * @param startValue defines the start matrix
  25552. * @param endValue defines the end matrix
  25553. * @param gradient defines the gradient between both matrices
  25554. * @param result defines an optional target matrix where to store the interpolation
  25555. * @returns the interpolated matrix
  25556. */
  25557. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25558. /**
  25559. * Makes a copy of the animation
  25560. * @returns Cloned animation
  25561. */
  25562. clone(): Animation;
  25563. /**
  25564. * Sets the key frames of the animation
  25565. * @param values The animation key frames to set
  25566. */
  25567. setKeys(values: Array<IAnimationKey>): void;
  25568. /**
  25569. * Serializes the animation to an object
  25570. * @returns Serialized object
  25571. */
  25572. serialize(): any;
  25573. /**
  25574. * Float animation type
  25575. */
  25576. private static _ANIMATIONTYPE_FLOAT;
  25577. /**
  25578. * Vector3 animation type
  25579. */
  25580. private static _ANIMATIONTYPE_VECTOR3;
  25581. /**
  25582. * Quaternion animation type
  25583. */
  25584. private static _ANIMATIONTYPE_QUATERNION;
  25585. /**
  25586. * Matrix animation type
  25587. */
  25588. private static _ANIMATIONTYPE_MATRIX;
  25589. /**
  25590. * Color3 animation type
  25591. */
  25592. private static _ANIMATIONTYPE_COLOR3;
  25593. /**
  25594. * Vector2 animation type
  25595. */
  25596. private static _ANIMATIONTYPE_VECTOR2;
  25597. /**
  25598. * Size animation type
  25599. */
  25600. private static _ANIMATIONTYPE_SIZE;
  25601. /**
  25602. * Relative Loop Mode
  25603. */
  25604. private static _ANIMATIONLOOPMODE_RELATIVE;
  25605. /**
  25606. * Cycle Loop Mode
  25607. */
  25608. private static _ANIMATIONLOOPMODE_CYCLE;
  25609. /**
  25610. * Constant Loop Mode
  25611. */
  25612. private static _ANIMATIONLOOPMODE_CONSTANT;
  25613. /**
  25614. * Get the float animation type
  25615. */
  25616. static readonly ANIMATIONTYPE_FLOAT: number;
  25617. /**
  25618. * Get the Vector3 animation type
  25619. */
  25620. static readonly ANIMATIONTYPE_VECTOR3: number;
  25621. /**
  25622. * Get the Vector2 animation type
  25623. */
  25624. static readonly ANIMATIONTYPE_VECTOR2: number;
  25625. /**
  25626. * Get the Size animation type
  25627. */
  25628. static readonly ANIMATIONTYPE_SIZE: number;
  25629. /**
  25630. * Get the Quaternion animation type
  25631. */
  25632. static readonly ANIMATIONTYPE_QUATERNION: number;
  25633. /**
  25634. * Get the Matrix animation type
  25635. */
  25636. static readonly ANIMATIONTYPE_MATRIX: number;
  25637. /**
  25638. * Get the Color3 animation type
  25639. */
  25640. static readonly ANIMATIONTYPE_COLOR3: number;
  25641. /**
  25642. * Get the Relative Loop Mode
  25643. */
  25644. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25645. /**
  25646. * Get the Cycle Loop Mode
  25647. */
  25648. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25649. /**
  25650. * Get the Constant Loop Mode
  25651. */
  25652. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25653. /** @hidden */
  25654. static _UniversalLerp(left: any, right: any, amount: number): any;
  25655. /**
  25656. * Parses an animation object and creates an animation
  25657. * @param parsedAnimation Parsed animation object
  25658. * @returns Animation object
  25659. */
  25660. static Parse(parsedAnimation: any): Animation;
  25661. /**
  25662. * Appends the serialized animations from the source animations
  25663. * @param source Source containing the animations
  25664. * @param destination Target to store the animations
  25665. */
  25666. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25667. }
  25668. }
  25669. declare module BABYLON {
  25670. /**
  25671. * Base class of all the textures in babylon.
  25672. * It groups all the common properties the materials, post process, lights... might need
  25673. * in order to make a correct use of the texture.
  25674. */
  25675. export class BaseTexture implements IAnimatable {
  25676. /**
  25677. * Default anisotropic filtering level for the application.
  25678. * It is set to 4 as a good tradeoff between perf and quality.
  25679. */
  25680. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25681. /**
  25682. * Gets or sets the unique id of the texture
  25683. */
  25684. uniqueId: number;
  25685. /**
  25686. * Define the name of the texture.
  25687. */
  25688. name: string;
  25689. /**
  25690. * Gets or sets an object used to store user defined information.
  25691. */
  25692. metadata: any;
  25693. /**
  25694. * For internal use only. Please do not use.
  25695. */
  25696. reservedDataStore: any;
  25697. private _hasAlpha;
  25698. /**
  25699. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25700. */
  25701. hasAlpha: boolean;
  25702. /**
  25703. * Defines if the alpha value should be determined via the rgb values.
  25704. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25705. */
  25706. getAlphaFromRGB: boolean;
  25707. /**
  25708. * Intensity or strength of the texture.
  25709. * It is commonly used by materials to fine tune the intensity of the texture
  25710. */
  25711. level: number;
  25712. /**
  25713. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25714. * This is part of the texture as textures usually maps to one uv set.
  25715. */
  25716. coordinatesIndex: number;
  25717. private _coordinatesMode;
  25718. /**
  25719. * How a texture is mapped.
  25720. *
  25721. * | Value | Type | Description |
  25722. * | ----- | ----------------------------------- | ----------- |
  25723. * | 0 | EXPLICIT_MODE | |
  25724. * | 1 | SPHERICAL_MODE | |
  25725. * | 2 | PLANAR_MODE | |
  25726. * | 3 | CUBIC_MODE | |
  25727. * | 4 | PROJECTION_MODE | |
  25728. * | 5 | SKYBOX_MODE | |
  25729. * | 6 | INVCUBIC_MODE | |
  25730. * | 7 | EQUIRECTANGULAR_MODE | |
  25731. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25732. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25733. */
  25734. coordinatesMode: number;
  25735. /**
  25736. * | Value | Type | Description |
  25737. * | ----- | ------------------ | ----------- |
  25738. * | 0 | CLAMP_ADDRESSMODE | |
  25739. * | 1 | WRAP_ADDRESSMODE | |
  25740. * | 2 | MIRROR_ADDRESSMODE | |
  25741. */
  25742. wrapU: number;
  25743. /**
  25744. * | Value | Type | Description |
  25745. * | ----- | ------------------ | ----------- |
  25746. * | 0 | CLAMP_ADDRESSMODE | |
  25747. * | 1 | WRAP_ADDRESSMODE | |
  25748. * | 2 | MIRROR_ADDRESSMODE | |
  25749. */
  25750. wrapV: number;
  25751. /**
  25752. * | Value | Type | Description |
  25753. * | ----- | ------------------ | ----------- |
  25754. * | 0 | CLAMP_ADDRESSMODE | |
  25755. * | 1 | WRAP_ADDRESSMODE | |
  25756. * | 2 | MIRROR_ADDRESSMODE | |
  25757. */
  25758. wrapR: number;
  25759. /**
  25760. * With compliant hardware and browser (supporting anisotropic filtering)
  25761. * this defines the level of anisotropic filtering in the texture.
  25762. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25763. */
  25764. anisotropicFilteringLevel: number;
  25765. /**
  25766. * Define if the texture is a cube texture or if false a 2d texture.
  25767. */
  25768. isCube: boolean;
  25769. /**
  25770. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25771. */
  25772. is3D: boolean;
  25773. /**
  25774. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25775. * HDR texture are usually stored in linear space.
  25776. * This only impacts the PBR and Background materials
  25777. */
  25778. gammaSpace: boolean;
  25779. /**
  25780. * Gets whether or not the texture contains RGBD data.
  25781. */
  25782. readonly isRGBD: boolean;
  25783. /**
  25784. * Is Z inverted in the texture (useful in a cube texture).
  25785. */
  25786. invertZ: boolean;
  25787. /**
  25788. * Are mip maps generated for this texture or not.
  25789. */
  25790. readonly noMipmap: boolean;
  25791. /**
  25792. * @hidden
  25793. */
  25794. lodLevelInAlpha: boolean;
  25795. /**
  25796. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25797. */
  25798. lodGenerationOffset: number;
  25799. /**
  25800. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25801. */
  25802. lodGenerationScale: number;
  25803. /**
  25804. * Define if the texture is a render target.
  25805. */
  25806. isRenderTarget: boolean;
  25807. /**
  25808. * Define the unique id of the texture in the scene.
  25809. */
  25810. readonly uid: string;
  25811. /**
  25812. * Return a string representation of the texture.
  25813. * @returns the texture as a string
  25814. */
  25815. toString(): string;
  25816. /**
  25817. * Get the class name of the texture.
  25818. * @returns "BaseTexture"
  25819. */
  25820. getClassName(): string;
  25821. /**
  25822. * Define the list of animation attached to the texture.
  25823. */
  25824. animations: Animation[];
  25825. /**
  25826. * An event triggered when the texture is disposed.
  25827. */
  25828. onDisposeObservable: Observable<BaseTexture>;
  25829. private _onDisposeObserver;
  25830. /**
  25831. * Callback triggered when the texture has been disposed.
  25832. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25833. */
  25834. onDispose: () => void;
  25835. /**
  25836. * Define the current state of the loading sequence when in delayed load mode.
  25837. */
  25838. delayLoadState: number;
  25839. private _scene;
  25840. /** @hidden */
  25841. _texture: Nullable<InternalTexture>;
  25842. private _uid;
  25843. /**
  25844. * Define if the texture is preventinga material to render or not.
  25845. * If not and the texture is not ready, the engine will use a default black texture instead.
  25846. */
  25847. readonly isBlocking: boolean;
  25848. /**
  25849. * Instantiates a new BaseTexture.
  25850. * Base class of all the textures in babylon.
  25851. * It groups all the common properties the materials, post process, lights... might need
  25852. * in order to make a correct use of the texture.
  25853. * @param scene Define the scene the texture blongs to
  25854. */
  25855. constructor(scene: Nullable<Scene>);
  25856. /**
  25857. * Get the scene the texture belongs to.
  25858. * @returns the scene or null if undefined
  25859. */
  25860. getScene(): Nullable<Scene>;
  25861. /**
  25862. * Get the texture transform matrix used to offset tile the texture for istance.
  25863. * @returns the transformation matrix
  25864. */
  25865. getTextureMatrix(): Matrix;
  25866. /**
  25867. * Get the texture reflection matrix used to rotate/transform the reflection.
  25868. * @returns the reflection matrix
  25869. */
  25870. getReflectionTextureMatrix(): Matrix;
  25871. /**
  25872. * Get the underlying lower level texture from Babylon.
  25873. * @returns the insternal texture
  25874. */
  25875. getInternalTexture(): Nullable<InternalTexture>;
  25876. /**
  25877. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25878. * @returns true if ready or not blocking
  25879. */
  25880. isReadyOrNotBlocking(): boolean;
  25881. /**
  25882. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25883. * @returns true if fully ready
  25884. */
  25885. isReady(): boolean;
  25886. private _cachedSize;
  25887. /**
  25888. * Get the size of the texture.
  25889. * @returns the texture size.
  25890. */
  25891. getSize(): ISize;
  25892. /**
  25893. * Get the base size of the texture.
  25894. * It can be different from the size if the texture has been resized for POT for instance
  25895. * @returns the base size
  25896. */
  25897. getBaseSize(): ISize;
  25898. /**
  25899. * Update the sampling mode of the texture.
  25900. * Default is Trilinear mode.
  25901. *
  25902. * | Value | Type | Description |
  25903. * | ----- | ------------------ | ----------- |
  25904. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25905. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25906. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25907. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25908. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25909. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25910. * | 7 | NEAREST_LINEAR | |
  25911. * | 8 | NEAREST_NEAREST | |
  25912. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25913. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25914. * | 11 | LINEAR_LINEAR | |
  25915. * | 12 | LINEAR_NEAREST | |
  25916. *
  25917. * > _mag_: magnification filter (close to the viewer)
  25918. * > _min_: minification filter (far from the viewer)
  25919. * > _mip_: filter used between mip map levels
  25920. *@param samplingMode Define the new sampling mode of the texture
  25921. */
  25922. updateSamplingMode(samplingMode: number): void;
  25923. /**
  25924. * Scales the texture if is `canRescale()`
  25925. * @param ratio the resize factor we want to use to rescale
  25926. */
  25927. scale(ratio: number): void;
  25928. /**
  25929. * Get if the texture can rescale.
  25930. */
  25931. readonly canRescale: boolean;
  25932. /** @hidden */
  25933. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25934. /** @hidden */
  25935. _rebuild(): void;
  25936. /**
  25937. * Triggers the load sequence in delayed load mode.
  25938. */
  25939. delayLoad(): void;
  25940. /**
  25941. * Clones the texture.
  25942. * @returns the cloned texture
  25943. */
  25944. clone(): Nullable<BaseTexture>;
  25945. /**
  25946. * Get the texture underlying type (INT, FLOAT...)
  25947. */
  25948. readonly textureType: number;
  25949. /**
  25950. * Get the texture underlying format (RGB, RGBA...)
  25951. */
  25952. readonly textureFormat: number;
  25953. /**
  25954. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25955. * This will returns an RGBA array buffer containing either in values (0-255) or
  25956. * float values (0-1) depending of the underlying buffer type.
  25957. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25958. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25959. * @param buffer defines a user defined buffer to fill with data (can be null)
  25960. * @returns The Array buffer containing the pixels data.
  25961. */
  25962. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25963. /**
  25964. * Release and destroy the underlying lower level texture aka internalTexture.
  25965. */
  25966. releaseInternalTexture(): void;
  25967. /**
  25968. * Get the polynomial representation of the texture data.
  25969. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25970. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25971. */
  25972. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25973. /** @hidden */
  25974. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25975. /** @hidden */
  25976. readonly _lodTextureMid: Nullable<BaseTexture>;
  25977. /** @hidden */
  25978. readonly _lodTextureLow: Nullable<BaseTexture>;
  25979. /**
  25980. * Dispose the texture and release its associated resources.
  25981. */
  25982. dispose(): void;
  25983. /**
  25984. * Serialize the texture into a JSON representation that can be parsed later on.
  25985. * @returns the JSON representation of the texture
  25986. */
  25987. serialize(): any;
  25988. /**
  25989. * Helper function to be called back once a list of texture contains only ready textures.
  25990. * @param textures Define the list of textures to wait for
  25991. * @param callback Define the callback triggered once the entire list will be ready
  25992. */
  25993. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25994. }
  25995. }
  25996. declare module BABYLON {
  25997. /**
  25998. * Uniform buffer objects.
  25999. *
  26000. * Handles blocks of uniform on the GPU.
  26001. *
  26002. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26003. *
  26004. * For more information, please refer to :
  26005. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26006. */
  26007. export class UniformBuffer {
  26008. private _engine;
  26009. private _buffer;
  26010. private _data;
  26011. private _bufferData;
  26012. private _dynamic?;
  26013. private _uniformLocations;
  26014. private _uniformSizes;
  26015. private _uniformLocationPointer;
  26016. private _needSync;
  26017. private _noUBO;
  26018. private _currentEffect;
  26019. private static _MAX_UNIFORM_SIZE;
  26020. private static _tempBuffer;
  26021. /**
  26022. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26023. * This is dynamic to allow compat with webgl 1 and 2.
  26024. * You will need to pass the name of the uniform as well as the value.
  26025. */
  26026. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26027. /**
  26028. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26029. * This is dynamic to allow compat with webgl 1 and 2.
  26030. * You will need to pass the name of the uniform as well as the value.
  26031. */
  26032. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26033. /**
  26034. * Lambda to Update a single float in a uniform buffer.
  26035. * This is dynamic to allow compat with webgl 1 and 2.
  26036. * You will need to pass the name of the uniform as well as the value.
  26037. */
  26038. updateFloat: (name: string, x: number) => void;
  26039. /**
  26040. * Lambda to Update a vec2 of float in a uniform buffer.
  26041. * This is dynamic to allow compat with webgl 1 and 2.
  26042. * You will need to pass the name of the uniform as well as the value.
  26043. */
  26044. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26045. /**
  26046. * Lambda to Update a vec3 of float in a uniform buffer.
  26047. * This is dynamic to allow compat with webgl 1 and 2.
  26048. * You will need to pass the name of the uniform as well as the value.
  26049. */
  26050. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26051. /**
  26052. * Lambda to Update a vec4 of float in a uniform buffer.
  26053. * This is dynamic to allow compat with webgl 1 and 2.
  26054. * You will need to pass the name of the uniform as well as the value.
  26055. */
  26056. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26057. /**
  26058. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26059. * This is dynamic to allow compat with webgl 1 and 2.
  26060. * You will need to pass the name of the uniform as well as the value.
  26061. */
  26062. updateMatrix: (name: string, mat: Matrix) => void;
  26063. /**
  26064. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26065. * This is dynamic to allow compat with webgl 1 and 2.
  26066. * You will need to pass the name of the uniform as well as the value.
  26067. */
  26068. updateVector3: (name: string, vector: Vector3) => void;
  26069. /**
  26070. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26071. * This is dynamic to allow compat with webgl 1 and 2.
  26072. * You will need to pass the name of the uniform as well as the value.
  26073. */
  26074. updateVector4: (name: string, vector: Vector4) => void;
  26075. /**
  26076. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26077. * This is dynamic to allow compat with webgl 1 and 2.
  26078. * You will need to pass the name of the uniform as well as the value.
  26079. */
  26080. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26081. /**
  26082. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26083. * This is dynamic to allow compat with webgl 1 and 2.
  26084. * You will need to pass the name of the uniform as well as the value.
  26085. */
  26086. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26087. /**
  26088. * Instantiates a new Uniform buffer objects.
  26089. *
  26090. * Handles blocks of uniform on the GPU.
  26091. *
  26092. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26093. *
  26094. * For more information, please refer to :
  26095. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26096. * @param engine Define the engine the buffer is associated with
  26097. * @param data Define the data contained in the buffer
  26098. * @param dynamic Define if the buffer is updatable
  26099. */
  26100. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26101. /**
  26102. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26103. * or just falling back on setUniformXXX calls.
  26104. */
  26105. readonly useUbo: boolean;
  26106. /**
  26107. * Indicates if the WebGL underlying uniform buffer is in sync
  26108. * with the javascript cache data.
  26109. */
  26110. readonly isSync: boolean;
  26111. /**
  26112. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26113. * Also, a dynamic UniformBuffer will disable cache verification and always
  26114. * update the underlying WebGL uniform buffer to the GPU.
  26115. * @returns if Dynamic, otherwise false
  26116. */
  26117. isDynamic(): boolean;
  26118. /**
  26119. * The data cache on JS side.
  26120. * @returns the underlying data as a float array
  26121. */
  26122. getData(): Float32Array;
  26123. /**
  26124. * The underlying WebGL Uniform buffer.
  26125. * @returns the webgl buffer
  26126. */
  26127. getBuffer(): Nullable<WebGLBuffer>;
  26128. /**
  26129. * std140 layout specifies how to align data within an UBO structure.
  26130. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26131. * for specs.
  26132. */
  26133. private _fillAlignment;
  26134. /**
  26135. * Adds an uniform in the buffer.
  26136. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26137. * for the layout to be correct !
  26138. * @param name Name of the uniform, as used in the uniform block in the shader.
  26139. * @param size Data size, or data directly.
  26140. */
  26141. addUniform(name: string, size: number | number[]): void;
  26142. /**
  26143. * Adds a Matrix 4x4 to the uniform buffer.
  26144. * @param name Name of the uniform, as used in the uniform block in the shader.
  26145. * @param mat A 4x4 matrix.
  26146. */
  26147. addMatrix(name: string, mat: Matrix): void;
  26148. /**
  26149. * Adds a vec2 to the uniform buffer.
  26150. * @param name Name of the uniform, as used in the uniform block in the shader.
  26151. * @param x Define the x component value of the vec2
  26152. * @param y Define the y component value of the vec2
  26153. */
  26154. addFloat2(name: string, x: number, y: number): void;
  26155. /**
  26156. * Adds a vec3 to the uniform buffer.
  26157. * @param name Name of the uniform, as used in the uniform block in the shader.
  26158. * @param x Define the x component value of the vec3
  26159. * @param y Define the y component value of the vec3
  26160. * @param z Define the z component value of the vec3
  26161. */
  26162. addFloat3(name: string, x: number, y: number, z: number): void;
  26163. /**
  26164. * Adds a vec3 to the uniform buffer.
  26165. * @param name Name of the uniform, as used in the uniform block in the shader.
  26166. * @param color Define the vec3 from a Color
  26167. */
  26168. addColor3(name: string, color: Color3): void;
  26169. /**
  26170. * Adds a vec4 to the uniform buffer.
  26171. * @param name Name of the uniform, as used in the uniform block in the shader.
  26172. * @param color Define the rgb components from a Color
  26173. * @param alpha Define the a component of the vec4
  26174. */
  26175. addColor4(name: string, color: Color3, alpha: number): void;
  26176. /**
  26177. * Adds a vec3 to the uniform buffer.
  26178. * @param name Name of the uniform, as used in the uniform block in the shader.
  26179. * @param vector Define the vec3 components from a Vector
  26180. */
  26181. addVector3(name: string, vector: Vector3): void;
  26182. /**
  26183. * Adds a Matrix 3x3 to the uniform buffer.
  26184. * @param name Name of the uniform, as used in the uniform block in the shader.
  26185. */
  26186. addMatrix3x3(name: string): void;
  26187. /**
  26188. * Adds a Matrix 2x2 to the uniform buffer.
  26189. * @param name Name of the uniform, as used in the uniform block in the shader.
  26190. */
  26191. addMatrix2x2(name: string): void;
  26192. /**
  26193. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26194. */
  26195. create(): void;
  26196. /** @hidden */
  26197. _rebuild(): void;
  26198. /**
  26199. * Updates the WebGL Uniform Buffer on the GPU.
  26200. * If the `dynamic` flag is set to true, no cache comparison is done.
  26201. * Otherwise, the buffer will be updated only if the cache differs.
  26202. */
  26203. update(): void;
  26204. /**
  26205. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26206. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26207. * @param data Define the flattened data
  26208. * @param size Define the size of the data.
  26209. */
  26210. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26211. private _updateMatrix3x3ForUniform;
  26212. private _updateMatrix3x3ForEffect;
  26213. private _updateMatrix2x2ForEffect;
  26214. private _updateMatrix2x2ForUniform;
  26215. private _updateFloatForEffect;
  26216. private _updateFloatForUniform;
  26217. private _updateFloat2ForEffect;
  26218. private _updateFloat2ForUniform;
  26219. private _updateFloat3ForEffect;
  26220. private _updateFloat3ForUniform;
  26221. private _updateFloat4ForEffect;
  26222. private _updateFloat4ForUniform;
  26223. private _updateMatrixForEffect;
  26224. private _updateMatrixForUniform;
  26225. private _updateVector3ForEffect;
  26226. private _updateVector3ForUniform;
  26227. private _updateVector4ForEffect;
  26228. private _updateVector4ForUniform;
  26229. private _updateColor3ForEffect;
  26230. private _updateColor3ForUniform;
  26231. private _updateColor4ForEffect;
  26232. private _updateColor4ForUniform;
  26233. /**
  26234. * Sets a sampler uniform on the effect.
  26235. * @param name Define the name of the sampler.
  26236. * @param texture Define the texture to set in the sampler
  26237. */
  26238. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26239. /**
  26240. * Directly updates the value of the uniform in the cache AND on the GPU.
  26241. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26242. * @param data Define the flattened data
  26243. */
  26244. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26245. /**
  26246. * Binds this uniform buffer to an effect.
  26247. * @param effect Define the effect to bind the buffer to
  26248. * @param name Name of the uniform block in the shader.
  26249. */
  26250. bindToEffect(effect: Effect, name: string): void;
  26251. /**
  26252. * Disposes the uniform buffer.
  26253. */
  26254. dispose(): void;
  26255. }
  26256. }
  26257. declare module BABYLON {
  26258. /**
  26259. * This represents the required contract to create a new type of texture loader.
  26260. */
  26261. export interface IInternalTextureLoader {
  26262. /**
  26263. * Defines wether the loader supports cascade loading the different faces.
  26264. */
  26265. supportCascades: boolean;
  26266. /**
  26267. * This returns if the loader support the current file information.
  26268. * @param extension defines the file extension of the file being loaded
  26269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26270. * @param fallback defines the fallback internal texture if any
  26271. * @param isBase64 defines whether the texture is encoded as a base64
  26272. * @param isBuffer defines whether the texture data are stored as a buffer
  26273. * @returns true if the loader can load the specified file
  26274. */
  26275. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26276. /**
  26277. * Transform the url before loading if required.
  26278. * @param rootUrl the url of the texture
  26279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26280. * @returns the transformed texture
  26281. */
  26282. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26283. /**
  26284. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26285. * @param rootUrl the url of the texture
  26286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26287. * @returns the fallback texture
  26288. */
  26289. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26290. /**
  26291. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26292. * @param data contains the texture data
  26293. * @param texture defines the BabylonJS internal texture
  26294. * @param createPolynomials will be true if polynomials have been requested
  26295. * @param onLoad defines the callback to trigger once the texture is ready
  26296. * @param onError defines the callback to trigger in case of error
  26297. */
  26298. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26299. /**
  26300. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26301. * @param data contains the texture data
  26302. * @param texture defines the BabylonJS internal texture
  26303. * @param callback defines the method to call once ready to upload
  26304. */
  26305. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26306. }
  26307. }
  26308. declare module BABYLON {
  26309. /**
  26310. * Creation options of the multi render target texture.
  26311. */
  26312. export interface IMultiRenderTargetOptions {
  26313. /**
  26314. * Define if the texture needs to create mip maps after render.
  26315. */
  26316. generateMipMaps?: boolean;
  26317. /**
  26318. * Define the types of all the draw buffers we want to create
  26319. */
  26320. types?: number[];
  26321. /**
  26322. * Define the sampling modes of all the draw buffers we want to create
  26323. */
  26324. samplingModes?: number[];
  26325. /**
  26326. * Define if a depth buffer is required
  26327. */
  26328. generateDepthBuffer?: boolean;
  26329. /**
  26330. * Define if a stencil buffer is required
  26331. */
  26332. generateStencilBuffer?: boolean;
  26333. /**
  26334. * Define if a depth texture is required instead of a depth buffer
  26335. */
  26336. generateDepthTexture?: boolean;
  26337. /**
  26338. * Define the number of desired draw buffers
  26339. */
  26340. textureCount?: number;
  26341. /**
  26342. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26343. */
  26344. doNotChangeAspectRatio?: boolean;
  26345. /**
  26346. * Define the default type of the buffers we are creating
  26347. */
  26348. defaultType?: number;
  26349. }
  26350. /**
  26351. * A multi render target, like a render target provides the ability to render to a texture.
  26352. * Unlike the render target, it can render to several draw buffers in one draw.
  26353. * This is specially interesting in deferred rendering or for any effects requiring more than
  26354. * just one color from a single pass.
  26355. */
  26356. export class MultiRenderTarget extends RenderTargetTexture {
  26357. private _internalTextures;
  26358. private _textures;
  26359. private _multiRenderTargetOptions;
  26360. /**
  26361. * Get if draw buffers are currently supported by the used hardware and browser.
  26362. */
  26363. readonly isSupported: boolean;
  26364. /**
  26365. * Get the list of textures generated by the multi render target.
  26366. */
  26367. readonly textures: Texture[];
  26368. /**
  26369. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26370. */
  26371. readonly depthTexture: Texture;
  26372. /**
  26373. * Set the wrapping mode on U of all the textures we are rendering to.
  26374. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26375. */
  26376. wrapU: number;
  26377. /**
  26378. * Set the wrapping mode on V of all the textures we are rendering to.
  26379. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26380. */
  26381. wrapV: number;
  26382. /**
  26383. * Instantiate a new multi render target texture.
  26384. * A multi render target, like a render target provides the ability to render to a texture.
  26385. * Unlike the render target, it can render to several draw buffers in one draw.
  26386. * This is specially interesting in deferred rendering or for any effects requiring more than
  26387. * just one color from a single pass.
  26388. * @param name Define the name of the texture
  26389. * @param size Define the size of the buffers to render to
  26390. * @param count Define the number of target we are rendering into
  26391. * @param scene Define the scene the texture belongs to
  26392. * @param options Define the options used to create the multi render target
  26393. */
  26394. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26395. /** @hidden */
  26396. _rebuild(): void;
  26397. private _createInternalTextures;
  26398. private _createTextures;
  26399. /**
  26400. * Define the number of samples used if MSAA is enabled.
  26401. */
  26402. samples: number;
  26403. /**
  26404. * Resize all the textures in the multi render target.
  26405. * Be carrefull as it will recreate all the data in the new texture.
  26406. * @param size Define the new size
  26407. */
  26408. resize(size: any): void;
  26409. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26410. /**
  26411. * Dispose the render targets and their associated resources
  26412. */
  26413. dispose(): void;
  26414. /**
  26415. * Release all the underlying texture used as draw buffers.
  26416. */
  26417. releaseInternalTextures(): void;
  26418. }
  26419. }
  26420. declare module BABYLON {
  26421. /**
  26422. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26424. */
  26425. export class Analyser {
  26426. /**
  26427. * Gets or sets the smoothing
  26428. * @ignorenaming
  26429. */
  26430. SMOOTHING: number;
  26431. /**
  26432. * Gets or sets the FFT table size
  26433. * @ignorenaming
  26434. */
  26435. FFT_SIZE: number;
  26436. /**
  26437. * Gets or sets the bar graph amplitude
  26438. * @ignorenaming
  26439. */
  26440. BARGRAPHAMPLITUDE: number;
  26441. /**
  26442. * Gets or sets the position of the debug canvas
  26443. * @ignorenaming
  26444. */
  26445. DEBUGCANVASPOS: {
  26446. x: number;
  26447. y: number;
  26448. };
  26449. /**
  26450. * Gets or sets the debug canvas size
  26451. * @ignorenaming
  26452. */
  26453. DEBUGCANVASSIZE: {
  26454. width: number;
  26455. height: number;
  26456. };
  26457. private _byteFreqs;
  26458. private _byteTime;
  26459. private _floatFreqs;
  26460. private _webAudioAnalyser;
  26461. private _debugCanvas;
  26462. private _debugCanvasContext;
  26463. private _scene;
  26464. private _registerFunc;
  26465. private _audioEngine;
  26466. /**
  26467. * Creates a new analyser
  26468. * @param scene defines hosting scene
  26469. */
  26470. constructor(scene: Scene);
  26471. /**
  26472. * Get the number of data values you will have to play with for the visualization
  26473. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26474. * @returns a number
  26475. */
  26476. getFrequencyBinCount(): number;
  26477. /**
  26478. * Gets the current frequency data as a byte array
  26479. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26480. * @returns a Uint8Array
  26481. */
  26482. getByteFrequencyData(): Uint8Array;
  26483. /**
  26484. * Gets the current waveform as a byte array
  26485. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26486. * @returns a Uint8Array
  26487. */
  26488. getByteTimeDomainData(): Uint8Array;
  26489. /**
  26490. * Gets the current frequency data as a float array
  26491. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26492. * @returns a Float32Array
  26493. */
  26494. getFloatFrequencyData(): Float32Array;
  26495. /**
  26496. * Renders the debug canvas
  26497. */
  26498. drawDebugCanvas(): void;
  26499. /**
  26500. * Stops rendering the debug canvas and removes it
  26501. */
  26502. stopDebugCanvas(): void;
  26503. /**
  26504. * Connects two audio nodes
  26505. * @param inputAudioNode defines first node to connect
  26506. * @param outputAudioNode defines second node to connect
  26507. */
  26508. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26509. /**
  26510. * Releases all associated resources
  26511. */
  26512. dispose(): void;
  26513. }
  26514. }
  26515. declare module BABYLON {
  26516. /**
  26517. * This represents an audio engine and it is responsible
  26518. * to play, synchronize and analyse sounds throughout the application.
  26519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26520. */
  26521. export interface IAudioEngine extends IDisposable {
  26522. /**
  26523. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26524. */
  26525. readonly canUseWebAudio: boolean;
  26526. /**
  26527. * Gets the current AudioContext if available.
  26528. */
  26529. readonly audioContext: Nullable<AudioContext>;
  26530. /**
  26531. * The master gain node defines the global audio volume of your audio engine.
  26532. */
  26533. readonly masterGain: GainNode;
  26534. /**
  26535. * Gets whether or not mp3 are supported by your browser.
  26536. */
  26537. readonly isMP3supported: boolean;
  26538. /**
  26539. * Gets whether or not ogg are supported by your browser.
  26540. */
  26541. readonly isOGGsupported: boolean;
  26542. /**
  26543. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26544. * @ignoreNaming
  26545. */
  26546. WarnedWebAudioUnsupported: boolean;
  26547. /**
  26548. * Defines if the audio engine relies on a custom unlocked button.
  26549. * In this case, the embedded button will not be displayed.
  26550. */
  26551. useCustomUnlockedButton: boolean;
  26552. /**
  26553. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26554. */
  26555. readonly unlocked: boolean;
  26556. /**
  26557. * Event raised when audio has been unlocked on the browser.
  26558. */
  26559. onAudioUnlockedObservable: Observable<AudioEngine>;
  26560. /**
  26561. * Event raised when audio has been locked on the browser.
  26562. */
  26563. onAudioLockedObservable: Observable<AudioEngine>;
  26564. /**
  26565. * Flags the audio engine in Locked state.
  26566. * This happens due to new browser policies preventing audio to autoplay.
  26567. */
  26568. lock(): void;
  26569. /**
  26570. * Unlocks the audio engine once a user action has been done on the dom.
  26571. * This is helpful to resume play once browser policies have been satisfied.
  26572. */
  26573. unlock(): void;
  26574. }
  26575. /**
  26576. * This represents the default audio engine used in babylon.
  26577. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26579. */
  26580. export class AudioEngine implements IAudioEngine {
  26581. private _audioContext;
  26582. private _audioContextInitialized;
  26583. private _muteButton;
  26584. private _hostElement;
  26585. /**
  26586. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26587. */
  26588. canUseWebAudio: boolean;
  26589. /**
  26590. * The master gain node defines the global audio volume of your audio engine.
  26591. */
  26592. masterGain: GainNode;
  26593. /**
  26594. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26595. * @ignoreNaming
  26596. */
  26597. WarnedWebAudioUnsupported: boolean;
  26598. /**
  26599. * Gets whether or not mp3 are supported by your browser.
  26600. */
  26601. isMP3supported: boolean;
  26602. /**
  26603. * Gets whether or not ogg are supported by your browser.
  26604. */
  26605. isOGGsupported: boolean;
  26606. /**
  26607. * Gets whether audio has been unlocked on the device.
  26608. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26609. * a user interaction has happened.
  26610. */
  26611. unlocked: boolean;
  26612. /**
  26613. * Defines if the audio engine relies on a custom unlocked button.
  26614. * In this case, the embedded button will not be displayed.
  26615. */
  26616. useCustomUnlockedButton: boolean;
  26617. /**
  26618. * Event raised when audio has been unlocked on the browser.
  26619. */
  26620. onAudioUnlockedObservable: Observable<AudioEngine>;
  26621. /**
  26622. * Event raised when audio has been locked on the browser.
  26623. */
  26624. onAudioLockedObservable: Observable<AudioEngine>;
  26625. /**
  26626. * Gets the current AudioContext if available.
  26627. */
  26628. readonly audioContext: Nullable<AudioContext>;
  26629. private _connectedAnalyser;
  26630. /**
  26631. * Instantiates a new audio engine.
  26632. *
  26633. * There should be only one per page as some browsers restrict the number
  26634. * of audio contexts you can create.
  26635. * @param hostElement defines the host element where to display the mute icon if necessary
  26636. */
  26637. constructor(hostElement?: Nullable<HTMLElement>);
  26638. /**
  26639. * Flags the audio engine in Locked state.
  26640. * This happens due to new browser policies preventing audio to autoplay.
  26641. */
  26642. lock(): void;
  26643. /**
  26644. * Unlocks the audio engine once a user action has been done on the dom.
  26645. * This is helpful to resume play once browser policies have been satisfied.
  26646. */
  26647. unlock(): void;
  26648. private _resumeAudioContext;
  26649. private _initializeAudioContext;
  26650. private _tryToRun;
  26651. private _triggerRunningState;
  26652. private _triggerSuspendedState;
  26653. private _displayMuteButton;
  26654. private _moveButtonToTopLeft;
  26655. private _onResize;
  26656. private _hideMuteButton;
  26657. /**
  26658. * Destroy and release the resources associated with the audio ccontext.
  26659. */
  26660. dispose(): void;
  26661. /**
  26662. * Gets the global volume sets on the master gain.
  26663. * @returns the global volume if set or -1 otherwise
  26664. */
  26665. getGlobalVolume(): number;
  26666. /**
  26667. * Sets the global volume of your experience (sets on the master gain).
  26668. * @param newVolume Defines the new global volume of the application
  26669. */
  26670. setGlobalVolume(newVolume: number): void;
  26671. /**
  26672. * Connect the audio engine to an audio analyser allowing some amazing
  26673. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26675. * @param analyser The analyser to connect to the engine
  26676. */
  26677. connectToAnalyser(analyser: Analyser): void;
  26678. }
  26679. }
  26680. declare module BABYLON {
  26681. /**
  26682. * Interface used to present a loading screen while loading a scene
  26683. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26684. */
  26685. export interface ILoadingScreen {
  26686. /**
  26687. * Function called to display the loading screen
  26688. */
  26689. displayLoadingUI: () => void;
  26690. /**
  26691. * Function called to hide the loading screen
  26692. */
  26693. hideLoadingUI: () => void;
  26694. /**
  26695. * Gets or sets the color to use for the background
  26696. */
  26697. loadingUIBackgroundColor: string;
  26698. /**
  26699. * Gets or sets the text to display while loading
  26700. */
  26701. loadingUIText: string;
  26702. }
  26703. /**
  26704. * Class used for the default loading screen
  26705. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26706. */
  26707. export class DefaultLoadingScreen implements ILoadingScreen {
  26708. private _renderingCanvas;
  26709. private _loadingText;
  26710. private _loadingDivBackgroundColor;
  26711. private _loadingDiv;
  26712. private _loadingTextDiv;
  26713. /**
  26714. * Creates a new default loading screen
  26715. * @param _renderingCanvas defines the canvas used to render the scene
  26716. * @param _loadingText defines the default text to display
  26717. * @param _loadingDivBackgroundColor defines the default background color
  26718. */
  26719. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26720. /**
  26721. * Function called to display the loading screen
  26722. */
  26723. displayLoadingUI(): void;
  26724. /**
  26725. * Function called to hide the loading screen
  26726. */
  26727. hideLoadingUI(): void;
  26728. /**
  26729. * Gets or sets the text to display while loading
  26730. */
  26731. loadingUIText: string;
  26732. /**
  26733. * Gets or sets the color to use for the background
  26734. */
  26735. loadingUIBackgroundColor: string;
  26736. private _resizeLoadingUI;
  26737. }
  26738. }
  26739. declare module BABYLON {
  26740. /**
  26741. * Settings for finer control over video usage
  26742. */
  26743. export interface VideoTextureSettings {
  26744. /**
  26745. * Applies `autoplay` to video, if specified
  26746. */
  26747. autoPlay?: boolean;
  26748. /**
  26749. * Applies `loop` to video, if specified
  26750. */
  26751. loop?: boolean;
  26752. /**
  26753. * Automatically updates internal texture from video at every frame in the render loop
  26754. */
  26755. autoUpdateTexture: boolean;
  26756. /**
  26757. * Image src displayed during the video loading or until the user interacts with the video.
  26758. */
  26759. poster?: string;
  26760. }
  26761. /**
  26762. * If you want to display a video in your scene, this is the special texture for that.
  26763. * This special texture works similar to other textures, with the exception of a few parameters.
  26764. * @see https://doc.babylonjs.com/how_to/video_texture
  26765. */
  26766. export class VideoTexture extends Texture {
  26767. /**
  26768. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26769. */
  26770. readonly autoUpdateTexture: boolean;
  26771. /**
  26772. * The video instance used by the texture internally
  26773. */
  26774. readonly video: HTMLVideoElement;
  26775. private _onUserActionRequestedObservable;
  26776. /**
  26777. * Event triggerd when a dom action is required by the user to play the video.
  26778. * This happens due to recent changes in browser policies preventing video to auto start.
  26779. */
  26780. readonly onUserActionRequestedObservable: Observable<Texture>;
  26781. private _generateMipMaps;
  26782. private _engine;
  26783. private _stillImageCaptured;
  26784. private _displayingPosterTexture;
  26785. private _settings;
  26786. private _createInternalTextureOnEvent;
  26787. /**
  26788. * Creates a video texture.
  26789. * If you want to display a video in your scene, this is the special texture for that.
  26790. * This special texture works similar to other textures, with the exception of a few parameters.
  26791. * @see https://doc.babylonjs.com/how_to/video_texture
  26792. * @param name optional name, will detect from video source, if not defined
  26793. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26794. * @param scene is obviously the current scene.
  26795. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26796. * @param invertY is false by default but can be used to invert video on Y axis
  26797. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26798. * @param settings allows finer control over video usage
  26799. */
  26800. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26801. private _getName;
  26802. private _getVideo;
  26803. private _createInternalTexture;
  26804. private reset;
  26805. /**
  26806. * @hidden Internal method to initiate `update`.
  26807. */
  26808. _rebuild(): void;
  26809. /**
  26810. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26811. */
  26812. update(): void;
  26813. /**
  26814. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26815. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26816. */
  26817. updateTexture(isVisible: boolean): void;
  26818. protected _updateInternalTexture: () => void;
  26819. /**
  26820. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26821. * @param url New url.
  26822. */
  26823. updateURL(url: string): void;
  26824. /**
  26825. * Dispose the texture and release its associated resources.
  26826. */
  26827. dispose(): void;
  26828. /**
  26829. * Creates a video texture straight from a stream.
  26830. * @param scene Define the scene the texture should be created in
  26831. * @param stream Define the stream the texture should be created from
  26832. * @returns The created video texture as a promise
  26833. */
  26834. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26835. /**
  26836. * Creates a video texture straight from your WebCam video feed.
  26837. * @param scene Define the scene the texture should be created in
  26838. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26839. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26840. * @returns The created video texture as a promise
  26841. */
  26842. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26843. minWidth: number;
  26844. maxWidth: number;
  26845. minHeight: number;
  26846. maxHeight: number;
  26847. deviceId: string;
  26848. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26849. /**
  26850. * Creates a video texture straight from your WebCam video feed.
  26851. * @param scene Define the scene the texture should be created in
  26852. * @param onReady Define a callback to triggered once the texture will be ready
  26853. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26854. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26855. */
  26856. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26857. minWidth: number;
  26858. maxWidth: number;
  26859. minHeight: number;
  26860. maxHeight: number;
  26861. deviceId: string;
  26862. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26863. }
  26864. }
  26865. declare module BABYLON {
  26866. /**
  26867. * Interface for attribute information associated with buffer instanciation
  26868. */
  26869. export class InstancingAttributeInfo {
  26870. /**
  26871. * Index/offset of the attribute in the vertex shader
  26872. */
  26873. index: number;
  26874. /**
  26875. * size of the attribute, 1, 2, 3 or 4
  26876. */
  26877. attributeSize: number;
  26878. /**
  26879. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26880. * default is FLOAT
  26881. */
  26882. attribyteType: number;
  26883. /**
  26884. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26885. */
  26886. normalized: boolean;
  26887. /**
  26888. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26889. */
  26890. offset: number;
  26891. /**
  26892. * Name of the GLSL attribute, for debugging purpose only
  26893. */
  26894. attributeName: string;
  26895. }
  26896. /**
  26897. * Define options used to create a depth texture
  26898. */
  26899. export class DepthTextureCreationOptions {
  26900. /** Specifies whether or not a stencil should be allocated in the texture */
  26901. generateStencil?: boolean;
  26902. /** Specifies whether or not bilinear filtering is enable on the texture */
  26903. bilinearFiltering?: boolean;
  26904. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26905. comparisonFunction?: number;
  26906. /** Specifies if the created texture is a cube texture */
  26907. isCube?: boolean;
  26908. }
  26909. /**
  26910. * Class used to describe the capabilities of the engine relatively to the current browser
  26911. */
  26912. export class EngineCapabilities {
  26913. /** Maximum textures units per fragment shader */
  26914. maxTexturesImageUnits: number;
  26915. /** Maximum texture units per vertex shader */
  26916. maxVertexTextureImageUnits: number;
  26917. /** Maximum textures units in the entire pipeline */
  26918. maxCombinedTexturesImageUnits: number;
  26919. /** Maximum texture size */
  26920. maxTextureSize: number;
  26921. /** Maximum cube texture size */
  26922. maxCubemapTextureSize: number;
  26923. /** Maximum render texture size */
  26924. maxRenderTextureSize: number;
  26925. /** Maximum number of vertex attributes */
  26926. maxVertexAttribs: number;
  26927. /** Maximum number of varyings */
  26928. maxVaryingVectors: number;
  26929. /** Maximum number of uniforms per vertex shader */
  26930. maxVertexUniformVectors: number;
  26931. /** Maximum number of uniforms per fragment shader */
  26932. maxFragmentUniformVectors: number;
  26933. /** Defines if standard derivates (dx/dy) are supported */
  26934. standardDerivatives: boolean;
  26935. /** Defines if s3tc texture compression is supported */
  26936. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26937. /** Defines if pvrtc texture compression is supported */
  26938. pvrtc: any;
  26939. /** Defines if etc1 texture compression is supported */
  26940. etc1: any;
  26941. /** Defines if etc2 texture compression is supported */
  26942. etc2: any;
  26943. /** Defines if astc texture compression is supported */
  26944. astc: any;
  26945. /** Defines if float textures are supported */
  26946. textureFloat: boolean;
  26947. /** Defines if vertex array objects are supported */
  26948. vertexArrayObject: boolean;
  26949. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26950. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26951. /** Gets the maximum level of anisotropy supported */
  26952. maxAnisotropy: number;
  26953. /** Defines if instancing is supported */
  26954. instancedArrays: boolean;
  26955. /** Defines if 32 bits indices are supported */
  26956. uintIndices: boolean;
  26957. /** Defines if high precision shaders are supported */
  26958. highPrecisionShaderSupported: boolean;
  26959. /** Defines if depth reading in the fragment shader is supported */
  26960. fragmentDepthSupported: boolean;
  26961. /** Defines if float texture linear filtering is supported*/
  26962. textureFloatLinearFiltering: boolean;
  26963. /** Defines if rendering to float textures is supported */
  26964. textureFloatRender: boolean;
  26965. /** Defines if half float textures are supported*/
  26966. textureHalfFloat: boolean;
  26967. /** Defines if half float texture linear filtering is supported*/
  26968. textureHalfFloatLinearFiltering: boolean;
  26969. /** Defines if rendering to half float textures is supported */
  26970. textureHalfFloatRender: boolean;
  26971. /** Defines if textureLOD shader command is supported */
  26972. textureLOD: boolean;
  26973. /** Defines if draw buffers extension is supported */
  26974. drawBuffersExtension: boolean;
  26975. /** Defines if depth textures are supported */
  26976. depthTextureExtension: boolean;
  26977. /** Defines if float color buffer are supported */
  26978. colorBufferFloat: boolean;
  26979. /** Gets disjoint timer query extension (null if not supported) */
  26980. timerQuery: EXT_disjoint_timer_query;
  26981. /** Defines if timestamp can be used with timer query */
  26982. canUseTimestampForTimerQuery: boolean;
  26983. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26984. multiview: any;
  26985. /** Function used to let the system compiles shaders in background */
  26986. parallelShaderCompile: {
  26987. COMPLETION_STATUS_KHR: number;
  26988. };
  26989. }
  26990. /** Interface defining initialization parameters for Engine class */
  26991. export interface EngineOptions extends WebGLContextAttributes {
  26992. /**
  26993. * Defines if the engine should no exceed a specified device ratio
  26994. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26995. */
  26996. limitDeviceRatio?: number;
  26997. /**
  26998. * Defines if webvr should be enabled automatically
  26999. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27000. */
  27001. autoEnableWebVR?: boolean;
  27002. /**
  27003. * Defines if webgl2 should be turned off even if supported
  27004. * @see http://doc.babylonjs.com/features/webgl2
  27005. */
  27006. disableWebGL2Support?: boolean;
  27007. /**
  27008. * Defines if webaudio should be initialized as well
  27009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27010. */
  27011. audioEngine?: boolean;
  27012. /**
  27013. * Defines if animations should run using a deterministic lock step
  27014. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27015. */
  27016. deterministicLockstep?: boolean;
  27017. /** Defines the maximum steps to use with deterministic lock step mode */
  27018. lockstepMaxSteps?: number;
  27019. /**
  27020. * Defines that engine should ignore context lost events
  27021. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27022. */
  27023. doNotHandleContextLost?: boolean;
  27024. /**
  27025. * Defines that engine should ignore modifying touch action attribute and style
  27026. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27027. */
  27028. doNotHandleTouchAction?: boolean;
  27029. /**
  27030. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27031. */
  27032. useHighPrecisionFloats?: boolean;
  27033. }
  27034. /**
  27035. * Defines the interface used by display changed events
  27036. */
  27037. export interface IDisplayChangedEventArgs {
  27038. /** Gets the vrDisplay object (if any) */
  27039. vrDisplay: Nullable<any>;
  27040. /** Gets a boolean indicating if webVR is supported */
  27041. vrSupported: boolean;
  27042. }
  27043. /**
  27044. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27045. */
  27046. export class Engine {
  27047. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27048. static ExceptionList: ({
  27049. key: string;
  27050. capture: string;
  27051. captureConstraint: number;
  27052. targets: string[];
  27053. } | {
  27054. key: string;
  27055. capture: null;
  27056. captureConstraint: null;
  27057. targets: string[];
  27058. })[];
  27059. /** Gets the list of created engines */
  27060. static readonly Instances: Engine[];
  27061. /**
  27062. * Gets the latest created engine
  27063. */
  27064. static readonly LastCreatedEngine: Nullable<Engine>;
  27065. /**
  27066. * Gets the latest created scene
  27067. */
  27068. static readonly LastCreatedScene: Nullable<Scene>;
  27069. /**
  27070. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27071. * @param flag defines which part of the materials must be marked as dirty
  27072. * @param predicate defines a predicate used to filter which materials should be affected
  27073. */
  27074. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27075. /**
  27076. * Hidden
  27077. */
  27078. static _TextureLoaders: IInternalTextureLoader[];
  27079. /** Defines that alpha blending is disabled */
  27080. static readonly ALPHA_DISABLE: number;
  27081. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27082. static readonly ALPHA_ADD: number;
  27083. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27084. static readonly ALPHA_COMBINE: number;
  27085. /** Defines that alpha blending to DEST - SRC * DEST */
  27086. static readonly ALPHA_SUBTRACT: number;
  27087. /** Defines that alpha blending to SRC * DEST */
  27088. static readonly ALPHA_MULTIPLY: number;
  27089. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27090. static readonly ALPHA_MAXIMIZED: number;
  27091. /** Defines that alpha blending to SRC + DEST */
  27092. static readonly ALPHA_ONEONE: number;
  27093. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27094. static readonly ALPHA_PREMULTIPLIED: number;
  27095. /**
  27096. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27097. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27098. */
  27099. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27100. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27101. static readonly ALPHA_INTERPOLATE: number;
  27102. /**
  27103. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27104. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27105. */
  27106. static readonly ALPHA_SCREENMODE: number;
  27107. /** Defines that the ressource is not delayed*/
  27108. static readonly DELAYLOADSTATE_NONE: number;
  27109. /** Defines that the ressource was successfully delay loaded */
  27110. static readonly DELAYLOADSTATE_LOADED: number;
  27111. /** Defines that the ressource is currently delay loading */
  27112. static readonly DELAYLOADSTATE_LOADING: number;
  27113. /** Defines that the ressource is delayed and has not started loading */
  27114. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27115. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27116. static readonly NEVER: number;
  27117. /** 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 */
  27118. static readonly ALWAYS: number;
  27119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27120. static readonly LESS: number;
  27121. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27122. static readonly EQUAL: number;
  27123. /** 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 */
  27124. static readonly LEQUAL: number;
  27125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27126. static readonly GREATER: number;
  27127. /** 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 */
  27128. static readonly GEQUAL: number;
  27129. /** 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 */
  27130. static readonly NOTEQUAL: number;
  27131. /** Passed to stencilOperation to specify that stencil value must be kept */
  27132. static readonly KEEP: number;
  27133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27134. static readonly REPLACE: number;
  27135. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27136. static readonly INCR: number;
  27137. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27138. static readonly DECR: number;
  27139. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27140. static readonly INVERT: number;
  27141. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27142. static readonly INCR_WRAP: number;
  27143. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27144. static readonly DECR_WRAP: number;
  27145. /** Texture is not repeating outside of 0..1 UVs */
  27146. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27147. /** Texture is repeating outside of 0..1 UVs */
  27148. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27149. /** Texture is repeating and mirrored */
  27150. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27151. /** ALPHA */
  27152. static readonly TEXTUREFORMAT_ALPHA: number;
  27153. /** LUMINANCE */
  27154. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27155. /** LUMINANCE_ALPHA */
  27156. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27157. /** RGB */
  27158. static readonly TEXTUREFORMAT_RGB: number;
  27159. /** RGBA */
  27160. static readonly TEXTUREFORMAT_RGBA: number;
  27161. /** RED */
  27162. static readonly TEXTUREFORMAT_RED: number;
  27163. /** RED (2nd reference) */
  27164. static readonly TEXTUREFORMAT_R: number;
  27165. /** RG */
  27166. static readonly TEXTUREFORMAT_RG: number;
  27167. /** RED_INTEGER */
  27168. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27169. /** RED_INTEGER (2nd reference) */
  27170. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27171. /** RG_INTEGER */
  27172. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27173. /** RGB_INTEGER */
  27174. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27175. /** RGBA_INTEGER */
  27176. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27177. /** UNSIGNED_BYTE */
  27178. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27179. /** UNSIGNED_BYTE (2nd reference) */
  27180. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27181. /** FLOAT */
  27182. static readonly TEXTURETYPE_FLOAT: number;
  27183. /** HALF_FLOAT */
  27184. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27185. /** BYTE */
  27186. static readonly TEXTURETYPE_BYTE: number;
  27187. /** SHORT */
  27188. static readonly TEXTURETYPE_SHORT: number;
  27189. /** UNSIGNED_SHORT */
  27190. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27191. /** INT */
  27192. static readonly TEXTURETYPE_INT: number;
  27193. /** UNSIGNED_INT */
  27194. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27195. /** UNSIGNED_SHORT_4_4_4_4 */
  27196. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27197. /** UNSIGNED_SHORT_5_5_5_1 */
  27198. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27199. /** UNSIGNED_SHORT_5_6_5 */
  27200. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27201. /** UNSIGNED_INT_2_10_10_10_REV */
  27202. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27203. /** UNSIGNED_INT_24_8 */
  27204. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27205. /** UNSIGNED_INT_10F_11F_11F_REV */
  27206. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27207. /** UNSIGNED_INT_5_9_9_9_REV */
  27208. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27209. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27210. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27211. /** nearest is mag = nearest and min = nearest and mip = linear */
  27212. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27213. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27214. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27215. /** Trilinear is mag = linear and min = linear and mip = linear */
  27216. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27217. /** nearest is mag = nearest and min = nearest and mip = linear */
  27218. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27219. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27220. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27221. /** Trilinear is mag = linear and min = linear and mip = linear */
  27222. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27223. /** mag = nearest and min = nearest and mip = nearest */
  27224. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27225. /** mag = nearest and min = linear and mip = nearest */
  27226. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27227. /** mag = nearest and min = linear and mip = linear */
  27228. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27229. /** mag = nearest and min = linear and mip = none */
  27230. static readonly TEXTURE_NEAREST_LINEAR: number;
  27231. /** mag = nearest and min = nearest and mip = none */
  27232. static readonly TEXTURE_NEAREST_NEAREST: number;
  27233. /** mag = linear and min = nearest and mip = nearest */
  27234. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27235. /** mag = linear and min = nearest and mip = linear */
  27236. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27237. /** mag = linear and min = linear and mip = none */
  27238. static readonly TEXTURE_LINEAR_LINEAR: number;
  27239. /** mag = linear and min = nearest and mip = none */
  27240. static readonly TEXTURE_LINEAR_NEAREST: number;
  27241. /** Explicit coordinates mode */
  27242. static readonly TEXTURE_EXPLICIT_MODE: number;
  27243. /** Spherical coordinates mode */
  27244. static readonly TEXTURE_SPHERICAL_MODE: number;
  27245. /** Planar coordinates mode */
  27246. static readonly TEXTURE_PLANAR_MODE: number;
  27247. /** Cubic coordinates mode */
  27248. static readonly TEXTURE_CUBIC_MODE: number;
  27249. /** Projection coordinates mode */
  27250. static readonly TEXTURE_PROJECTION_MODE: number;
  27251. /** Skybox coordinates mode */
  27252. static readonly TEXTURE_SKYBOX_MODE: number;
  27253. /** Inverse Cubic coordinates mode */
  27254. static readonly TEXTURE_INVCUBIC_MODE: number;
  27255. /** Equirectangular coordinates mode */
  27256. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27257. /** Equirectangular Fixed coordinates mode */
  27258. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27259. /** Equirectangular Fixed Mirrored coordinates mode */
  27260. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27261. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27262. static readonly SCALEMODE_FLOOR: number;
  27263. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27264. static readonly SCALEMODE_NEAREST: number;
  27265. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27266. static readonly SCALEMODE_CEILING: number;
  27267. /**
  27268. * Returns the current npm package of the sdk
  27269. */
  27270. static readonly NpmPackage: string;
  27271. /**
  27272. * Returns the current version of the framework
  27273. */
  27274. static readonly Version: string;
  27275. /**
  27276. * Returns a string describing the current engine
  27277. */
  27278. readonly description: string;
  27279. /**
  27280. * Gets or sets the epsilon value used by collision engine
  27281. */
  27282. static CollisionsEpsilon: number;
  27283. /**
  27284. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27285. */
  27286. static ShadersRepository: string;
  27287. /**
  27288. * Method called to create the default loading screen.
  27289. * This can be overriden in your own app.
  27290. * @param canvas The rendering canvas element
  27291. * @returns The loading screen
  27292. */
  27293. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27294. /**
  27295. * Method called to create the default rescale post process on each engine.
  27296. */
  27297. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27298. /**
  27299. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27300. */
  27301. forcePOTTextures: boolean;
  27302. /**
  27303. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27304. */
  27305. isFullscreen: boolean;
  27306. /**
  27307. * Gets a boolean indicating if the pointer is currently locked
  27308. */
  27309. isPointerLock: boolean;
  27310. /**
  27311. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27312. */
  27313. cullBackFaces: boolean;
  27314. /**
  27315. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27316. */
  27317. renderEvenInBackground: boolean;
  27318. /**
  27319. * Gets or sets a boolean indicating that cache can be kept between frames
  27320. */
  27321. preventCacheWipeBetweenFrames: boolean;
  27322. /**
  27323. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27324. **/
  27325. enableOfflineSupport: boolean;
  27326. /**
  27327. * 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)
  27328. **/
  27329. disableManifestCheck: boolean;
  27330. /**
  27331. * Gets the list of created scenes
  27332. */
  27333. scenes: Scene[];
  27334. /**
  27335. * Event raised when a new scene is created
  27336. */
  27337. onNewSceneAddedObservable: Observable<Scene>;
  27338. /**
  27339. * Gets the list of created postprocesses
  27340. */
  27341. postProcesses: PostProcess[];
  27342. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27343. validateShaderPrograms: boolean;
  27344. /**
  27345. * Observable event triggered each time the rendering canvas is resized
  27346. */
  27347. onResizeObservable: Observable<Engine>;
  27348. /**
  27349. * Observable event triggered each time the canvas loses focus
  27350. */
  27351. onCanvasBlurObservable: Observable<Engine>;
  27352. /**
  27353. * Observable event triggered each time the canvas gains focus
  27354. */
  27355. onCanvasFocusObservable: Observable<Engine>;
  27356. /**
  27357. * Observable event triggered each time the canvas receives pointerout event
  27358. */
  27359. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27360. /**
  27361. * Observable event triggered before each texture is initialized
  27362. */
  27363. onBeforeTextureInitObservable: Observable<Texture>;
  27364. private _vrDisplay;
  27365. private _vrSupported;
  27366. private _oldSize;
  27367. private _oldHardwareScaleFactor;
  27368. private _vrExclusivePointerMode;
  27369. private _webVRInitPromise;
  27370. /**
  27371. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27372. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27373. */
  27374. readonly isInVRExclusivePointerMode: boolean;
  27375. /**
  27376. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27377. */
  27378. disableUniformBuffers: boolean;
  27379. /** @hidden */
  27380. _uniformBuffers: UniformBuffer[];
  27381. /**
  27382. * Gets a boolean indicating that the engine supports uniform buffers
  27383. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27384. */
  27385. readonly supportsUniformBuffers: boolean;
  27386. /**
  27387. * Observable raised when the engine begins a new frame
  27388. */
  27389. onBeginFrameObservable: Observable<Engine>;
  27390. /**
  27391. * If set, will be used to request the next animation frame for the render loop
  27392. */
  27393. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27394. /**
  27395. * Observable raised when the engine ends the current frame
  27396. */
  27397. onEndFrameObservable: Observable<Engine>;
  27398. /**
  27399. * Observable raised when the engine is about to compile a shader
  27400. */
  27401. onBeforeShaderCompilationObservable: Observable<Engine>;
  27402. /**
  27403. * Observable raised when the engine has jsut compiled a shader
  27404. */
  27405. onAfterShaderCompilationObservable: Observable<Engine>;
  27406. /** @hidden */
  27407. _gl: WebGLRenderingContext;
  27408. private _renderingCanvas;
  27409. private _windowIsBackground;
  27410. private _webGLVersion;
  27411. protected _highPrecisionShadersAllowed: boolean;
  27412. /** @hidden */
  27413. readonly _shouldUseHighPrecisionShader: boolean;
  27414. /**
  27415. * Gets a boolean indicating that only power of 2 textures are supported
  27416. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27417. */
  27418. readonly needPOTTextures: boolean;
  27419. /** @hidden */
  27420. _badOS: boolean;
  27421. /** @hidden */
  27422. _badDesktopOS: boolean;
  27423. /**
  27424. * Gets the audio engine
  27425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27426. * @ignorenaming
  27427. */
  27428. static audioEngine: IAudioEngine;
  27429. /**
  27430. * Default AudioEngine factory responsible of creating the Audio Engine.
  27431. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27432. */
  27433. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27434. /**
  27435. * Default offline support factory responsible of creating a tool used to store data locally.
  27436. * By default, this will create a Database object if the workload has been embedded.
  27437. */
  27438. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27439. private _onFocus;
  27440. private _onBlur;
  27441. private _onCanvasPointerOut;
  27442. private _onCanvasBlur;
  27443. private _onCanvasFocus;
  27444. private _onFullscreenChange;
  27445. private _onPointerLockChange;
  27446. private _onVRDisplayPointerRestricted;
  27447. private _onVRDisplayPointerUnrestricted;
  27448. private _onVrDisplayConnect;
  27449. private _onVrDisplayDisconnect;
  27450. private _onVrDisplayPresentChange;
  27451. /**
  27452. * Observable signaled when VR display mode changes
  27453. */
  27454. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27455. /**
  27456. * Observable signaled when VR request present is complete
  27457. */
  27458. onVRRequestPresentComplete: Observable<boolean>;
  27459. /**
  27460. * Observable signaled when VR request present starts
  27461. */
  27462. onVRRequestPresentStart: Observable<Engine>;
  27463. private _hardwareScalingLevel;
  27464. /** @hidden */
  27465. _caps: EngineCapabilities;
  27466. private _pointerLockRequested;
  27467. private _isStencilEnable;
  27468. private _colorWrite;
  27469. private _loadingScreen;
  27470. /** @hidden */
  27471. _drawCalls: PerfCounter;
  27472. private _glVersion;
  27473. private _glRenderer;
  27474. private _glVendor;
  27475. private _videoTextureSupported;
  27476. private _renderingQueueLaunched;
  27477. private _activeRenderLoops;
  27478. private _deterministicLockstep;
  27479. private _lockstepMaxSteps;
  27480. /**
  27481. * Observable signaled when a context lost event is raised
  27482. */
  27483. onContextLostObservable: Observable<Engine>;
  27484. /**
  27485. * Observable signaled when a context restored event is raised
  27486. */
  27487. onContextRestoredObservable: Observable<Engine>;
  27488. private _onContextLost;
  27489. private _onContextRestored;
  27490. private _contextWasLost;
  27491. /** @hidden */
  27492. _doNotHandleContextLost: boolean;
  27493. /**
  27494. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27496. */
  27497. doNotHandleContextLost: boolean;
  27498. private _performanceMonitor;
  27499. private _fps;
  27500. private _deltaTime;
  27501. /**
  27502. * Turn this value on if you want to pause FPS computation when in background
  27503. */
  27504. disablePerformanceMonitorInBackground: boolean;
  27505. /**
  27506. * Gets the performance monitor attached to this engine
  27507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27508. */
  27509. readonly performanceMonitor: PerformanceMonitor;
  27510. /**
  27511. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27512. */
  27513. disableVertexArrayObjects: boolean;
  27514. /** @hidden */
  27515. protected _depthCullingState: _DepthCullingState;
  27516. /** @hidden */
  27517. protected _stencilState: _StencilState;
  27518. /** @hidden */
  27519. protected _alphaState: _AlphaState;
  27520. /** @hidden */
  27521. protected _alphaMode: number;
  27522. /** @hidden */
  27523. _internalTexturesCache: InternalTexture[];
  27524. /** @hidden */
  27525. protected _activeChannel: number;
  27526. private _currentTextureChannel;
  27527. /** @hidden */
  27528. protected _boundTexturesCache: {
  27529. [key: string]: Nullable<InternalTexture>;
  27530. };
  27531. /** @hidden */
  27532. protected _currentEffect: Nullable<Effect>;
  27533. /** @hidden */
  27534. protected _currentProgram: Nullable<WebGLProgram>;
  27535. private _compiledEffects;
  27536. private _vertexAttribArraysEnabled;
  27537. /** @hidden */
  27538. protected _cachedViewport: Nullable<Viewport>;
  27539. private _cachedVertexArrayObject;
  27540. /** @hidden */
  27541. protected _cachedVertexBuffers: any;
  27542. /** @hidden */
  27543. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27544. /** @hidden */
  27545. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27546. /** @hidden */
  27547. protected _currentRenderTarget: Nullable<InternalTexture>;
  27548. private _uintIndicesCurrentlySet;
  27549. private _currentBoundBuffer;
  27550. /** @hidden */
  27551. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27552. private _currentBufferPointers;
  27553. private _currentInstanceLocations;
  27554. private _currentInstanceBuffers;
  27555. private _textureUnits;
  27556. private _workingCanvas;
  27557. private _workingContext;
  27558. private _rescalePostProcess;
  27559. private _dummyFramebuffer;
  27560. private _externalData;
  27561. private _bindedRenderFunction;
  27562. private _vaoRecordInProgress;
  27563. private _mustWipeVertexAttributes;
  27564. private _emptyTexture;
  27565. private _emptyCubeTexture;
  27566. private _emptyTexture3D;
  27567. /** @hidden */
  27568. _frameHandler: number;
  27569. private _nextFreeTextureSlots;
  27570. private _maxSimultaneousTextures;
  27571. private _activeRequests;
  27572. private _texturesSupported;
  27573. private _textureFormatInUse;
  27574. /**
  27575. * Gets the list of texture formats supported
  27576. */
  27577. readonly texturesSupported: Array<string>;
  27578. /**
  27579. * Gets the list of texture formats in use
  27580. */
  27581. readonly textureFormatInUse: Nullable<string>;
  27582. /**
  27583. * Gets the current viewport
  27584. */
  27585. readonly currentViewport: Nullable<Viewport>;
  27586. /**
  27587. * Gets the default empty texture
  27588. */
  27589. readonly emptyTexture: InternalTexture;
  27590. /**
  27591. * Gets the default empty 3D texture
  27592. */
  27593. readonly emptyTexture3D: InternalTexture;
  27594. /**
  27595. * Gets the default empty cube texture
  27596. */
  27597. readonly emptyCubeTexture: InternalTexture;
  27598. /**
  27599. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27600. */
  27601. readonly premultipliedAlpha: boolean;
  27602. /**
  27603. * Creates a new engine
  27604. * @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
  27605. * @param antialias defines enable antialiasing (default: false)
  27606. * @param options defines further options to be sent to the getContext() function
  27607. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27608. */
  27609. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27610. private _disableTouchAction;
  27611. private _rebuildInternalTextures;
  27612. private _rebuildEffects;
  27613. /**
  27614. * Gets a boolean indicating if all created effects are ready
  27615. * @returns true if all effects are ready
  27616. */
  27617. areAllEffectsReady(): boolean;
  27618. private _rebuildBuffers;
  27619. private _initGLContext;
  27620. /**
  27621. * Gets version of the current webGL context
  27622. */
  27623. readonly webGLVersion: number;
  27624. /**
  27625. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27626. */
  27627. readonly isStencilEnable: boolean;
  27628. private _prepareWorkingCanvas;
  27629. /**
  27630. * Reset the texture cache to empty state
  27631. */
  27632. resetTextureCache(): void;
  27633. /**
  27634. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27636. * @returns true if engine is in deterministic lock step mode
  27637. */
  27638. isDeterministicLockStep(): boolean;
  27639. /**
  27640. * Gets the max steps when engine is running in deterministic lock step
  27641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27642. * @returns the max steps
  27643. */
  27644. getLockstepMaxSteps(): number;
  27645. /**
  27646. * Gets an object containing information about the current webGL context
  27647. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27648. */
  27649. getGlInfo(): {
  27650. vendor: string;
  27651. renderer: string;
  27652. version: string;
  27653. };
  27654. /**
  27655. * Gets current aspect ratio
  27656. * @param camera defines the camera to use to get the aspect ratio
  27657. * @param useScreen defines if screen size must be used (or the current render target if any)
  27658. * @returns a number defining the aspect ratio
  27659. */
  27660. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27661. /**
  27662. * Gets current screen aspect ratio
  27663. * @returns a number defining the aspect ratio
  27664. */
  27665. getScreenAspectRatio(): number;
  27666. /**
  27667. * Gets the current render width
  27668. * @param useScreen defines if screen size must be used (or the current render target if any)
  27669. * @returns a number defining the current render width
  27670. */
  27671. getRenderWidth(useScreen?: boolean): number;
  27672. /**
  27673. * Gets the current render height
  27674. * @param useScreen defines if screen size must be used (or the current render target if any)
  27675. * @returns a number defining the current render height
  27676. */
  27677. getRenderHeight(useScreen?: boolean): number;
  27678. /**
  27679. * Gets the HTML canvas attached with the current webGL context
  27680. * @returns a HTML canvas
  27681. */
  27682. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27683. /**
  27684. * Gets the client rect of the HTML canvas attached with the current webGL context
  27685. * @returns a client rectanglee
  27686. */
  27687. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27688. /**
  27689. * Defines the hardware scaling level.
  27690. * By default the hardware scaling level is computed from the window device ratio.
  27691. * 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.
  27692. * @param level defines the level to use
  27693. */
  27694. setHardwareScalingLevel(level: number): void;
  27695. /**
  27696. * Gets the current hardware scaling level.
  27697. * By default the hardware scaling level is computed from the window device ratio.
  27698. * 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.
  27699. * @returns a number indicating the current hardware scaling level
  27700. */
  27701. getHardwareScalingLevel(): number;
  27702. /**
  27703. * Gets the list of loaded textures
  27704. * @returns an array containing all loaded textures
  27705. */
  27706. getLoadedTexturesCache(): InternalTexture[];
  27707. /**
  27708. * Gets the object containing all engine capabilities
  27709. * @returns the EngineCapabilities object
  27710. */
  27711. getCaps(): EngineCapabilities;
  27712. /**
  27713. * Gets the current depth function
  27714. * @returns a number defining the depth function
  27715. */
  27716. getDepthFunction(): Nullable<number>;
  27717. /**
  27718. * Sets the current depth function
  27719. * @param depthFunc defines the function to use
  27720. */
  27721. setDepthFunction(depthFunc: number): void;
  27722. /**
  27723. * Sets the current depth function to GREATER
  27724. */
  27725. setDepthFunctionToGreater(): void;
  27726. /**
  27727. * Sets the current depth function to GEQUAL
  27728. */
  27729. setDepthFunctionToGreaterOrEqual(): void;
  27730. /**
  27731. * Sets the current depth function to LESS
  27732. */
  27733. setDepthFunctionToLess(): void;
  27734. private _cachedStencilBuffer;
  27735. private _cachedStencilFunction;
  27736. private _cachedStencilMask;
  27737. private _cachedStencilOperationPass;
  27738. private _cachedStencilOperationFail;
  27739. private _cachedStencilOperationDepthFail;
  27740. private _cachedStencilReference;
  27741. /**
  27742. * Caches the the state of the stencil buffer
  27743. */
  27744. cacheStencilState(): void;
  27745. /**
  27746. * Restores the state of the stencil buffer
  27747. */
  27748. restoreStencilState(): void;
  27749. /**
  27750. * Sets the current depth function to LEQUAL
  27751. */
  27752. setDepthFunctionToLessOrEqual(): void;
  27753. /**
  27754. * Gets a boolean indicating if stencil buffer is enabled
  27755. * @returns the current stencil buffer state
  27756. */
  27757. getStencilBuffer(): boolean;
  27758. /**
  27759. * Enable or disable the stencil buffer
  27760. * @param enable defines if the stencil buffer must be enabled or disabled
  27761. */
  27762. setStencilBuffer(enable: boolean): void;
  27763. /**
  27764. * Gets the current stencil mask
  27765. * @returns a number defining the new stencil mask to use
  27766. */
  27767. getStencilMask(): number;
  27768. /**
  27769. * Sets the current stencil mask
  27770. * @param mask defines the new stencil mask to use
  27771. */
  27772. setStencilMask(mask: number): void;
  27773. /**
  27774. * Gets the current stencil function
  27775. * @returns a number defining the stencil function to use
  27776. */
  27777. getStencilFunction(): number;
  27778. /**
  27779. * Gets the current stencil reference value
  27780. * @returns a number defining the stencil reference value to use
  27781. */
  27782. getStencilFunctionReference(): number;
  27783. /**
  27784. * Gets the current stencil mask
  27785. * @returns a number defining the stencil mask to use
  27786. */
  27787. getStencilFunctionMask(): number;
  27788. /**
  27789. * Sets the current stencil function
  27790. * @param stencilFunc defines the new stencil function to use
  27791. */
  27792. setStencilFunction(stencilFunc: number): void;
  27793. /**
  27794. * Sets the current stencil reference
  27795. * @param reference defines the new stencil reference to use
  27796. */
  27797. setStencilFunctionReference(reference: number): void;
  27798. /**
  27799. * Sets the current stencil mask
  27800. * @param mask defines the new stencil mask to use
  27801. */
  27802. setStencilFunctionMask(mask: number): void;
  27803. /**
  27804. * Gets the current stencil operation when stencil fails
  27805. * @returns a number defining stencil operation to use when stencil fails
  27806. */
  27807. getStencilOperationFail(): number;
  27808. /**
  27809. * Gets the current stencil operation when depth fails
  27810. * @returns a number defining stencil operation to use when depth fails
  27811. */
  27812. getStencilOperationDepthFail(): number;
  27813. /**
  27814. * Gets the current stencil operation when stencil passes
  27815. * @returns a number defining stencil operation to use when stencil passes
  27816. */
  27817. getStencilOperationPass(): number;
  27818. /**
  27819. * Sets the stencil operation to use when stencil fails
  27820. * @param operation defines the stencil operation to use when stencil fails
  27821. */
  27822. setStencilOperationFail(operation: number): void;
  27823. /**
  27824. * Sets the stencil operation to use when depth fails
  27825. * @param operation defines the stencil operation to use when depth fails
  27826. */
  27827. setStencilOperationDepthFail(operation: number): void;
  27828. /**
  27829. * Sets the stencil operation to use when stencil passes
  27830. * @param operation defines the stencil operation to use when stencil passes
  27831. */
  27832. setStencilOperationPass(operation: number): void;
  27833. /**
  27834. * Sets a boolean indicating if the dithering state is enabled or disabled
  27835. * @param value defines the dithering state
  27836. */
  27837. setDitheringState(value: boolean): void;
  27838. /**
  27839. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27840. * @param value defines the rasterizer state
  27841. */
  27842. setRasterizerState(value: boolean): void;
  27843. /**
  27844. * stop executing a render loop function and remove it from the execution array
  27845. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27846. */
  27847. stopRenderLoop(renderFunction?: () => void): void;
  27848. /** @hidden */
  27849. _renderLoop(): void;
  27850. /**
  27851. * Register and execute a render loop. The engine can have more than one render function
  27852. * @param renderFunction defines the function to continuously execute
  27853. */
  27854. runRenderLoop(renderFunction: () => void): void;
  27855. /**
  27856. * Toggle full screen mode
  27857. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27858. */
  27859. switchFullscreen(requestPointerLock: boolean): void;
  27860. /**
  27861. * Enters full screen mode
  27862. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27863. */
  27864. enterFullscreen(requestPointerLock: boolean): void;
  27865. /**
  27866. * Exits full screen mode
  27867. */
  27868. exitFullscreen(): void;
  27869. /**
  27870. * Clear the current render buffer or the current render target (if any is set up)
  27871. * @param color defines the color to use
  27872. * @param backBuffer defines if the back buffer must be cleared
  27873. * @param depth defines if the depth buffer must be cleared
  27874. * @param stencil defines if the stencil buffer must be cleared
  27875. */
  27876. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27877. /**
  27878. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27879. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27880. * @param y defines the y-coordinate of the corner of the clear rectangle
  27881. * @param width defines the width of the clear rectangle
  27882. * @param height defines the height of the clear rectangle
  27883. * @param clearColor defines the clear color
  27884. */
  27885. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27886. /**
  27887. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27888. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27889. * @param y defines the y-coordinate of the corner of the clear rectangle
  27890. * @param width defines the width of the clear rectangle
  27891. * @param height defines the height of the clear rectangle
  27892. */
  27893. enableScissor(x: number, y: number, width: number, height: number): void;
  27894. /**
  27895. * Disable previously set scissor test rectangle
  27896. */
  27897. disableScissor(): void;
  27898. private _viewportCached;
  27899. /** @hidden */
  27900. _viewport(x: number, y: number, width: number, height: number): void;
  27901. /**
  27902. * Set the WebGL's viewport
  27903. * @param viewport defines the viewport element to be used
  27904. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27905. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27906. */
  27907. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27908. /**
  27909. * Directly set the WebGL Viewport
  27910. * @param x defines the x coordinate of the viewport (in screen space)
  27911. * @param y defines the y coordinate of the viewport (in screen space)
  27912. * @param width defines the width of the viewport (in screen space)
  27913. * @param height defines the height of the viewport (in screen space)
  27914. * @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
  27915. */
  27916. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27917. /**
  27918. * Begin a new frame
  27919. */
  27920. beginFrame(): void;
  27921. /**
  27922. * Enf the current frame
  27923. */
  27924. endFrame(): void;
  27925. /**
  27926. * Resize the view according to the canvas' size
  27927. */
  27928. resize(): void;
  27929. /**
  27930. * Force a specific size of the canvas
  27931. * @param width defines the new canvas' width
  27932. * @param height defines the new canvas' height
  27933. */
  27934. setSize(width: number, height: number): void;
  27935. /**
  27936. * Gets a boolean indicating if a webVR device was detected
  27937. * @returns true if a webVR device was detected
  27938. */
  27939. isVRDevicePresent(): boolean;
  27940. /**
  27941. * Gets the current webVR device
  27942. * @returns the current webVR device (or null)
  27943. */
  27944. getVRDevice(): any;
  27945. /**
  27946. * Initializes a webVR display and starts listening to display change events
  27947. * The onVRDisplayChangedObservable will be notified upon these changes
  27948. * @returns The onVRDisplayChangedObservable
  27949. */
  27950. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27951. /**
  27952. * Initializes a webVR display and starts listening to display change events
  27953. * The onVRDisplayChangedObservable will be notified upon these changes
  27954. * @returns A promise containing a VRDisplay and if vr is supported
  27955. */
  27956. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27957. /**
  27958. * Call this function to switch to webVR mode
  27959. * Will do nothing if webVR is not supported or if there is no webVR device
  27960. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27961. */
  27962. enableVR(): void;
  27963. /**
  27964. * Call this function to leave webVR mode
  27965. * Will do nothing if webVR is not supported or if there is no webVR device
  27966. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27967. */
  27968. disableVR(): void;
  27969. private _onVRFullScreenTriggered;
  27970. private _getVRDisplaysAsync;
  27971. /**
  27972. * Binds the frame buffer to the specified texture.
  27973. * @param texture The texture to render to or null for the default canvas
  27974. * @param faceIndex The face of the texture to render to in case of cube texture
  27975. * @param requiredWidth The width of the target to render to
  27976. * @param requiredHeight The height of the target to render to
  27977. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27978. * @param depthStencilTexture The depth stencil texture to use to render
  27979. * @param lodLevel defines le lod level to bind to the frame buffer
  27980. */
  27981. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27982. private bindUnboundFramebuffer;
  27983. /**
  27984. * Unbind the current render target texture from the webGL context
  27985. * @param texture defines the render target texture to unbind
  27986. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27987. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27988. */
  27989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27990. /**
  27991. * Unbind a list of render target textures from the webGL context
  27992. * This is used only when drawBuffer extension or webGL2 are active
  27993. * @param textures defines the render target textures to unbind
  27994. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27995. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27996. */
  27997. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27998. /**
  27999. * Force the mipmap generation for the given render target texture
  28000. * @param texture defines the render target texture to use
  28001. */
  28002. generateMipMapsForCubemap(texture: InternalTexture): void;
  28003. /**
  28004. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28005. */
  28006. flushFramebuffer(): void;
  28007. /**
  28008. * Unbind the current render target and bind the default framebuffer
  28009. */
  28010. restoreDefaultFramebuffer(): void;
  28011. /**
  28012. * Create an uniform buffer
  28013. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28014. * @param elements defines the content of the uniform buffer
  28015. * @returns the webGL uniform buffer
  28016. */
  28017. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28018. /**
  28019. * Create a dynamic uniform buffer
  28020. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28021. * @param elements defines the content of the uniform buffer
  28022. * @returns the webGL uniform buffer
  28023. */
  28024. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28025. /**
  28026. * Update an existing uniform buffer
  28027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28028. * @param uniformBuffer defines the target uniform buffer
  28029. * @param elements defines the content to update
  28030. * @param offset defines the offset in the uniform buffer where update should start
  28031. * @param count defines the size of the data to update
  28032. */
  28033. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28034. private _resetVertexBufferBinding;
  28035. /**
  28036. * Creates a vertex buffer
  28037. * @param data the data for the vertex buffer
  28038. * @returns the new WebGL static buffer
  28039. */
  28040. createVertexBuffer(data: DataArray): WebGLBuffer;
  28041. /**
  28042. * Creates a dynamic vertex buffer
  28043. * @param data the data for the dynamic vertex buffer
  28044. * @returns the new WebGL dynamic buffer
  28045. */
  28046. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28047. /**
  28048. * Update a dynamic index buffer
  28049. * @param indexBuffer defines the target index buffer
  28050. * @param indices defines the data to update
  28051. * @param offset defines the offset in the target index buffer where update should start
  28052. */
  28053. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28054. /**
  28055. * Updates a dynamic vertex buffer.
  28056. * @param vertexBuffer the vertex buffer to update
  28057. * @param data the data used to update the vertex buffer
  28058. * @param byteOffset the byte offset of the data
  28059. * @param byteLength the byte length of the data
  28060. */
  28061. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28062. private _resetIndexBufferBinding;
  28063. /**
  28064. * Creates a new index buffer
  28065. * @param indices defines the content of the index buffer
  28066. * @param updatable defines if the index buffer must be updatable
  28067. * @returns a new webGL buffer
  28068. */
  28069. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28070. /**
  28071. * Bind a webGL buffer to the webGL context
  28072. * @param buffer defines the buffer to bind
  28073. */
  28074. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28075. /**
  28076. * Bind an uniform buffer to the current webGL context
  28077. * @param buffer defines the buffer to bind
  28078. */
  28079. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28080. /**
  28081. * Bind a buffer to the current webGL context at a given location
  28082. * @param buffer defines the buffer to bind
  28083. * @param location defines the index where to bind the buffer
  28084. */
  28085. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28086. /**
  28087. * Bind a specific block at a given index in a specific shader program
  28088. * @param shaderProgram defines the shader program
  28089. * @param blockName defines the block name
  28090. * @param index defines the index where to bind the block
  28091. */
  28092. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28093. private bindIndexBuffer;
  28094. private bindBuffer;
  28095. /**
  28096. * update the bound buffer with the given data
  28097. * @param data defines the data to update
  28098. */
  28099. updateArrayBuffer(data: Float32Array): void;
  28100. private _vertexAttribPointer;
  28101. private _bindIndexBufferWithCache;
  28102. private _bindVertexBuffersAttributes;
  28103. /**
  28104. * Records a vertex array object
  28105. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28106. * @param vertexBuffers defines the list of vertex buffers to store
  28107. * @param indexBuffer defines the index buffer to store
  28108. * @param effect defines the effect to store
  28109. * @returns the new vertex array object
  28110. */
  28111. recordVertexArrayObject(vertexBuffers: {
  28112. [key: string]: VertexBuffer;
  28113. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28114. /**
  28115. * Bind a specific vertex array object
  28116. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28117. * @param vertexArrayObject defines the vertex array object to bind
  28118. * @param indexBuffer defines the index buffer to bind
  28119. */
  28120. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28121. /**
  28122. * Bind webGl buffers directly to the webGL context
  28123. * @param vertexBuffer defines the vertex buffer to bind
  28124. * @param indexBuffer defines the index buffer to bind
  28125. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28126. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28127. * @param effect defines the effect associated with the vertex buffer
  28128. */
  28129. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28130. private _unbindVertexArrayObject;
  28131. /**
  28132. * Bind a list of vertex buffers to the webGL context
  28133. * @param vertexBuffers defines the list of vertex buffers to bind
  28134. * @param indexBuffer defines the index buffer to bind
  28135. * @param effect defines the effect associated with the vertex buffers
  28136. */
  28137. bindBuffers(vertexBuffers: {
  28138. [key: string]: Nullable<VertexBuffer>;
  28139. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28140. /**
  28141. * Unbind all instance attributes
  28142. */
  28143. unbindInstanceAttributes(): void;
  28144. /**
  28145. * Release and free the memory of a vertex array object
  28146. * @param vao defines the vertex array object to delete
  28147. */
  28148. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28149. /** @hidden */
  28150. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28151. /**
  28152. * Creates a webGL buffer to use with instanciation
  28153. * @param capacity defines the size of the buffer
  28154. * @returns the webGL buffer
  28155. */
  28156. createInstancesBuffer(capacity: number): WebGLBuffer;
  28157. /**
  28158. * Delete a webGL buffer used with instanciation
  28159. * @param buffer defines the webGL buffer to delete
  28160. */
  28161. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28162. /**
  28163. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28164. * @param instancesBuffer defines the webGL buffer to update and bind
  28165. * @param data defines the data to store in the buffer
  28166. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28167. */
  28168. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28169. /**
  28170. * Apply all cached states (depth, culling, stencil and alpha)
  28171. */
  28172. applyStates(): void;
  28173. /**
  28174. * Send a draw order
  28175. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28176. * @param indexStart defines the starting index
  28177. * @param indexCount defines the number of index to draw
  28178. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28179. */
  28180. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28181. /**
  28182. * Draw a list of points
  28183. * @param verticesStart defines the index of first vertex to draw
  28184. * @param verticesCount defines the count of vertices to draw
  28185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28186. */
  28187. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28188. /**
  28189. * Draw a list of unindexed primitives
  28190. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28191. * @param verticesStart defines the index of first vertex to draw
  28192. * @param verticesCount defines the count of vertices to draw
  28193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28194. */
  28195. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28196. /**
  28197. * Draw a list of indexed primitives
  28198. * @param fillMode defines the primitive to use
  28199. * @param indexStart defines the starting index
  28200. * @param indexCount defines the number of index to draw
  28201. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28202. */
  28203. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28204. /**
  28205. * Draw a list of unindexed primitives
  28206. * @param fillMode defines the primitive to use
  28207. * @param verticesStart defines the index of first vertex to draw
  28208. * @param verticesCount defines the count of vertices to draw
  28209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28210. */
  28211. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28212. private _drawMode;
  28213. /** @hidden */
  28214. _releaseEffect(effect: Effect): void;
  28215. /** @hidden */
  28216. _deleteProgram(program: WebGLProgram): void;
  28217. /**
  28218. * Create a new effect (used to store vertex/fragment shaders)
  28219. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28220. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28221. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28222. * @param samplers defines an array of string used to represent textures
  28223. * @param defines defines the string containing the defines to use to compile the shaders
  28224. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28225. * @param onCompiled defines a function to call when the effect creation is successful
  28226. * @param onError defines a function to call when the effect creation has failed
  28227. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28228. * @returns the new Effect
  28229. */
  28230. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28231. private _compileShader;
  28232. private _compileRawShader;
  28233. /**
  28234. * Directly creates a webGL program
  28235. * @param vertexCode defines the vertex shader code to use
  28236. * @param fragmentCode defines the fragment shader code to use
  28237. * @param context defines the webGL context to use (if not set, the current one will be used)
  28238. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28239. * @returns the new webGL program
  28240. */
  28241. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28242. /**
  28243. * Creates a webGL program
  28244. * @param vertexCode defines the vertex shader code to use
  28245. * @param fragmentCode defines the fragment shader code to use
  28246. * @param defines defines the string containing the defines to use to compile the shaders
  28247. * @param context defines the webGL context to use (if not set, the current one will be used)
  28248. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28249. * @returns the new webGL program
  28250. */
  28251. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28252. private _createShaderProgram;
  28253. private _finalizeProgram;
  28254. /** @hidden */
  28255. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28256. /** @hidden */
  28257. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28258. /**
  28259. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28260. * @param shaderProgram defines the webGL program to use
  28261. * @param uniformsNames defines the list of uniform names
  28262. * @returns an array of webGL uniform locations
  28263. */
  28264. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28265. /**
  28266. * Gets the lsit of active attributes for a given webGL program
  28267. * @param shaderProgram defines the webGL program to use
  28268. * @param attributesNames defines the list of attribute names to get
  28269. * @returns an array of indices indicating the offset of each attribute
  28270. */
  28271. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28272. /**
  28273. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28274. * @param effect defines the effect to activate
  28275. */
  28276. enableEffect(effect: Nullable<Effect>): void;
  28277. /**
  28278. * Set the value of an uniform to an array of int32
  28279. * @param uniform defines the webGL uniform location where to store the value
  28280. * @param array defines the array of int32 to store
  28281. */
  28282. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28283. /**
  28284. * Set the value of an uniform to an array of int32 (stored as vec2)
  28285. * @param uniform defines the webGL uniform location where to store the value
  28286. * @param array defines the array of int32 to store
  28287. */
  28288. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28289. /**
  28290. * Set the value of an uniform to an array of int32 (stored as vec3)
  28291. * @param uniform defines the webGL uniform location where to store the value
  28292. * @param array defines the array of int32 to store
  28293. */
  28294. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28295. /**
  28296. * Set the value of an uniform to an array of int32 (stored as vec4)
  28297. * @param uniform defines the webGL uniform location where to store the value
  28298. * @param array defines the array of int32 to store
  28299. */
  28300. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28301. /**
  28302. * Set the value of an uniform to an array of float32
  28303. * @param uniform defines the webGL uniform location where to store the value
  28304. * @param array defines the array of float32 to store
  28305. */
  28306. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28307. /**
  28308. * Set the value of an uniform to an array of float32 (stored as vec2)
  28309. * @param uniform defines the webGL uniform location where to store the value
  28310. * @param array defines the array of float32 to store
  28311. */
  28312. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28313. /**
  28314. * Set the value of an uniform to an array of float32 (stored as vec3)
  28315. * @param uniform defines the webGL uniform location where to store the value
  28316. * @param array defines the array of float32 to store
  28317. */
  28318. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28319. /**
  28320. * Set the value of an uniform to an array of float32 (stored as vec4)
  28321. * @param uniform defines the webGL uniform location where to store the value
  28322. * @param array defines the array of float32 to store
  28323. */
  28324. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28325. /**
  28326. * Set the value of an uniform to an array of number
  28327. * @param uniform defines the webGL uniform location where to store the value
  28328. * @param array defines the array of number to store
  28329. */
  28330. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28331. /**
  28332. * Set the value of an uniform to an array of number (stored as vec2)
  28333. * @param uniform defines the webGL uniform location where to store the value
  28334. * @param array defines the array of number to store
  28335. */
  28336. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28337. /**
  28338. * Set the value of an uniform to an array of number (stored as vec3)
  28339. * @param uniform defines the webGL uniform location where to store the value
  28340. * @param array defines the array of number to store
  28341. */
  28342. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28343. /**
  28344. * Set the value of an uniform to an array of number (stored as vec4)
  28345. * @param uniform defines the webGL uniform location where to store the value
  28346. * @param array defines the array of number to store
  28347. */
  28348. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28349. /**
  28350. * Set the value of an uniform to an array of float32 (stored as matrices)
  28351. * @param uniform defines the webGL uniform location where to store the value
  28352. * @param matrices defines the array of float32 to store
  28353. */
  28354. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28355. /**
  28356. * Set the value of an uniform to a matrix
  28357. * @param uniform defines the webGL uniform location where to store the value
  28358. * @param matrix defines the matrix to store
  28359. */
  28360. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28361. /**
  28362. * Set the value of an uniform to a matrix (3x3)
  28363. * @param uniform defines the webGL uniform location where to store the value
  28364. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28365. */
  28366. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28367. /**
  28368. * Set the value of an uniform to a matrix (2x2)
  28369. * @param uniform defines the webGL uniform location where to store the value
  28370. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28371. */
  28372. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28373. /**
  28374. * Set the value of an uniform to a number (int)
  28375. * @param uniform defines the webGL uniform location where to store the value
  28376. * @param value defines the int number to store
  28377. */
  28378. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28379. /**
  28380. * Set the value of an uniform to a number (float)
  28381. * @param uniform defines the webGL uniform location where to store the value
  28382. * @param value defines the float number to store
  28383. */
  28384. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28385. /**
  28386. * Set the value of an uniform to a vec2
  28387. * @param uniform defines the webGL uniform location where to store the value
  28388. * @param x defines the 1st component of the value
  28389. * @param y defines the 2nd component of the value
  28390. */
  28391. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28392. /**
  28393. * Set the value of an uniform to a vec3
  28394. * @param uniform defines the webGL uniform location where to store the value
  28395. * @param x defines the 1st component of the value
  28396. * @param y defines the 2nd component of the value
  28397. * @param z defines the 3rd component of the value
  28398. */
  28399. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28400. /**
  28401. * Set the value of an uniform to a boolean
  28402. * @param uniform defines the webGL uniform location where to store the value
  28403. * @param bool defines the boolean to store
  28404. */
  28405. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28406. /**
  28407. * Set the value of an uniform to a vec4
  28408. * @param uniform defines the webGL uniform location where to store the value
  28409. * @param x defines the 1st component of the value
  28410. * @param y defines the 2nd component of the value
  28411. * @param z defines the 3rd component of the value
  28412. * @param w defines the 4th component of the value
  28413. */
  28414. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28415. /**
  28416. * Set the value of an uniform to a Color3
  28417. * @param uniform defines the webGL uniform location where to store the value
  28418. * @param color3 defines the color to store
  28419. */
  28420. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28421. /**
  28422. * Set the value of an uniform to a Color3 and an alpha value
  28423. * @param uniform defines the webGL uniform location where to store the value
  28424. * @param color3 defines the color to store
  28425. * @param alpha defines the alpha component to store
  28426. */
  28427. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28428. /**
  28429. * Sets a Color4 on a uniform variable
  28430. * @param uniform defines the uniform location
  28431. * @param color4 defines the value to be set
  28432. */
  28433. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28434. /**
  28435. * Set various states to the webGL context
  28436. * @param culling defines backface culling state
  28437. * @param zOffset defines the value to apply to zOffset (0 by default)
  28438. * @param force defines if states must be applied even if cache is up to date
  28439. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28440. */
  28441. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28442. /**
  28443. * Set the z offset to apply to current rendering
  28444. * @param value defines the offset to apply
  28445. */
  28446. setZOffset(value: number): void;
  28447. /**
  28448. * Gets the current value of the zOffset
  28449. * @returns the current zOffset state
  28450. */
  28451. getZOffset(): number;
  28452. /**
  28453. * Enable or disable depth buffering
  28454. * @param enable defines the state to set
  28455. */
  28456. setDepthBuffer(enable: boolean): void;
  28457. /**
  28458. * Gets a boolean indicating if depth writing is enabled
  28459. * @returns the current depth writing state
  28460. */
  28461. getDepthWrite(): boolean;
  28462. /**
  28463. * Enable or disable depth writing
  28464. * @param enable defines the state to set
  28465. */
  28466. setDepthWrite(enable: boolean): void;
  28467. /**
  28468. * Enable or disable color writing
  28469. * @param enable defines the state to set
  28470. */
  28471. setColorWrite(enable: boolean): void;
  28472. /**
  28473. * Gets a boolean indicating if color writing is enabled
  28474. * @returns the current color writing state
  28475. */
  28476. getColorWrite(): boolean;
  28477. /**
  28478. * Sets alpha constants used by some alpha blending modes
  28479. * @param r defines the red component
  28480. * @param g defines the green component
  28481. * @param b defines the blue component
  28482. * @param a defines the alpha component
  28483. */
  28484. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28485. /**
  28486. * Sets the current alpha mode
  28487. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28488. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28489. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28490. */
  28491. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28492. /**
  28493. * Gets the current alpha mode
  28494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28495. * @returns the current alpha mode
  28496. */
  28497. getAlphaMode(): number;
  28498. /**
  28499. * Clears the list of texture accessible through engine.
  28500. * This can help preventing texture load conflict due to name collision.
  28501. */
  28502. clearInternalTexturesCache(): void;
  28503. /**
  28504. * Force the entire cache to be cleared
  28505. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28506. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28507. */
  28508. wipeCaches(bruteForce?: boolean): void;
  28509. /**
  28510. * Set the compressed texture format to use, based on the formats you have, and the formats
  28511. * supported by the hardware / browser.
  28512. *
  28513. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28514. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28515. * to API arguments needed to compressed textures. This puts the burden on the container
  28516. * generator to house the arcane code for determining these for current & future formats.
  28517. *
  28518. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28519. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28520. *
  28521. * Note: The result of this call is not taken into account when a texture is base64.
  28522. *
  28523. * @param formatsAvailable defines the list of those format families you have created
  28524. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28525. *
  28526. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28527. * @returns The extension selected.
  28528. */
  28529. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28530. /** @hidden */
  28531. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28532. min: number;
  28533. mag: number;
  28534. };
  28535. private _partialLoadImg;
  28536. private _cascadeLoadImgs;
  28537. /** @hidden */
  28538. _createTexture(): WebGLTexture;
  28539. /**
  28540. * Usually called from Texture.ts.
  28541. * Passed information to create a WebGLTexture
  28542. * @param urlArg defines a value which contains one of the following:
  28543. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28544. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28545. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28546. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28547. * @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)
  28548. * @param scene needed for loading to the correct scene
  28549. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28550. * @param onLoad optional callback to be called upon successful completion
  28551. * @param onError optional callback to be called upon failure
  28552. * @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
  28553. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28554. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28555. * @param forcedExtension defines the extension to use to pick the right loader
  28556. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28557. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28558. */
  28559. 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;
  28560. private _rescaleTexture;
  28561. private _unpackFlipYCached;
  28562. /**
  28563. * In case you are sharing the context with other applications, it might
  28564. * be interested to not cache the unpack flip y state to ensure a consistent
  28565. * value would be set.
  28566. */
  28567. enableUnpackFlipYCached: boolean;
  28568. /** @hidden */
  28569. _unpackFlipY(value: boolean): void;
  28570. /** @hidden */
  28571. _getUnpackAlignement(): number;
  28572. /**
  28573. * Creates a dynamic texture
  28574. * @param width defines the width of the texture
  28575. * @param height defines the height of the texture
  28576. * @param generateMipMaps defines if the engine should generate the mip levels
  28577. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28578. * @returns the dynamic texture inside an InternalTexture
  28579. */
  28580. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28581. /**
  28582. * Update the sampling mode of a given texture
  28583. * @param samplingMode defines the required sampling mode
  28584. * @param texture defines the texture to update
  28585. */
  28586. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28587. /**
  28588. * Update the content of a dynamic texture
  28589. * @param texture defines the texture to update
  28590. * @param canvas defines the canvas containing the source
  28591. * @param invertY defines if data must be stored with Y axis inverted
  28592. * @param premulAlpha defines if alpha is stored as premultiplied
  28593. * @param format defines the format of the data
  28594. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28595. */
  28596. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28597. /**
  28598. * Update a video texture
  28599. * @param texture defines the texture to update
  28600. * @param video defines the video element to use
  28601. * @param invertY defines if data must be stored with Y axis inverted
  28602. */
  28603. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28604. /**
  28605. * Updates a depth texture Comparison Mode and Function.
  28606. * If the comparison Function is equal to 0, the mode will be set to none.
  28607. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28608. * @param texture The texture to set the comparison function for
  28609. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28610. */
  28611. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28612. private _setupDepthStencilTexture;
  28613. /**
  28614. * Creates a depth stencil texture.
  28615. * This is only available in WebGL 2 or with the depth texture extension available.
  28616. * @param size The size of face edge in the texture.
  28617. * @param options The options defining the texture.
  28618. * @returns The texture
  28619. */
  28620. createDepthStencilTexture(size: number | {
  28621. width: number;
  28622. height: number;
  28623. }, options: DepthTextureCreationOptions): InternalTexture;
  28624. /**
  28625. * Creates a depth stencil texture.
  28626. * This is only available in WebGL 2 or with the depth texture extension available.
  28627. * @param size The size of face edge in the texture.
  28628. * @param options The options defining the texture.
  28629. * @returns The texture
  28630. */
  28631. private _createDepthStencilTexture;
  28632. /**
  28633. * Creates a depth stencil cube texture.
  28634. * This is only available in WebGL 2.
  28635. * @param size The size of face edge in the cube texture.
  28636. * @param options The options defining the cube texture.
  28637. * @returns The cube texture
  28638. */
  28639. private _createDepthStencilCubeTexture;
  28640. /**
  28641. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28642. * @param renderTarget The render target to set the frame buffer for
  28643. */
  28644. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28645. /**
  28646. * Creates a new render target texture
  28647. * @param size defines the size of the texture
  28648. * @param options defines the options used to create the texture
  28649. * @returns a new render target texture stored in an InternalTexture
  28650. */
  28651. createRenderTargetTexture(size: number | {
  28652. width: number;
  28653. height: number;
  28654. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28655. /**
  28656. * Create a multi render target texture
  28657. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28658. * @param size defines the size of the texture
  28659. * @param options defines the creation options
  28660. * @returns the cube texture as an InternalTexture
  28661. */
  28662. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28663. private _setupFramebufferDepthAttachments;
  28664. /**
  28665. * Updates the sample count of a render target texture
  28666. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28667. * @param texture defines the texture to update
  28668. * @param samples defines the sample count to set
  28669. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28670. */
  28671. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28672. /**
  28673. * Update the sample count for a given multiple render target texture
  28674. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28675. * @param textures defines the textures to update
  28676. * @param samples defines the sample count to set
  28677. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28678. */
  28679. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28680. /** @hidden */
  28681. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28682. /** @hidden */
  28683. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28684. /** @hidden */
  28685. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28686. /** @hidden */
  28687. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28688. /**
  28689. * Creates a new render target cube texture
  28690. * @param size defines the size of the texture
  28691. * @param options defines the options used to create the texture
  28692. * @returns a new render target cube texture stored in an InternalTexture
  28693. */
  28694. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28695. /**
  28696. * Creates a cube texture
  28697. * @param rootUrl defines the url where the files to load is located
  28698. * @param scene defines the current scene
  28699. * @param files defines the list of files to load (1 per face)
  28700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28701. * @param onLoad defines an optional callback raised when the texture is loaded
  28702. * @param onError defines an optional callback raised if there is an issue to load the texture
  28703. * @param format defines the format of the data
  28704. * @param forcedExtension defines the extension to use to pick the right loader
  28705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28709. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28710. * @returns the cube texture as an InternalTexture
  28711. */
  28712. 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;
  28713. /**
  28714. * @hidden
  28715. */
  28716. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28717. private _prepareWebGLTextureContinuation;
  28718. private _prepareWebGLTexture;
  28719. /** @hidden */
  28720. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28721. /** @hidden */
  28722. _releaseFramebufferObjects(texture: InternalTexture): void;
  28723. /** @hidden */
  28724. _releaseTexture(texture: InternalTexture): void;
  28725. private setProgram;
  28726. private _boundUniforms;
  28727. /**
  28728. * Binds an effect to the webGL context
  28729. * @param effect defines the effect to bind
  28730. */
  28731. bindSamplers(effect: Effect): void;
  28732. private _activateCurrentTexture;
  28733. /** @hidden */
  28734. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28735. /** @hidden */
  28736. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28737. /**
  28738. * Sets a texture to the webGL context from a postprocess
  28739. * @param channel defines the channel to use
  28740. * @param postProcess defines the source postprocess
  28741. */
  28742. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28743. /**
  28744. * Binds the output of the passed in post process to the texture channel specified
  28745. * @param channel The channel the texture should be bound to
  28746. * @param postProcess The post process which's output should be bound
  28747. */
  28748. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28749. /**
  28750. * Unbind all textures from the webGL context
  28751. */
  28752. unbindAllTextures(): void;
  28753. /**
  28754. * Sets a texture to the according uniform.
  28755. * @param channel The texture channel
  28756. * @param uniform The uniform to set
  28757. * @param texture The texture to apply
  28758. */
  28759. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28760. /**
  28761. * Sets a depth stencil texture from a render target to the according uniform.
  28762. * @param channel The texture channel
  28763. * @param uniform The uniform to set
  28764. * @param texture The render target texture containing the depth stencil texture to apply
  28765. */
  28766. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28767. private _bindSamplerUniformToChannel;
  28768. private _getTextureWrapMode;
  28769. private _setTexture;
  28770. /**
  28771. * Sets an array of texture to the webGL context
  28772. * @param channel defines the channel where the texture array must be set
  28773. * @param uniform defines the associated uniform location
  28774. * @param textures defines the array of textures to bind
  28775. */
  28776. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28777. /** @hidden */
  28778. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28779. private _setTextureParameterFloat;
  28780. private _setTextureParameterInteger;
  28781. /**
  28782. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28783. * @param x defines the x coordinate of the rectangle where pixels must be read
  28784. * @param y defines the y coordinate of the rectangle where pixels must be read
  28785. * @param width defines the width of the rectangle where pixels must be read
  28786. * @param height defines the height of the rectangle where pixels must be read
  28787. * @returns a Uint8Array containing RGBA colors
  28788. */
  28789. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28790. /**
  28791. * Add an externaly attached data from its key.
  28792. * This method call will fail and return false, if such key already exists.
  28793. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28794. * @param key the unique key that identifies the data
  28795. * @param data the data object to associate to the key for this Engine instance
  28796. * @return true if no such key were already present and the data was added successfully, false otherwise
  28797. */
  28798. addExternalData<T>(key: string, data: T): boolean;
  28799. /**
  28800. * Get an externaly attached data from its key
  28801. * @param key the unique key that identifies the data
  28802. * @return the associated data, if present (can be null), or undefined if not present
  28803. */
  28804. getExternalData<T>(key: string): T;
  28805. /**
  28806. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28807. * @param key the unique key that identifies the data
  28808. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28809. * @return the associated data, can be null if the factory returned null.
  28810. */
  28811. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28812. /**
  28813. * Remove an externaly attached data from the Engine instance
  28814. * @param key the unique key that identifies the data
  28815. * @return true if the data was successfully removed, false if it doesn't exist
  28816. */
  28817. removeExternalData(key: string): boolean;
  28818. /**
  28819. * Unbind all vertex attributes from the webGL context
  28820. */
  28821. unbindAllAttributes(): void;
  28822. /**
  28823. * 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
  28824. */
  28825. releaseEffects(): void;
  28826. /**
  28827. * Dispose and release all associated resources
  28828. */
  28829. dispose(): void;
  28830. /**
  28831. * Display the loading screen
  28832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28833. */
  28834. displayLoadingUI(): void;
  28835. /**
  28836. * Hide the loading screen
  28837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28838. */
  28839. hideLoadingUI(): void;
  28840. /**
  28841. * Gets the current loading screen object
  28842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28843. */
  28844. /**
  28845. * Sets the current loading screen object
  28846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28847. */
  28848. loadingScreen: ILoadingScreen;
  28849. /**
  28850. * Sets the current loading screen text
  28851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28852. */
  28853. loadingUIText: string;
  28854. /**
  28855. * Sets the current loading screen background color
  28856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28857. */
  28858. loadingUIBackgroundColor: string;
  28859. /**
  28860. * Attach a new callback raised when context lost event is fired
  28861. * @param callback defines the callback to call
  28862. */
  28863. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28864. /**
  28865. * Attach a new callback raised when context restored event is fired
  28866. * @param callback defines the callback to call
  28867. */
  28868. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28869. /**
  28870. * Gets the source code of the vertex shader associated with a specific webGL program
  28871. * @param program defines the program to use
  28872. * @returns a string containing the source code of the vertex shader associated with the program
  28873. */
  28874. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28875. /**
  28876. * Gets the source code of the fragment shader associated with a specific webGL program
  28877. * @param program defines the program to use
  28878. * @returns a string containing the source code of the fragment shader associated with the program
  28879. */
  28880. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28881. /**
  28882. * Get the current error code of the webGL context
  28883. * @returns the error code
  28884. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28885. */
  28886. getError(): number;
  28887. /**
  28888. * Gets the current framerate
  28889. * @returns a number representing the framerate
  28890. */
  28891. getFps(): number;
  28892. /**
  28893. * Gets the time spent between current and previous frame
  28894. * @returns a number representing the delta time in ms
  28895. */
  28896. getDeltaTime(): number;
  28897. private _measureFps;
  28898. /** @hidden */
  28899. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28900. private _canRenderToFloatFramebuffer;
  28901. private _canRenderToHalfFloatFramebuffer;
  28902. private _canRenderToFramebuffer;
  28903. /** @hidden */
  28904. _getWebGLTextureType(type: number): number;
  28905. /** @hidden */
  28906. _getInternalFormat(format: number): number;
  28907. /** @hidden */
  28908. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28909. /** @hidden */
  28910. _getRGBAMultiSampleBufferFormat(type: number): number;
  28911. /** @hidden */
  28912. _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;
  28913. /** @hidden */
  28914. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28915. private _partialLoadFile;
  28916. private _cascadeLoadFiles;
  28917. /**
  28918. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28919. * @returns true if the engine can be created
  28920. * @ignorenaming
  28921. */
  28922. static isSupported(): boolean;
  28923. }
  28924. }
  28925. declare module BABYLON {
  28926. /**
  28927. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28928. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28929. */
  28930. export class EffectFallbacks {
  28931. private _defines;
  28932. private _currentRank;
  28933. private _maxRank;
  28934. private _mesh;
  28935. /**
  28936. * Removes the fallback from the bound mesh.
  28937. */
  28938. unBindMesh(): void;
  28939. /**
  28940. * Adds a fallback on the specified property.
  28941. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28942. * @param define The name of the define in the shader
  28943. */
  28944. addFallback(rank: number, define: string): void;
  28945. /**
  28946. * Sets the mesh to use CPU skinning when needing to fallback.
  28947. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28948. * @param mesh The mesh to use the fallbacks.
  28949. */
  28950. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28951. /**
  28952. * Checks to see if more fallbacks are still availible.
  28953. */
  28954. readonly isMoreFallbacks: boolean;
  28955. /**
  28956. * Removes the defines that shoould be removed when falling back.
  28957. * @param currentDefines defines the current define statements for the shader.
  28958. * @param effect defines the current effect we try to compile
  28959. * @returns The resulting defines with defines of the current rank removed.
  28960. */
  28961. reduce(currentDefines: string, effect: Effect): string;
  28962. }
  28963. /**
  28964. * Options to be used when creating an effect.
  28965. */
  28966. export class EffectCreationOptions {
  28967. /**
  28968. * Atrributes that will be used in the shader.
  28969. */
  28970. attributes: string[];
  28971. /**
  28972. * Uniform varible names that will be set in the shader.
  28973. */
  28974. uniformsNames: string[];
  28975. /**
  28976. * Uniform buffer varible names that will be set in the shader.
  28977. */
  28978. uniformBuffersNames: string[];
  28979. /**
  28980. * Sampler texture variable names that will be set in the shader.
  28981. */
  28982. samplers: string[];
  28983. /**
  28984. * Define statements that will be set in the shader.
  28985. */
  28986. defines: any;
  28987. /**
  28988. * Possible fallbacks for this effect to improve performance when needed.
  28989. */
  28990. fallbacks: Nullable<EffectFallbacks>;
  28991. /**
  28992. * Callback that will be called when the shader is compiled.
  28993. */
  28994. onCompiled: Nullable<(effect: Effect) => void>;
  28995. /**
  28996. * Callback that will be called if an error occurs during shader compilation.
  28997. */
  28998. onError: Nullable<(effect: Effect, errors: string) => void>;
  28999. /**
  29000. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29001. */
  29002. indexParameters: any;
  29003. /**
  29004. * Max number of lights that can be used in the shader.
  29005. */
  29006. maxSimultaneousLights: number;
  29007. /**
  29008. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29009. */
  29010. transformFeedbackVaryings: Nullable<string[]>;
  29011. }
  29012. /**
  29013. * Effect containing vertex and fragment shader that can be executed on an object.
  29014. */
  29015. export class Effect implements IDisposable {
  29016. /**
  29017. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29018. */
  29019. static ShadersRepository: string;
  29020. /**
  29021. * Name of the effect.
  29022. */
  29023. name: any;
  29024. /**
  29025. * String container all the define statements that should be set on the shader.
  29026. */
  29027. defines: string;
  29028. /**
  29029. * Callback that will be called when the shader is compiled.
  29030. */
  29031. onCompiled: Nullable<(effect: Effect) => void>;
  29032. /**
  29033. * Callback that will be called if an error occurs during shader compilation.
  29034. */
  29035. onError: Nullable<(effect: Effect, errors: string) => void>;
  29036. /**
  29037. * Callback that will be called when effect is bound.
  29038. */
  29039. onBind: Nullable<(effect: Effect) => void>;
  29040. /**
  29041. * Unique ID of the effect.
  29042. */
  29043. uniqueId: number;
  29044. /**
  29045. * Observable that will be called when the shader is compiled.
  29046. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29047. */
  29048. onCompileObservable: Observable<Effect>;
  29049. /**
  29050. * Observable that will be called if an error occurs during shader compilation.
  29051. */
  29052. onErrorObservable: Observable<Effect>;
  29053. /** @hidden */
  29054. _onBindObservable: Nullable<Observable<Effect>>;
  29055. /**
  29056. * Observable that will be called when effect is bound.
  29057. */
  29058. readonly onBindObservable: Observable<Effect>;
  29059. /** @hidden */
  29060. _bonesComputationForcedToCPU: boolean;
  29061. private static _uniqueIdSeed;
  29062. private _engine;
  29063. private _uniformBuffersNames;
  29064. private _uniformsNames;
  29065. private _samplerList;
  29066. private _samplers;
  29067. private _isReady;
  29068. private _compilationError;
  29069. private _attributesNames;
  29070. private _attributes;
  29071. private _uniforms;
  29072. /**
  29073. * Key for the effect.
  29074. * @hidden
  29075. */
  29076. _key: string;
  29077. private _indexParameters;
  29078. private _fallbacks;
  29079. private _vertexSourceCode;
  29080. private _fragmentSourceCode;
  29081. private _vertexSourceCodeOverride;
  29082. private _fragmentSourceCodeOverride;
  29083. private _transformFeedbackVaryings;
  29084. /**
  29085. * Compiled shader to webGL program.
  29086. * @hidden
  29087. */
  29088. _program: WebGLProgram;
  29089. private _valueCache;
  29090. private static _baseCache;
  29091. /**
  29092. * Instantiates an effect.
  29093. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29094. * @param baseName Name of the effect.
  29095. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29096. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29097. * @param samplers List of sampler variables that will be passed to the shader.
  29098. * @param engine Engine to be used to render the effect
  29099. * @param defines Define statements to be added to the shader.
  29100. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29101. * @param onCompiled Callback that will be called when the shader is compiled.
  29102. * @param onError Callback that will be called if an error occurs during shader compilation.
  29103. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29104. */
  29105. 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);
  29106. /**
  29107. * Unique key for this effect
  29108. */
  29109. readonly key: string;
  29110. /**
  29111. * If the effect has been compiled and prepared.
  29112. * @returns if the effect is compiled and prepared.
  29113. */
  29114. isReady(): boolean;
  29115. /**
  29116. * The engine the effect was initialized with.
  29117. * @returns the engine.
  29118. */
  29119. getEngine(): Engine;
  29120. /**
  29121. * The compiled webGL program for the effect
  29122. * @returns the webGL program.
  29123. */
  29124. getProgram(): WebGLProgram;
  29125. /**
  29126. * The set of names of attribute variables for the shader.
  29127. * @returns An array of attribute names.
  29128. */
  29129. getAttributesNames(): string[];
  29130. /**
  29131. * Returns the attribute at the given index.
  29132. * @param index The index of the attribute.
  29133. * @returns The location of the attribute.
  29134. */
  29135. getAttributeLocation(index: number): number;
  29136. /**
  29137. * Returns the attribute based on the name of the variable.
  29138. * @param name of the attribute to look up.
  29139. * @returns the attribute location.
  29140. */
  29141. getAttributeLocationByName(name: string): number;
  29142. /**
  29143. * The number of attributes.
  29144. * @returns the numnber of attributes.
  29145. */
  29146. getAttributesCount(): number;
  29147. /**
  29148. * Gets the index of a uniform variable.
  29149. * @param uniformName of the uniform to look up.
  29150. * @returns the index.
  29151. */
  29152. getUniformIndex(uniformName: string): number;
  29153. /**
  29154. * Returns the attribute based on the name of the variable.
  29155. * @param uniformName of the uniform to look up.
  29156. * @returns the location of the uniform.
  29157. */
  29158. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29159. /**
  29160. * Returns an array of sampler variable names
  29161. * @returns The array of sampler variable neames.
  29162. */
  29163. getSamplers(): string[];
  29164. /**
  29165. * The error from the last compilation.
  29166. * @returns the error string.
  29167. */
  29168. getCompilationError(): string;
  29169. /**
  29170. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29171. * @param func The callback to be used.
  29172. */
  29173. executeWhenCompiled(func: (effect: Effect) => void): void;
  29174. private _checkIsReady;
  29175. /** @hidden */
  29176. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29177. /** @hidden */
  29178. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29179. /** @hidden */
  29180. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29181. private _processShaderConversion;
  29182. private _processIncludes;
  29183. private _processPrecision;
  29184. /**
  29185. * Recompiles the webGL program
  29186. * @param vertexSourceCode The source code for the vertex shader.
  29187. * @param fragmentSourceCode The source code for the fragment shader.
  29188. * @param onCompiled Callback called when completed.
  29189. * @param onError Callback called on error.
  29190. * @hidden
  29191. */
  29192. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29193. /**
  29194. * Gets the uniform locations of the the specified variable names
  29195. * @param names THe names of the variables to lookup.
  29196. * @returns Array of locations in the same order as variable names.
  29197. */
  29198. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29199. /**
  29200. * Prepares the effect
  29201. * @hidden
  29202. */
  29203. _prepareEffect(): void;
  29204. /**
  29205. * Checks if the effect is supported. (Must be called after compilation)
  29206. */
  29207. readonly isSupported: boolean;
  29208. /**
  29209. * Binds a texture to the engine to be used as output of the shader.
  29210. * @param channel Name of the output variable.
  29211. * @param texture Texture to bind.
  29212. * @hidden
  29213. */
  29214. _bindTexture(channel: string, texture: InternalTexture): void;
  29215. /**
  29216. * Sets a texture on the engine to be used in the shader.
  29217. * @param channel Name of the sampler variable.
  29218. * @param texture Texture to set.
  29219. */
  29220. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29221. /**
  29222. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29223. * @param channel Name of the sampler variable.
  29224. * @param texture Texture to set.
  29225. */
  29226. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29227. /**
  29228. * Sets an array of textures on the engine to be used in the shader.
  29229. * @param channel Name of the variable.
  29230. * @param textures Textures to set.
  29231. */
  29232. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29233. /**
  29234. * 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)
  29235. * @param channel Name of the sampler variable.
  29236. * @param postProcess Post process to get the input texture from.
  29237. */
  29238. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29239. /**
  29240. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29241. * 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)
  29242. * @param channel Name of the sampler variable.
  29243. * @param postProcess Post process to get the output texture from.
  29244. */
  29245. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29246. /** @hidden */
  29247. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29248. /** @hidden */
  29249. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29250. /** @hidden */
  29251. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29252. /** @hidden */
  29253. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29254. /**
  29255. * Binds a buffer to a uniform.
  29256. * @param buffer Buffer to bind.
  29257. * @param name Name of the uniform variable to bind to.
  29258. */
  29259. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29260. /**
  29261. * Binds block to a uniform.
  29262. * @param blockName Name of the block to bind.
  29263. * @param index Index to bind.
  29264. */
  29265. bindUniformBlock(blockName: string, index: number): void;
  29266. /**
  29267. * Sets an interger value on a uniform variable.
  29268. * @param uniformName Name of the variable.
  29269. * @param value Value to be set.
  29270. * @returns this effect.
  29271. */
  29272. setInt(uniformName: string, value: number): Effect;
  29273. /**
  29274. * Sets an int array on a uniform variable.
  29275. * @param uniformName Name of the variable.
  29276. * @param array array to be set.
  29277. * @returns this effect.
  29278. */
  29279. setIntArray(uniformName: string, array: Int32Array): Effect;
  29280. /**
  29281. * 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)
  29282. * @param uniformName Name of the variable.
  29283. * @param array array to be set.
  29284. * @returns this effect.
  29285. */
  29286. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29287. /**
  29288. * 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)
  29289. * @param uniformName Name of the variable.
  29290. * @param array array to be set.
  29291. * @returns this effect.
  29292. */
  29293. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29294. /**
  29295. * 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)
  29296. * @param uniformName Name of the variable.
  29297. * @param array array to be set.
  29298. * @returns this effect.
  29299. */
  29300. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29301. /**
  29302. * Sets an float array on a uniform variable.
  29303. * @param uniformName Name of the variable.
  29304. * @param array array to be set.
  29305. * @returns this effect.
  29306. */
  29307. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29308. /**
  29309. * 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)
  29310. * @param uniformName Name of the variable.
  29311. * @param array array to be set.
  29312. * @returns this effect.
  29313. */
  29314. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29315. /**
  29316. * 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)
  29317. * @param uniformName Name of the variable.
  29318. * @param array array to be set.
  29319. * @returns this effect.
  29320. */
  29321. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29322. /**
  29323. * 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)
  29324. * @param uniformName Name of the variable.
  29325. * @param array array to be set.
  29326. * @returns this effect.
  29327. */
  29328. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29329. /**
  29330. * Sets an array on a uniform variable.
  29331. * @param uniformName Name of the variable.
  29332. * @param array array to be set.
  29333. * @returns this effect.
  29334. */
  29335. setArray(uniformName: string, array: number[]): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setArray2(uniformName: string, array: number[]): Effect;
  29343. /**
  29344. * 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)
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setArray3(uniformName: string, array: number[]): Effect;
  29350. /**
  29351. * 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)
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setArray4(uniformName: string, array: number[]): Effect;
  29357. /**
  29358. * Sets matrices on a uniform variable.
  29359. * @param uniformName Name of the variable.
  29360. * @param matrices matrices to be set.
  29361. * @returns this effect.
  29362. */
  29363. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29364. /**
  29365. * Sets matrix on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param matrix matrix to be set.
  29368. * @returns this effect.
  29369. */
  29370. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param matrix matrix to be set.
  29375. * @returns this effect.
  29376. */
  29377. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29378. /**
  29379. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29380. * @param uniformName Name of the variable.
  29381. * @param matrix matrix to be set.
  29382. * @returns this effect.
  29383. */
  29384. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29385. /**
  29386. * Sets a float on a uniform variable.
  29387. * @param uniformName Name of the variable.
  29388. * @param value value to be set.
  29389. * @returns this effect.
  29390. */
  29391. setFloat(uniformName: string, value: number): Effect;
  29392. /**
  29393. * Sets a boolean on a uniform variable.
  29394. * @param uniformName Name of the variable.
  29395. * @param bool value to be set.
  29396. * @returns this effect.
  29397. */
  29398. setBool(uniformName: string, bool: boolean): Effect;
  29399. /**
  29400. * Sets a Vector2 on a uniform variable.
  29401. * @param uniformName Name of the variable.
  29402. * @param vector2 vector2 to be set.
  29403. * @returns this effect.
  29404. */
  29405. setVector2(uniformName: string, vector2: Vector2): Effect;
  29406. /**
  29407. * Sets a float2 on a uniform variable.
  29408. * @param uniformName Name of the variable.
  29409. * @param x First float in float2.
  29410. * @param y Second float in float2.
  29411. * @returns this effect.
  29412. */
  29413. setFloat2(uniformName: string, x: number, y: number): Effect;
  29414. /**
  29415. * Sets a Vector3 on a uniform variable.
  29416. * @param uniformName Name of the variable.
  29417. * @param vector3 Value to be set.
  29418. * @returns this effect.
  29419. */
  29420. setVector3(uniformName: string, vector3: Vector3): Effect;
  29421. /**
  29422. * Sets a float3 on a uniform variable.
  29423. * @param uniformName Name of the variable.
  29424. * @param x First float in float3.
  29425. * @param y Second float in float3.
  29426. * @param z Third float in float3.
  29427. * @returns this effect.
  29428. */
  29429. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29430. /**
  29431. * Sets a Vector4 on a uniform variable.
  29432. * @param uniformName Name of the variable.
  29433. * @param vector4 Value to be set.
  29434. * @returns this effect.
  29435. */
  29436. setVector4(uniformName: string, vector4: Vector4): Effect;
  29437. /**
  29438. * Sets a float4 on a uniform variable.
  29439. * @param uniformName Name of the variable.
  29440. * @param x First float in float4.
  29441. * @param y Second float in float4.
  29442. * @param z Third float in float4.
  29443. * @param w Fourth float in float4.
  29444. * @returns this effect.
  29445. */
  29446. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29447. /**
  29448. * Sets a Color3 on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param color3 Value to be set.
  29451. * @returns this effect.
  29452. */
  29453. setColor3(uniformName: string, color3: Color3): Effect;
  29454. /**
  29455. * Sets a Color4 on a uniform variable.
  29456. * @param uniformName Name of the variable.
  29457. * @param color3 Value to be set.
  29458. * @param alpha Alpha value to be set.
  29459. * @returns this effect.
  29460. */
  29461. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29462. /**
  29463. * Sets a Color4 on a uniform variable
  29464. * @param uniformName defines the name of the variable
  29465. * @param color4 defines the value to be set
  29466. * @returns this effect.
  29467. */
  29468. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29469. /** Release all associated resources */
  29470. dispose(): void;
  29471. /**
  29472. * This function will add a new shader to the shader store
  29473. * @param name the name of the shader
  29474. * @param pixelShader optional pixel shader content
  29475. * @param vertexShader optional vertex shader content
  29476. */
  29477. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29478. /**
  29479. * Store of each shader (The can be looked up using effect.key)
  29480. */
  29481. static ShadersStore: {
  29482. [key: string]: string;
  29483. };
  29484. /**
  29485. * Store of each included file for a shader (The can be looked up using effect.key)
  29486. */
  29487. static IncludesShadersStore: {
  29488. [key: string]: string;
  29489. };
  29490. /**
  29491. * Resets the cache of effects.
  29492. */
  29493. static ResetCache(): void;
  29494. }
  29495. }
  29496. declare module BABYLON {
  29497. /**
  29498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29500. * 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;
  29501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29502. */
  29503. export class ColorCurves {
  29504. private _dirty;
  29505. private _tempColor;
  29506. private _globalCurve;
  29507. private _highlightsCurve;
  29508. private _midtonesCurve;
  29509. private _shadowsCurve;
  29510. private _positiveCurve;
  29511. private _negativeCurve;
  29512. private _globalHue;
  29513. private _globalDensity;
  29514. private _globalSaturation;
  29515. private _globalExposure;
  29516. /**
  29517. * Gets the global Hue value.
  29518. * 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).
  29519. */
  29520. /**
  29521. * Sets the global Hue value.
  29522. * 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).
  29523. */
  29524. globalHue: number;
  29525. /**
  29526. * Gets the global Density value.
  29527. * 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.
  29528. * Values less than zero provide a filter of opposite hue.
  29529. */
  29530. /**
  29531. * Sets the global Density value.
  29532. * 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.
  29533. * Values less than zero provide a filter of opposite hue.
  29534. */
  29535. globalDensity: number;
  29536. /**
  29537. * Gets the global Saturation value.
  29538. * 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.
  29539. */
  29540. /**
  29541. * Sets the global Saturation value.
  29542. * 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.
  29543. */
  29544. globalSaturation: number;
  29545. /**
  29546. * Gets the global Exposure value.
  29547. * 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.
  29548. */
  29549. /**
  29550. * Sets the global Exposure value.
  29551. * 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.
  29552. */
  29553. globalExposure: number;
  29554. private _highlightsHue;
  29555. private _highlightsDensity;
  29556. private _highlightsSaturation;
  29557. private _highlightsExposure;
  29558. /**
  29559. * Gets the highlights Hue value.
  29560. * 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).
  29561. */
  29562. /**
  29563. * Sets the highlights Hue value.
  29564. * 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).
  29565. */
  29566. highlightsHue: number;
  29567. /**
  29568. * Gets the highlights Density value.
  29569. * 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.
  29570. * Values less than zero provide a filter of opposite hue.
  29571. */
  29572. /**
  29573. * Sets the highlights Density value.
  29574. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29575. * Values less than zero provide a filter of opposite hue.
  29576. */
  29577. highlightsDensity: number;
  29578. /**
  29579. * Gets the highlights Saturation value.
  29580. * 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.
  29581. */
  29582. /**
  29583. * Sets the highlights Saturation value.
  29584. * 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.
  29585. */
  29586. highlightsSaturation: number;
  29587. /**
  29588. * Gets the highlights Exposure value.
  29589. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29590. */
  29591. /**
  29592. * Sets the highlights Exposure value.
  29593. * 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.
  29594. */
  29595. highlightsExposure: number;
  29596. private _midtonesHue;
  29597. private _midtonesDensity;
  29598. private _midtonesSaturation;
  29599. private _midtonesExposure;
  29600. /**
  29601. * Gets the midtones Hue value.
  29602. * 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).
  29603. */
  29604. /**
  29605. * Sets the midtones Hue value.
  29606. * 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).
  29607. */
  29608. midtonesHue: number;
  29609. /**
  29610. * Gets the midtones Density value.
  29611. * 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.
  29612. * Values less than zero provide a filter of opposite hue.
  29613. */
  29614. /**
  29615. * Sets the midtones Density value.
  29616. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29617. * Values less than zero provide a filter of opposite hue.
  29618. */
  29619. midtonesDensity: number;
  29620. /**
  29621. * Gets the midtones Saturation value.
  29622. * 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.
  29623. */
  29624. /**
  29625. * Sets the midtones Saturation value.
  29626. * 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.
  29627. */
  29628. midtonesSaturation: number;
  29629. /**
  29630. * Gets the midtones Exposure value.
  29631. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29632. */
  29633. /**
  29634. * Sets the midtones Exposure value.
  29635. * 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.
  29636. */
  29637. midtonesExposure: number;
  29638. private _shadowsHue;
  29639. private _shadowsDensity;
  29640. private _shadowsSaturation;
  29641. private _shadowsExposure;
  29642. /**
  29643. * Gets the shadows Hue value.
  29644. * 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).
  29645. */
  29646. /**
  29647. * Sets the shadows Hue value.
  29648. * 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).
  29649. */
  29650. shadowsHue: number;
  29651. /**
  29652. * Gets the shadows Density value.
  29653. * 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.
  29654. * Values less than zero provide a filter of opposite hue.
  29655. */
  29656. /**
  29657. * Sets the shadows Density value.
  29658. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29659. * Values less than zero provide a filter of opposite hue.
  29660. */
  29661. shadowsDensity: number;
  29662. /**
  29663. * Gets the shadows Saturation value.
  29664. * 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.
  29665. */
  29666. /**
  29667. * Sets the shadows Saturation value.
  29668. * 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.
  29669. */
  29670. shadowsSaturation: number;
  29671. /**
  29672. * Gets the shadows Exposure value.
  29673. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29674. */
  29675. /**
  29676. * Sets the shadows Exposure value.
  29677. * 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.
  29678. */
  29679. shadowsExposure: number;
  29680. /**
  29681. * Returns the class name
  29682. * @returns The class name
  29683. */
  29684. getClassName(): string;
  29685. /**
  29686. * Binds the color curves to the shader.
  29687. * @param colorCurves The color curve to bind
  29688. * @param effect The effect to bind to
  29689. * @param positiveUniform The positive uniform shader parameter
  29690. * @param neutralUniform The neutral uniform shader parameter
  29691. * @param negativeUniform The negative uniform shader parameter
  29692. */
  29693. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29694. /**
  29695. * Prepare the list of uniforms associated with the ColorCurves effects.
  29696. * @param uniformsList The list of uniforms used in the effect
  29697. */
  29698. static PrepareUniforms(uniformsList: string[]): void;
  29699. /**
  29700. * Returns color grading data based on a hue, density, saturation and exposure value.
  29701. * @param filterHue The hue of the color filter.
  29702. * @param filterDensity The density of the color filter.
  29703. * @param saturation The saturation.
  29704. * @param exposure The exposure.
  29705. * @param result The result data container.
  29706. */
  29707. private getColorGradingDataToRef;
  29708. /**
  29709. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29710. * @param value The input slider value in range [-100,100].
  29711. * @returns Adjusted value.
  29712. */
  29713. private static applyColorGradingSliderNonlinear;
  29714. /**
  29715. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29716. * @param hue The hue (H) input.
  29717. * @param saturation The saturation (S) input.
  29718. * @param brightness The brightness (B) input.
  29719. * @result An RGBA color represented as Vector4.
  29720. */
  29721. private static fromHSBToRef;
  29722. /**
  29723. * Returns a value clamped between min and max
  29724. * @param value The value to clamp
  29725. * @param min The minimum of value
  29726. * @param max The maximum of value
  29727. * @returns The clamped value.
  29728. */
  29729. private static clamp;
  29730. /**
  29731. * Clones the current color curve instance.
  29732. * @return The cloned curves
  29733. */
  29734. clone(): ColorCurves;
  29735. /**
  29736. * Serializes the current color curve instance to a json representation.
  29737. * @return a JSON representation
  29738. */
  29739. serialize(): any;
  29740. /**
  29741. * Parses the color curve from a json representation.
  29742. * @param source the JSON source to parse
  29743. * @return The parsed curves
  29744. */
  29745. static Parse(source: any): ColorCurves;
  29746. }
  29747. }
  29748. declare module BABYLON {
  29749. /**
  29750. * Interface to follow in your material defines to integrate easily the
  29751. * Image proccessing functions.
  29752. * @hidden
  29753. */
  29754. export interface IImageProcessingConfigurationDefines {
  29755. IMAGEPROCESSING: boolean;
  29756. VIGNETTE: boolean;
  29757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29758. VIGNETTEBLENDMODEOPAQUE: boolean;
  29759. TONEMAPPING: boolean;
  29760. TONEMAPPING_ACES: boolean;
  29761. CONTRAST: boolean;
  29762. EXPOSURE: boolean;
  29763. COLORCURVES: boolean;
  29764. COLORGRADING: boolean;
  29765. COLORGRADING3D: boolean;
  29766. SAMPLER3DGREENDEPTH: boolean;
  29767. SAMPLER3DBGRMAP: boolean;
  29768. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29769. }
  29770. /**
  29771. * @hidden
  29772. */
  29773. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29774. IMAGEPROCESSING: boolean;
  29775. VIGNETTE: boolean;
  29776. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29777. VIGNETTEBLENDMODEOPAQUE: boolean;
  29778. TONEMAPPING: boolean;
  29779. TONEMAPPING_ACES: boolean;
  29780. CONTRAST: boolean;
  29781. COLORCURVES: boolean;
  29782. COLORGRADING: boolean;
  29783. COLORGRADING3D: boolean;
  29784. SAMPLER3DGREENDEPTH: boolean;
  29785. SAMPLER3DBGRMAP: boolean;
  29786. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29787. EXPOSURE: boolean;
  29788. constructor();
  29789. }
  29790. /**
  29791. * This groups together the common properties used for image processing either in direct forward pass
  29792. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29793. * or not.
  29794. */
  29795. export class ImageProcessingConfiguration {
  29796. /**
  29797. * Default tone mapping applied in BabylonJS.
  29798. */
  29799. static readonly TONEMAPPING_STANDARD: number;
  29800. /**
  29801. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29802. * to other engines rendering to increase portability.
  29803. */
  29804. static readonly TONEMAPPING_ACES: number;
  29805. /**
  29806. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29807. */
  29808. colorCurves: Nullable<ColorCurves>;
  29809. private _colorCurvesEnabled;
  29810. /**
  29811. * Gets wether the color curves effect is enabled.
  29812. */
  29813. /**
  29814. * Sets wether the color curves effect is enabled.
  29815. */
  29816. colorCurvesEnabled: boolean;
  29817. private _colorGradingTexture;
  29818. /**
  29819. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29820. */
  29821. /**
  29822. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29823. */
  29824. colorGradingTexture: Nullable<BaseTexture>;
  29825. private _colorGradingEnabled;
  29826. /**
  29827. * Gets wether the color grading effect is enabled.
  29828. */
  29829. /**
  29830. * Sets wether the color grading effect is enabled.
  29831. */
  29832. colorGradingEnabled: boolean;
  29833. private _colorGradingWithGreenDepth;
  29834. /**
  29835. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29836. */
  29837. /**
  29838. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29839. */
  29840. colorGradingWithGreenDepth: boolean;
  29841. private _colorGradingBGR;
  29842. /**
  29843. * Gets wether the color grading texture contains BGR values.
  29844. */
  29845. /**
  29846. * Sets wether the color grading texture contains BGR values.
  29847. */
  29848. colorGradingBGR: boolean;
  29849. /** @hidden */
  29850. _exposure: number;
  29851. /**
  29852. * Gets the Exposure used in the effect.
  29853. */
  29854. /**
  29855. * Sets the Exposure used in the effect.
  29856. */
  29857. exposure: number;
  29858. private _toneMappingEnabled;
  29859. /**
  29860. * Gets wether the tone mapping effect is enabled.
  29861. */
  29862. /**
  29863. * Sets wether the tone mapping effect is enabled.
  29864. */
  29865. toneMappingEnabled: boolean;
  29866. private _toneMappingType;
  29867. /**
  29868. * Gets the type of tone mapping effect.
  29869. */
  29870. /**
  29871. * Sets the type of tone mapping effect used in BabylonJS.
  29872. */
  29873. toneMappingType: number;
  29874. protected _contrast: number;
  29875. /**
  29876. * Gets the contrast used in the effect.
  29877. */
  29878. /**
  29879. * Sets the contrast used in the effect.
  29880. */
  29881. contrast: number;
  29882. /**
  29883. * Vignette stretch size.
  29884. */
  29885. vignetteStretch: number;
  29886. /**
  29887. * Vignette centre X Offset.
  29888. */
  29889. vignetteCentreX: number;
  29890. /**
  29891. * Vignette centre Y Offset.
  29892. */
  29893. vignetteCentreY: number;
  29894. /**
  29895. * Vignette weight or intensity of the vignette effect.
  29896. */
  29897. vignetteWeight: number;
  29898. /**
  29899. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29900. * if vignetteEnabled is set to true.
  29901. */
  29902. vignetteColor: Color4;
  29903. /**
  29904. * Camera field of view used by the Vignette effect.
  29905. */
  29906. vignetteCameraFov: number;
  29907. private _vignetteBlendMode;
  29908. /**
  29909. * Gets the vignette blend mode allowing different kind of effect.
  29910. */
  29911. /**
  29912. * Sets the vignette blend mode allowing different kind of effect.
  29913. */
  29914. vignetteBlendMode: number;
  29915. private _vignetteEnabled;
  29916. /**
  29917. * Gets wether the vignette effect is enabled.
  29918. */
  29919. /**
  29920. * Sets wether the vignette effect is enabled.
  29921. */
  29922. vignetteEnabled: boolean;
  29923. private _applyByPostProcess;
  29924. /**
  29925. * Gets wether the image processing is applied through a post process or not.
  29926. */
  29927. /**
  29928. * Sets wether the image processing is applied through a post process or not.
  29929. */
  29930. applyByPostProcess: boolean;
  29931. private _isEnabled;
  29932. /**
  29933. * Gets wether the image processing is enabled or not.
  29934. */
  29935. /**
  29936. * Sets wether the image processing is enabled or not.
  29937. */
  29938. isEnabled: boolean;
  29939. /**
  29940. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29941. */
  29942. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29943. /**
  29944. * Method called each time the image processing information changes requires to recompile the effect.
  29945. */
  29946. protected _updateParameters(): void;
  29947. /**
  29948. * Gets the current class name.
  29949. * @return "ImageProcessingConfiguration"
  29950. */
  29951. getClassName(): string;
  29952. /**
  29953. * Prepare the list of uniforms associated with the Image Processing effects.
  29954. * @param uniforms The list of uniforms used in the effect
  29955. * @param defines the list of defines currently in use
  29956. */
  29957. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29958. /**
  29959. * Prepare the list of samplers associated with the Image Processing effects.
  29960. * @param samplersList The list of uniforms used in the effect
  29961. * @param defines the list of defines currently in use
  29962. */
  29963. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29964. /**
  29965. * Prepare the list of defines associated to the shader.
  29966. * @param defines the list of defines to complete
  29967. * @param forPostProcess Define if we are currently in post process mode or not
  29968. */
  29969. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29970. /**
  29971. * Returns true if all the image processing information are ready.
  29972. * @returns True if ready, otherwise, false
  29973. */
  29974. isReady(): boolean;
  29975. /**
  29976. * Binds the image processing to the shader.
  29977. * @param effect The effect to bind to
  29978. * @param aspectRatio Define the current aspect ratio of the effect
  29979. */
  29980. bind(effect: Effect, aspectRatio?: number): void;
  29981. /**
  29982. * Clones the current image processing instance.
  29983. * @return The cloned image processing
  29984. */
  29985. clone(): ImageProcessingConfiguration;
  29986. /**
  29987. * Serializes the current image processing instance to a json representation.
  29988. * @return a JSON representation
  29989. */
  29990. serialize(): any;
  29991. /**
  29992. * Parses the image processing from a json representation.
  29993. * @param source the JSON source to parse
  29994. * @return The parsed image processing
  29995. */
  29996. static Parse(source: any): ImageProcessingConfiguration;
  29997. private static _VIGNETTEMODE_MULTIPLY;
  29998. private static _VIGNETTEMODE_OPAQUE;
  29999. /**
  30000. * Used to apply the vignette as a mix with the pixel color.
  30001. */
  30002. static readonly VIGNETTEMODE_MULTIPLY: number;
  30003. /**
  30004. * Used to apply the vignette as a replacement of the pixel color.
  30005. */
  30006. static readonly VIGNETTEMODE_OPAQUE: number;
  30007. }
  30008. }
  30009. declare module BABYLON {
  30010. /**
  30011. * This represents all the required information to add a fresnel effect on a material:
  30012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30013. */
  30014. export class FresnelParameters {
  30015. private _isEnabled;
  30016. /**
  30017. * Define if the fresnel effect is enable or not.
  30018. */
  30019. isEnabled: boolean;
  30020. /**
  30021. * Define the color used on edges (grazing angle)
  30022. */
  30023. leftColor: Color3;
  30024. /**
  30025. * Define the color used on center
  30026. */
  30027. rightColor: Color3;
  30028. /**
  30029. * Define bias applied to computed fresnel term
  30030. */
  30031. bias: number;
  30032. /**
  30033. * Defined the power exponent applied to fresnel term
  30034. */
  30035. power: number;
  30036. /**
  30037. * Clones the current fresnel and its valuues
  30038. * @returns a clone fresnel configuration
  30039. */
  30040. clone(): FresnelParameters;
  30041. /**
  30042. * Serializes the current fresnel parameters to a JSON representation.
  30043. * @return the JSON serialization
  30044. */
  30045. serialize(): any;
  30046. /**
  30047. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30048. * @param parsedFresnelParameters Define the JSON representation
  30049. * @returns the parsed parameters
  30050. */
  30051. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30052. }
  30053. }
  30054. declare module BABYLON {
  30055. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30056. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30057. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30059. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30060. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30061. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30062. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30063. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30064. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30065. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30066. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30067. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30068. /**
  30069. * Decorator used to define property that can be serialized as reference to a camera
  30070. * @param sourceName defines the name of the property to decorate
  30071. */
  30072. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30073. /**
  30074. * Class used to help serialization objects
  30075. */
  30076. export class SerializationHelper {
  30077. /** hidden */
  30078. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30079. /** hidden */
  30080. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30081. /** hidden */
  30082. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30083. /** hidden */
  30084. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30085. /**
  30086. * Appends the serialized animations from the source animations
  30087. * @param source Source containing the animations
  30088. * @param destination Target to store the animations
  30089. */
  30090. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30091. /**
  30092. * Static function used to serialized a specific entity
  30093. * @param entity defines the entity to serialize
  30094. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30095. * @returns a JSON compatible object representing the serialization of the entity
  30096. */
  30097. static Serialize<T>(entity: T, serializationObject?: any): any;
  30098. /**
  30099. * Creates a new entity from a serialization data object
  30100. * @param creationFunction defines a function used to instanciated the new entity
  30101. * @param source defines the source serialization data
  30102. * @param scene defines the hosting scene
  30103. * @param rootUrl defines the root url for resources
  30104. * @returns a new entity
  30105. */
  30106. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30107. /**
  30108. * Clones an object
  30109. * @param creationFunction defines the function used to instanciate the new object
  30110. * @param source defines the source object
  30111. * @returns the cloned object
  30112. */
  30113. static Clone<T>(creationFunction: () => T, source: T): T;
  30114. /**
  30115. * Instanciates a new object based on a source one (some data will be shared between both object)
  30116. * @param creationFunction defines the function used to instanciate the new object
  30117. * @param source defines the source object
  30118. * @returns the new object
  30119. */
  30120. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30121. }
  30122. }
  30123. declare module BABYLON {
  30124. /**
  30125. * This is the base class of all the camera used in the application.
  30126. * @see http://doc.babylonjs.com/features/cameras
  30127. */
  30128. export class Camera extends Node {
  30129. /** @hidden */
  30130. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30131. /**
  30132. * This is the default projection mode used by the cameras.
  30133. * It helps recreating a feeling of perspective and better appreciate depth.
  30134. * This is the best way to simulate real life cameras.
  30135. */
  30136. static readonly PERSPECTIVE_CAMERA: number;
  30137. /**
  30138. * This helps creating camera with an orthographic mode.
  30139. * 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.
  30140. */
  30141. static readonly ORTHOGRAPHIC_CAMERA: number;
  30142. /**
  30143. * This is the default FOV mode for perspective cameras.
  30144. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30145. */
  30146. static readonly FOVMODE_VERTICAL_FIXED: number;
  30147. /**
  30148. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30149. */
  30150. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30151. /**
  30152. * This specifies ther is no need for a camera rig.
  30153. * Basically only one eye is rendered corresponding to the camera.
  30154. */
  30155. static readonly RIG_MODE_NONE: number;
  30156. /**
  30157. * Simulates a camera Rig with one blue eye and one red eye.
  30158. * This can be use with 3d blue and red glasses.
  30159. */
  30160. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30161. /**
  30162. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30163. */
  30164. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30165. /**
  30166. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30167. */
  30168. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30169. /**
  30170. * Defines that both eyes of the camera will be rendered over under each other.
  30171. */
  30172. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30173. /**
  30174. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30175. */
  30176. static readonly RIG_MODE_VR: number;
  30177. /**
  30178. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30179. */
  30180. static readonly RIG_MODE_WEBVR: number;
  30181. /**
  30182. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30183. */
  30184. static readonly RIG_MODE_CUSTOM: number;
  30185. /**
  30186. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30187. */
  30188. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30189. /**
  30190. * Define the input manager associated with the camera.
  30191. */
  30192. inputs: CameraInputsManager<Camera>;
  30193. /** @hidden */
  30194. _position: Vector3;
  30195. /**
  30196. * Define the current local position of the camera in the scene
  30197. */
  30198. position: Vector3;
  30199. /**
  30200. * The vector the camera should consider as up.
  30201. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30202. */
  30203. upVector: Vector3;
  30204. /**
  30205. * Define the current limit on the left side for an orthographic camera
  30206. * In scene unit
  30207. */
  30208. orthoLeft: Nullable<number>;
  30209. /**
  30210. * Define the current limit on the right side for an orthographic camera
  30211. * In scene unit
  30212. */
  30213. orthoRight: Nullable<number>;
  30214. /**
  30215. * Define the current limit on the bottom side for an orthographic camera
  30216. * In scene unit
  30217. */
  30218. orthoBottom: Nullable<number>;
  30219. /**
  30220. * Define the current limit on the top side for an orthographic camera
  30221. * In scene unit
  30222. */
  30223. orthoTop: Nullable<number>;
  30224. /**
  30225. * Field Of View is set in Radians. (default is 0.8)
  30226. */
  30227. fov: number;
  30228. /**
  30229. * Define the minimum distance the camera can see from.
  30230. * This is important to note that the depth buffer are not infinite and the closer it starts
  30231. * the more your scene might encounter depth fighting issue.
  30232. */
  30233. minZ: number;
  30234. /**
  30235. * Define the maximum distance the camera can see to.
  30236. * This is important to note that the depth buffer are not infinite and the further it end
  30237. * the more your scene might encounter depth fighting issue.
  30238. */
  30239. maxZ: number;
  30240. /**
  30241. * Define the default inertia of the camera.
  30242. * This helps giving a smooth feeling to the camera movement.
  30243. */
  30244. inertia: number;
  30245. /**
  30246. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30247. */
  30248. mode: number;
  30249. /**
  30250. * Define wether the camera is intermediate.
  30251. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30252. */
  30253. isIntermediate: boolean;
  30254. /**
  30255. * Define the viewport of the camera.
  30256. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30257. */
  30258. viewport: Viewport;
  30259. /**
  30260. * Restricts the camera to viewing objects with the same layerMask.
  30261. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30262. */
  30263. layerMask: number;
  30264. /**
  30265. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30266. */
  30267. fovMode: number;
  30268. /**
  30269. * Rig mode of the camera.
  30270. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30271. * This is normally controlled byt the camera themselves as internal use.
  30272. */
  30273. cameraRigMode: number;
  30274. /**
  30275. * Defines the distance between both "eyes" in case of a RIG
  30276. */
  30277. interaxialDistance: number;
  30278. /**
  30279. * Defines if stereoscopic rendering is done side by side or over under.
  30280. */
  30281. isStereoscopicSideBySide: boolean;
  30282. /**
  30283. * 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
  30284. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30285. * else in the scene.
  30286. */
  30287. customRenderTargets: RenderTargetTexture[];
  30288. /**
  30289. * When set, the camera will render to this render target instead of the default canvas
  30290. */
  30291. outputRenderTarget: Nullable<RenderTargetTexture>;
  30292. /**
  30293. * Observable triggered when the camera view matrix has changed.
  30294. */
  30295. onViewMatrixChangedObservable: Observable<Camera>;
  30296. /**
  30297. * Observable triggered when the camera Projection matrix has changed.
  30298. */
  30299. onProjectionMatrixChangedObservable: Observable<Camera>;
  30300. /**
  30301. * Observable triggered when the inputs have been processed.
  30302. */
  30303. onAfterCheckInputsObservable: Observable<Camera>;
  30304. /**
  30305. * Observable triggered when reset has been called and applied to the camera.
  30306. */
  30307. onRestoreStateObservable: Observable<Camera>;
  30308. /** @hidden */
  30309. _cameraRigParams: any;
  30310. /** @hidden */
  30311. _rigCameras: Camera[];
  30312. /** @hidden */
  30313. _rigPostProcess: Nullable<PostProcess>;
  30314. protected _webvrViewMatrix: Matrix;
  30315. /** @hidden */
  30316. _skipRendering: boolean;
  30317. /** @hidden */
  30318. _projectionMatrix: Matrix;
  30319. /** @hidden */
  30320. _postProcesses: Nullable<PostProcess>[];
  30321. /** @hidden */
  30322. _activeMeshes: SmartArray<AbstractMesh>;
  30323. protected _globalPosition: Vector3;
  30324. /** hidden */
  30325. _computedViewMatrix: Matrix;
  30326. private _doNotComputeProjectionMatrix;
  30327. private _transformMatrix;
  30328. private _frustumPlanes;
  30329. private _refreshFrustumPlanes;
  30330. private _storedFov;
  30331. private _stateStored;
  30332. /**
  30333. * Instantiates a new camera object.
  30334. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30335. * @see http://doc.babylonjs.com/features/cameras
  30336. * @param name Defines the name of the camera in the scene
  30337. * @param position Defines the position of the camera
  30338. * @param scene Defines the scene the camera belongs too
  30339. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30340. */
  30341. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30342. /**
  30343. * Store current camera state (fov, position, etc..)
  30344. * @returns the camera
  30345. */
  30346. storeState(): Camera;
  30347. /**
  30348. * Restores the camera state values if it has been stored. You must call storeState() first
  30349. */
  30350. protected _restoreStateValues(): boolean;
  30351. /**
  30352. * Restored camera state. You must call storeState() first.
  30353. * @returns true if restored and false otherwise
  30354. */
  30355. restoreState(): boolean;
  30356. /**
  30357. * Gets the class name of the camera.
  30358. * @returns the class name
  30359. */
  30360. getClassName(): string;
  30361. /** @hidden */
  30362. readonly _isCamera: boolean;
  30363. /**
  30364. * Gets a string representation of the camera useful for debug purpose.
  30365. * @param fullDetails Defines that a more verboe level of logging is required
  30366. * @returns the string representation
  30367. */
  30368. toString(fullDetails?: boolean): string;
  30369. /**
  30370. * Gets the current world space position of the camera.
  30371. */
  30372. readonly globalPosition: Vector3;
  30373. /**
  30374. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30375. * @returns the active meshe list
  30376. */
  30377. getActiveMeshes(): SmartArray<AbstractMesh>;
  30378. /**
  30379. * Check wether a mesh is part of the current active mesh list of the camera
  30380. * @param mesh Defines the mesh to check
  30381. * @returns true if active, false otherwise
  30382. */
  30383. isActiveMesh(mesh: Mesh): boolean;
  30384. /**
  30385. * Is this camera ready to be used/rendered
  30386. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30387. * @return true if the camera is ready
  30388. */
  30389. isReady(completeCheck?: boolean): boolean;
  30390. /** @hidden */
  30391. _initCache(): void;
  30392. /** @hidden */
  30393. _updateCache(ignoreParentClass?: boolean): void;
  30394. /** @hidden */
  30395. _isSynchronized(): boolean;
  30396. /** @hidden */
  30397. _isSynchronizedViewMatrix(): boolean;
  30398. /** @hidden */
  30399. _isSynchronizedProjectionMatrix(): boolean;
  30400. /**
  30401. * Attach the input controls to a specific dom element to get the input from.
  30402. * @param element Defines the element the controls should be listened from
  30403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30404. */
  30405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30406. /**
  30407. * Detach the current controls from the specified dom element.
  30408. * @param element Defines the element to stop listening the inputs from
  30409. */
  30410. detachControl(element: HTMLElement): void;
  30411. /**
  30412. * Update the camera state according to the different inputs gathered during the frame.
  30413. */
  30414. update(): void;
  30415. /** @hidden */
  30416. _checkInputs(): void;
  30417. /** @hidden */
  30418. readonly rigCameras: Camera[];
  30419. /**
  30420. * Gets the post process used by the rig cameras
  30421. */
  30422. readonly rigPostProcess: Nullable<PostProcess>;
  30423. /**
  30424. * Internal, gets the first post proces.
  30425. * @returns the first post process to be run on this camera.
  30426. */
  30427. _getFirstPostProcess(): Nullable<PostProcess>;
  30428. private _cascadePostProcessesToRigCams;
  30429. /**
  30430. * Attach a post process to the camera.
  30431. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30432. * @param postProcess The post process to attach to the camera
  30433. * @param insertAt The position of the post process in case several of them are in use in the scene
  30434. * @returns the position the post process has been inserted at
  30435. */
  30436. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30437. /**
  30438. * Detach a post process to the camera.
  30439. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30440. * @param postProcess The post process to detach from the camera
  30441. */
  30442. detachPostProcess(postProcess: PostProcess): void;
  30443. /**
  30444. * Gets the current world matrix of the camera
  30445. */
  30446. getWorldMatrix(): Matrix;
  30447. /** @hidden */
  30448. _getViewMatrix(): Matrix;
  30449. /**
  30450. * Gets the current view matrix of the camera.
  30451. * @param force forces the camera to recompute the matrix without looking at the cached state
  30452. * @returns the view matrix
  30453. */
  30454. getViewMatrix(force?: boolean): Matrix;
  30455. /**
  30456. * Freeze the projection matrix.
  30457. * It will prevent the cache check of the camera projection compute and can speed up perf
  30458. * if no parameter of the camera are meant to change
  30459. * @param projection Defines manually a projection if necessary
  30460. */
  30461. freezeProjectionMatrix(projection?: Matrix): void;
  30462. /**
  30463. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30464. */
  30465. unfreezeProjectionMatrix(): void;
  30466. /**
  30467. * Gets the current projection matrix of the camera.
  30468. * @param force forces the camera to recompute the matrix without looking at the cached state
  30469. * @returns the projection matrix
  30470. */
  30471. getProjectionMatrix(force?: boolean): Matrix;
  30472. /**
  30473. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30474. * @returns a Matrix
  30475. */
  30476. getTransformationMatrix(): Matrix;
  30477. private _updateFrustumPlanes;
  30478. /**
  30479. * Checks if a cullable object (mesh...) is in the camera frustum
  30480. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30481. * @param target The object to check
  30482. * @returns true if the object is in frustum otherwise false
  30483. */
  30484. isInFrustum(target: ICullable): boolean;
  30485. /**
  30486. * Checks if a cullable object (mesh...) is in the camera frustum
  30487. * Unlike isInFrustum this cheks the full bounding box
  30488. * @param target The object to check
  30489. * @returns true if the object is in frustum otherwise false
  30490. */
  30491. isCompletelyInFrustum(target: ICullable): boolean;
  30492. /**
  30493. * Gets a ray in the forward direction from the camera.
  30494. * @param length Defines the length of the ray to create
  30495. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30496. * @param origin Defines the start point of the ray which defaults to the camera position
  30497. * @returns the forward ray
  30498. */
  30499. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30500. /**
  30501. * Releases resources associated with this node.
  30502. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30503. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30504. */
  30505. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30506. /** @hidden */
  30507. _isLeftCamera: boolean;
  30508. /**
  30509. * Gets the left camera of a rig setup in case of Rigged Camera
  30510. */
  30511. readonly isLeftCamera: boolean;
  30512. /** @hidden */
  30513. _isRightCamera: boolean;
  30514. /**
  30515. * Gets the right camera of a rig setup in case of Rigged Camera
  30516. */
  30517. readonly isRightCamera: boolean;
  30518. /**
  30519. * Gets the left camera of a rig setup in case of Rigged Camera
  30520. */
  30521. readonly leftCamera: Nullable<FreeCamera>;
  30522. /**
  30523. * Gets the right camera of a rig setup in case of Rigged Camera
  30524. */
  30525. readonly rightCamera: Nullable<FreeCamera>;
  30526. /**
  30527. * Gets the left camera target of a rig setup in case of Rigged Camera
  30528. * @returns the target position
  30529. */
  30530. getLeftTarget(): Nullable<Vector3>;
  30531. /**
  30532. * Gets the right camera target of a rig setup in case of Rigged Camera
  30533. * @returns the target position
  30534. */
  30535. getRightTarget(): Nullable<Vector3>;
  30536. /**
  30537. * @hidden
  30538. */
  30539. setCameraRigMode(mode: number, rigParams: any): void;
  30540. /** @hidden */
  30541. static _setStereoscopicRigMode(camera: Camera): void;
  30542. /** @hidden */
  30543. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30544. /** @hidden */
  30545. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30546. /** @hidden */
  30547. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30548. /** @hidden */
  30549. _getVRProjectionMatrix(): Matrix;
  30550. protected _updateCameraRotationMatrix(): void;
  30551. protected _updateWebVRCameraRotationMatrix(): void;
  30552. /**
  30553. * This function MUST be overwritten by the different WebVR cameras available.
  30554. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30555. * @hidden
  30556. */
  30557. _getWebVRProjectionMatrix(): Matrix;
  30558. /**
  30559. * This function MUST be overwritten by the different WebVR cameras available.
  30560. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30561. * @hidden
  30562. */
  30563. _getWebVRViewMatrix(): Matrix;
  30564. /** @hidden */
  30565. setCameraRigParameter(name: string, value: any): void;
  30566. /**
  30567. * needs to be overridden by children so sub has required properties to be copied
  30568. * @hidden
  30569. */
  30570. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30571. /**
  30572. * May need to be overridden by children
  30573. * @hidden
  30574. */
  30575. _updateRigCameras(): void;
  30576. /** @hidden */
  30577. _setupInputs(): void;
  30578. /**
  30579. * Serialiaze the camera setup to a json represention
  30580. * @returns the JSON representation
  30581. */
  30582. serialize(): any;
  30583. /**
  30584. * Clones the current camera.
  30585. * @param name The cloned camera name
  30586. * @returns the cloned camera
  30587. */
  30588. clone(name: string): Camera;
  30589. /**
  30590. * Gets the direction of the camera relative to a given local axis.
  30591. * @param localAxis Defines the reference axis to provide a relative direction.
  30592. * @return the direction
  30593. */
  30594. getDirection(localAxis: Vector3): Vector3;
  30595. /**
  30596. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30597. * @param localAxis Defines the reference axis to provide a relative direction.
  30598. * @param result Defines the vector to store the result in
  30599. */
  30600. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30601. /**
  30602. * Gets a camera constructor for a given camera type
  30603. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30604. * @param name The name of the camera the result will be able to instantiate
  30605. * @param scene The scene the result will construct the camera in
  30606. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30607. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30608. * @returns a factory method to construc the camera
  30609. */
  30610. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30611. /**
  30612. * Compute the world matrix of the camera.
  30613. * @returns the camera workd matrix
  30614. */
  30615. computeWorldMatrix(): Matrix;
  30616. /**
  30617. * Parse a JSON and creates the camera from the parsed information
  30618. * @param parsedCamera The JSON to parse
  30619. * @param scene The scene to instantiate the camera in
  30620. * @returns the newly constructed camera
  30621. */
  30622. static Parse(parsedCamera: any, scene: Scene): Camera;
  30623. }
  30624. }
  30625. declare module BABYLON {
  30626. /**
  30627. * Interface for any object that can request an animation frame
  30628. */
  30629. export interface ICustomAnimationFrameRequester {
  30630. /**
  30631. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30632. */
  30633. renderFunction?: Function;
  30634. /**
  30635. * Called to request the next frame to render to
  30636. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30637. */
  30638. requestAnimationFrame: Function;
  30639. /**
  30640. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30641. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30642. */
  30643. requestID?: number;
  30644. }
  30645. /**
  30646. * Interface containing an array of animations
  30647. */
  30648. export interface IAnimatable {
  30649. /**
  30650. * Array of animations
  30651. */
  30652. animations: Nullable<Array<Animation>>;
  30653. }
  30654. /** Interface used by value gradients (color, factor, ...) */
  30655. export interface IValueGradient {
  30656. /**
  30657. * Gets or sets the gradient value (between 0 and 1)
  30658. */
  30659. gradient: number;
  30660. }
  30661. /** Class used to store color4 gradient */
  30662. export class ColorGradient implements IValueGradient {
  30663. /**
  30664. * Gets or sets the gradient value (between 0 and 1)
  30665. */
  30666. gradient: number;
  30667. /**
  30668. * Gets or sets first associated color
  30669. */
  30670. color1: Color4;
  30671. /**
  30672. * Gets or sets second associated color
  30673. */
  30674. color2?: Color4;
  30675. /**
  30676. * Will get a color picked randomly between color1 and color2.
  30677. * If color2 is undefined then color1 will be used
  30678. * @param result defines the target Color4 to store the result in
  30679. */
  30680. getColorToRef(result: Color4): void;
  30681. }
  30682. /** Class used to store color 3 gradient */
  30683. export class Color3Gradient implements IValueGradient {
  30684. /**
  30685. * Gets or sets the gradient value (between 0 and 1)
  30686. */
  30687. gradient: number;
  30688. /**
  30689. * Gets or sets the associated color
  30690. */
  30691. color: Color3;
  30692. }
  30693. /** Class used to store factor gradient */
  30694. export class FactorGradient implements IValueGradient {
  30695. /**
  30696. * Gets or sets the gradient value (between 0 and 1)
  30697. */
  30698. gradient: number;
  30699. /**
  30700. * Gets or sets first associated factor
  30701. */
  30702. factor1: number;
  30703. /**
  30704. * Gets or sets second associated factor
  30705. */
  30706. factor2?: number;
  30707. /**
  30708. * Will get a number picked randomly between factor1 and factor2.
  30709. * If factor2 is undefined then factor1 will be used
  30710. * @returns the picked number
  30711. */
  30712. getFactor(): number;
  30713. }
  30714. /**
  30715. * @ignore
  30716. * Application error to support additional information when loading a file
  30717. */
  30718. export class LoadFileError extends Error {
  30719. /** defines the optional web request */
  30720. request?: WebRequest | undefined;
  30721. private static _setPrototypeOf;
  30722. /**
  30723. * Creates a new LoadFileError
  30724. * @param message defines the message of the error
  30725. * @param request defines the optional web request
  30726. */
  30727. constructor(message: string,
  30728. /** defines the optional web request */
  30729. request?: WebRequest | undefined);
  30730. }
  30731. /**
  30732. * Class used to define a retry strategy when error happens while loading assets
  30733. */
  30734. export class RetryStrategy {
  30735. /**
  30736. * Function used to defines an exponential back off strategy
  30737. * @param maxRetries defines the maximum number of retries (3 by default)
  30738. * @param baseInterval defines the interval between retries
  30739. * @returns the strategy function to use
  30740. */
  30741. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30742. }
  30743. /**
  30744. * File request interface
  30745. */
  30746. export interface IFileRequest {
  30747. /**
  30748. * Raised when the request is complete (success or error).
  30749. */
  30750. onCompleteObservable: Observable<IFileRequest>;
  30751. /**
  30752. * Aborts the request for a file.
  30753. */
  30754. abort: () => void;
  30755. }
  30756. /**
  30757. * Class containing a set of static utilities functions
  30758. */
  30759. export class Tools {
  30760. /**
  30761. * Gets or sets the base URL to use to load assets
  30762. */
  30763. static BaseUrl: string;
  30764. /**
  30765. * Enable/Disable Custom HTTP Request Headers globally.
  30766. * default = false
  30767. * @see CustomRequestHeaders
  30768. */
  30769. static UseCustomRequestHeaders: boolean;
  30770. /**
  30771. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30772. * i.e. when loading files, where the server/service expects an Authorization header
  30773. */
  30774. static CustomRequestHeaders: {
  30775. [key: string]: string;
  30776. };
  30777. /**
  30778. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30779. */
  30780. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30781. /**
  30782. * Default behaviour for cors in the application.
  30783. * It can be a string if the expected behavior is identical in the entire app.
  30784. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30785. */
  30786. static CorsBehavior: string | ((url: string | string[]) => string);
  30787. /**
  30788. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30789. * @ignorenaming
  30790. */
  30791. static UseFallbackTexture: boolean;
  30792. /**
  30793. * Use this object to register external classes like custom textures or material
  30794. * to allow the laoders to instantiate them
  30795. */
  30796. static RegisteredExternalClasses: {
  30797. [key: string]: Object;
  30798. };
  30799. /**
  30800. * Texture content used if a texture cannot loaded
  30801. * @ignorenaming
  30802. */
  30803. static fallbackTexture: string;
  30804. /**
  30805. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30806. * @param u defines the coordinate on X axis
  30807. * @param v defines the coordinate on Y axis
  30808. * @param width defines the width of the source data
  30809. * @param height defines the height of the source data
  30810. * @param pixels defines the source byte array
  30811. * @param color defines the output color
  30812. */
  30813. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30814. /**
  30815. * Interpolates between a and b via alpha
  30816. * @param a The lower value (returned when alpha = 0)
  30817. * @param b The upper value (returned when alpha = 1)
  30818. * @param alpha The interpolation-factor
  30819. * @return The mixed value
  30820. */
  30821. static Mix(a: number, b: number, alpha: number): number;
  30822. /**
  30823. * Tries to instantiate a new object from a given class name
  30824. * @param className defines the class name to instantiate
  30825. * @returns the new object or null if the system was not able to do the instantiation
  30826. */
  30827. static Instantiate(className: string): any;
  30828. /**
  30829. * Provides a slice function that will work even on IE
  30830. * @param data defines the array to slice
  30831. * @param start defines the start of the data (optional)
  30832. * @param end defines the end of the data (optional)
  30833. * @returns the new sliced array
  30834. */
  30835. static Slice<T>(data: T, start?: number, end?: number): T;
  30836. /**
  30837. * Polyfill for setImmediate
  30838. * @param action defines the action to execute after the current execution block
  30839. */
  30840. static SetImmediate(action: () => void): void;
  30841. /**
  30842. * Function indicating if a number is an exponent of 2
  30843. * @param value defines the value to test
  30844. * @returns true if the value is an exponent of 2
  30845. */
  30846. static IsExponentOfTwo(value: number): boolean;
  30847. private static _tmpFloatArray;
  30848. /**
  30849. * Returns the nearest 32-bit single precision float representation of a Number
  30850. * @param value A Number. If the parameter is of a different type, it will get converted
  30851. * to a number or to NaN if it cannot be converted
  30852. * @returns number
  30853. */
  30854. static FloatRound(value: number): number;
  30855. /**
  30856. * Find the next highest power of two.
  30857. * @param x Number to start search from.
  30858. * @return Next highest power of two.
  30859. */
  30860. static CeilingPOT(x: number): number;
  30861. /**
  30862. * Find the next lowest power of two.
  30863. * @param x Number to start search from.
  30864. * @return Next lowest power of two.
  30865. */
  30866. static FloorPOT(x: number): number;
  30867. /**
  30868. * Find the nearest power of two.
  30869. * @param x Number to start search from.
  30870. * @return Next nearest power of two.
  30871. */
  30872. static NearestPOT(x: number): number;
  30873. /**
  30874. * Get the closest exponent of two
  30875. * @param value defines the value to approximate
  30876. * @param max defines the maximum value to return
  30877. * @param mode defines how to define the closest value
  30878. * @returns closest exponent of two of the given value
  30879. */
  30880. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30881. /**
  30882. * Extracts the filename from a path
  30883. * @param path defines the path to use
  30884. * @returns the filename
  30885. */
  30886. static GetFilename(path: string): string;
  30887. /**
  30888. * Extracts the "folder" part of a path (everything before the filename).
  30889. * @param uri The URI to extract the info from
  30890. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30891. * @returns The "folder" part of the path
  30892. */
  30893. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30894. /**
  30895. * Extracts text content from a DOM element hierarchy
  30896. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30897. */
  30898. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30899. /**
  30900. * Convert an angle in radians to degrees
  30901. * @param angle defines the angle to convert
  30902. * @returns the angle in degrees
  30903. */
  30904. static ToDegrees(angle: number): number;
  30905. /**
  30906. * Convert an angle in degrees to radians
  30907. * @param angle defines the angle to convert
  30908. * @returns the angle in radians
  30909. */
  30910. static ToRadians(angle: number): number;
  30911. /**
  30912. * Encode a buffer to a base64 string
  30913. * @param buffer defines the buffer to encode
  30914. * @returns the encoded string
  30915. */
  30916. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30917. /**
  30918. * Extracts minimum and maximum values from a list of indexed positions
  30919. * @param positions defines the positions to use
  30920. * @param indices defines the indices to the positions
  30921. * @param indexStart defines the start index
  30922. * @param indexCount defines the end index
  30923. * @param bias defines bias value to add to the result
  30924. * @return minimum and maximum values
  30925. */
  30926. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30927. minimum: Vector3;
  30928. maximum: Vector3;
  30929. };
  30930. /**
  30931. * Extracts minimum and maximum values from a list of positions
  30932. * @param positions defines the positions to use
  30933. * @param start defines the start index in the positions array
  30934. * @param count defines the number of positions to handle
  30935. * @param bias defines bias value to add to the result
  30936. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30937. * @return minimum and maximum values
  30938. */
  30939. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30940. minimum: Vector3;
  30941. maximum: Vector3;
  30942. };
  30943. /**
  30944. * Returns an array if obj is not an array
  30945. * @param obj defines the object to evaluate as an array
  30946. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30947. * @returns either obj directly if obj is an array or a new array containing obj
  30948. */
  30949. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30950. /**
  30951. * Gets the pointer prefix to use
  30952. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30953. */
  30954. static GetPointerPrefix(): string;
  30955. /**
  30956. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30957. * @param func - the function to be called
  30958. * @param requester - the object that will request the next frame. Falls back to window.
  30959. * @returns frame number
  30960. */
  30961. static QueueNewFrame(func: () => void, requester?: any): number;
  30962. /**
  30963. * Ask the browser to promote the current element to fullscreen rendering mode
  30964. * @param element defines the DOM element to promote
  30965. */
  30966. static RequestFullscreen(element: HTMLElement): void;
  30967. /**
  30968. * Asks the browser to exit fullscreen mode
  30969. */
  30970. static ExitFullscreen(): void;
  30971. /**
  30972. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30973. * @param url define the url we are trying
  30974. * @param element define the dom element where to configure the cors policy
  30975. */
  30976. static SetCorsBehavior(url: string | string[], element: {
  30977. crossOrigin: string | null;
  30978. }): void;
  30979. /**
  30980. * Removes unwanted characters from an url
  30981. * @param url defines the url to clean
  30982. * @returns the cleaned url
  30983. */
  30984. static CleanUrl(url: string): string;
  30985. /**
  30986. * Gets or sets a function used to pre-process url before using them to load assets
  30987. */
  30988. static PreprocessUrl: (url: string) => string;
  30989. /**
  30990. * Loads an image as an HTMLImageElement.
  30991. * @param input url string, ArrayBuffer, or Blob to load
  30992. * @param onLoad callback called when the image successfully loads
  30993. * @param onError callback called when the image fails to load
  30994. * @param offlineProvider offline provider for caching
  30995. * @returns the HTMLImageElement of the loaded image
  30996. */
  30997. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30998. /**
  30999. * Loads a file
  31000. * @param url url string, ArrayBuffer, or Blob to load
  31001. * @param onSuccess callback called when the file successfully loads
  31002. * @param onProgress callback called while file is loading (if the server supports this mode)
  31003. * @param offlineProvider defines the offline provider for caching
  31004. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31005. * @param onError callback called when the file fails to load
  31006. * @returns a file request object
  31007. */
  31008. 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;
  31009. /**
  31010. * Load a script (identified by an url). When the url returns, the
  31011. * content of this file is added into a new script element, attached to the DOM (body element)
  31012. * @param scriptUrl defines the url of the script to laod
  31013. * @param onSuccess defines the callback called when the script is loaded
  31014. * @param onError defines the callback to call if an error occurs
  31015. * @param scriptId defines the id of the script element
  31016. */
  31017. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31018. /**
  31019. * Load an asynchronous script (identified by an url). When the url returns, the
  31020. * content of this file is added into a new script element, attached to the DOM (body element)
  31021. * @param scriptUrl defines the url of the script to laod
  31022. * @param scriptId defines the id of the script element
  31023. * @returns a promise request object
  31024. */
  31025. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31026. /**
  31027. * Loads a file from a blob
  31028. * @param fileToLoad defines the blob to use
  31029. * @param callback defines the callback to call when data is loaded
  31030. * @param progressCallback defines the callback to call during loading process
  31031. * @returns a file request object
  31032. */
  31033. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31034. /**
  31035. * Loads a file
  31036. * @param fileToLoad defines the file to load
  31037. * @param callback defines the callback to call when data is loaded
  31038. * @param progressCallBack defines the callback to call during loading process
  31039. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31040. * @returns a file request object
  31041. */
  31042. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31043. /**
  31044. * Creates a data url from a given string content
  31045. * @param content defines the content to convert
  31046. * @returns the new data url link
  31047. */
  31048. static FileAsURL(content: string): string;
  31049. /**
  31050. * Format the given number to a specific decimal format
  31051. * @param value defines the number to format
  31052. * @param decimals defines the number of decimals to use
  31053. * @returns the formatted string
  31054. */
  31055. static Format(value: number, decimals?: number): string;
  31056. /**
  31057. * Checks if a given vector is inside a specific range
  31058. * @param v defines the vector to test
  31059. * @param min defines the minimum range
  31060. * @param max defines the maximum range
  31061. */
  31062. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31063. /**
  31064. * Tries to copy an object by duplicating every property
  31065. * @param source defines the source object
  31066. * @param destination defines the target object
  31067. * @param doNotCopyList defines a list of properties to avoid
  31068. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31069. */
  31070. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31071. /**
  31072. * Gets a boolean indicating if the given object has no own property
  31073. * @param obj defines the object to test
  31074. * @returns true if object has no own property
  31075. */
  31076. static IsEmpty(obj: any): boolean;
  31077. /**
  31078. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31079. * @param str Source string
  31080. * @param suffix Suffix to search for in the source string
  31081. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31082. */
  31083. static EndsWith(str: string, suffix: string): boolean;
  31084. /**
  31085. * Function used to register events at window level
  31086. * @param events defines the events to register
  31087. */
  31088. static RegisterTopRootEvents(events: {
  31089. name: string;
  31090. handler: Nullable<(e: FocusEvent) => any>;
  31091. }[]): void;
  31092. /**
  31093. * Function used to unregister events from window level
  31094. * @param events defines the events to unregister
  31095. */
  31096. static UnregisterTopRootEvents(events: {
  31097. name: string;
  31098. handler: Nullable<(e: FocusEvent) => any>;
  31099. }[]): void;
  31100. /**
  31101. * @ignore
  31102. */
  31103. static _ScreenshotCanvas: HTMLCanvasElement;
  31104. /**
  31105. * Dumps the current bound framebuffer
  31106. * @param width defines the rendering width
  31107. * @param height defines the rendering height
  31108. * @param engine defines the hosting engine
  31109. * @param successCallback defines the callback triggered once the data are available
  31110. * @param mimeType defines the mime type of the result
  31111. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31112. */
  31113. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31114. /**
  31115. * Converts the canvas data to blob.
  31116. * This acts as a polyfill for browsers not supporting the to blob function.
  31117. * @param canvas Defines the canvas to extract the data from
  31118. * @param successCallback Defines the callback triggered once the data are available
  31119. * @param mimeType Defines the mime type of the result
  31120. */
  31121. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31122. /**
  31123. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31124. * @param successCallback defines the callback triggered once the data are available
  31125. * @param mimeType defines the mime type of the result
  31126. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31127. */
  31128. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31129. /**
  31130. * Downloads a blob in the browser
  31131. * @param blob defines the blob to download
  31132. * @param fileName defines the name of the downloaded file
  31133. */
  31134. static Download(blob: Blob, fileName: string): void;
  31135. /**
  31136. * Captures a screenshot of the current rendering
  31137. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31138. * @param engine defines the rendering engine
  31139. * @param camera defines the source camera
  31140. * @param size This parameter can be set to a single number or to an object with the
  31141. * following (optional) properties: precision, width, height. If a single number is passed,
  31142. * it will be used for both width and height. If an object is passed, the screenshot size
  31143. * will be derived from the parameters. The precision property is a multiplier allowing
  31144. * rendering at a higher or lower resolution
  31145. * @param successCallback defines the callback receives a single parameter which contains the
  31146. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31147. * src parameter of an <img> to display it
  31148. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31149. * Check your browser for supported MIME types
  31150. */
  31151. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31152. /**
  31153. * Generates an image screenshot from the specified camera.
  31154. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31155. * @param engine The engine to use for rendering
  31156. * @param camera The camera to use for rendering
  31157. * @param size This parameter can be set to a single number or to an object with the
  31158. * following (optional) properties: precision, width, height. If a single number is passed,
  31159. * it will be used for both width and height. If an object is passed, the screenshot size
  31160. * will be derived from the parameters. The precision property is a multiplier allowing
  31161. * rendering at a higher or lower resolution
  31162. * @param successCallback The callback receives a single parameter which contains the
  31163. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31164. * src parameter of an <img> to display it
  31165. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31166. * Check your browser for supported MIME types
  31167. * @param samples Texture samples (default: 1)
  31168. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31169. * @param fileName A name for for the downloaded file.
  31170. */
  31171. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31172. /**
  31173. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31174. * Be aware Math.random() could cause collisions, but:
  31175. * "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"
  31176. * @returns a pseudo random id
  31177. */
  31178. static RandomId(): string;
  31179. /**
  31180. * Test if the given uri is a base64 string
  31181. * @param uri The uri to test
  31182. * @return True if the uri is a base64 string or false otherwise
  31183. */
  31184. static IsBase64(uri: string): boolean;
  31185. /**
  31186. * Decode the given base64 uri.
  31187. * @param uri The uri to decode
  31188. * @return The decoded base64 data.
  31189. */
  31190. static DecodeBase64(uri: string): ArrayBuffer;
  31191. /**
  31192. * Gets the absolute url.
  31193. * @param url the input url
  31194. * @return the absolute url
  31195. */
  31196. static GetAbsoluteUrl(url: string): string;
  31197. /**
  31198. * No log
  31199. */
  31200. static readonly NoneLogLevel: number;
  31201. /**
  31202. * Only message logs
  31203. */
  31204. static readonly MessageLogLevel: number;
  31205. /**
  31206. * Only warning logs
  31207. */
  31208. static readonly WarningLogLevel: number;
  31209. /**
  31210. * Only error logs
  31211. */
  31212. static readonly ErrorLogLevel: number;
  31213. /**
  31214. * All logs
  31215. */
  31216. static readonly AllLogLevel: number;
  31217. /**
  31218. * Gets a value indicating the number of loading errors
  31219. * @ignorenaming
  31220. */
  31221. static readonly errorsCount: number;
  31222. /**
  31223. * Callback called when a new log is added
  31224. */
  31225. static OnNewCacheEntry: (entry: string) => void;
  31226. /**
  31227. * Log a message to the console
  31228. * @param message defines the message to log
  31229. */
  31230. static Log(message: string): void;
  31231. /**
  31232. * Write a warning message to the console
  31233. * @param message defines the message to log
  31234. */
  31235. static Warn(message: string): void;
  31236. /**
  31237. * Write an error message to the console
  31238. * @param message defines the message to log
  31239. */
  31240. static Error(message: string): void;
  31241. /**
  31242. * Gets current log cache (list of logs)
  31243. */
  31244. static readonly LogCache: string;
  31245. /**
  31246. * Clears the log cache
  31247. */
  31248. static ClearLogCache(): void;
  31249. /**
  31250. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31251. */
  31252. static LogLevels: number;
  31253. /**
  31254. * Checks if the loaded document was accessed via `file:`-Protocol.
  31255. * @returns boolean
  31256. */
  31257. static IsFileURL(): boolean;
  31258. /**
  31259. * Checks if the window object exists
  31260. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31261. */
  31262. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31263. /**
  31264. * No performance log
  31265. */
  31266. static readonly PerformanceNoneLogLevel: number;
  31267. /**
  31268. * Use user marks to log performance
  31269. */
  31270. static readonly PerformanceUserMarkLogLevel: number;
  31271. /**
  31272. * Log performance to the console
  31273. */
  31274. static readonly PerformanceConsoleLogLevel: number;
  31275. private static _performance;
  31276. /**
  31277. * Sets the current performance log level
  31278. */
  31279. static PerformanceLogLevel: number;
  31280. private static _StartPerformanceCounterDisabled;
  31281. private static _EndPerformanceCounterDisabled;
  31282. private static _StartUserMark;
  31283. private static _EndUserMark;
  31284. private static _StartPerformanceConsole;
  31285. private static _EndPerformanceConsole;
  31286. /**
  31287. * Starts a performance counter
  31288. */
  31289. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31290. /**
  31291. * Ends a specific performance coutner
  31292. */
  31293. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31294. /**
  31295. * Gets either window.performance.now() if supported or Date.now() else
  31296. */
  31297. static readonly Now: number;
  31298. /**
  31299. * This method will return the name of the class used to create the instance of the given object.
  31300. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31301. * @param object the object to get the class name from
  31302. * @param isType defines if the object is actually a type
  31303. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31304. */
  31305. static GetClassName(object: any, isType?: boolean): string;
  31306. /**
  31307. * Gets the first element of an array satisfying a given predicate
  31308. * @param array defines the array to browse
  31309. * @param predicate defines the predicate to use
  31310. * @returns null if not found or the element
  31311. */
  31312. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31313. /**
  31314. * This method will return the name of the full name of the class, including its owning module (if any).
  31315. * 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).
  31316. * @param object the object to get the class name from
  31317. * @param isType defines if the object is actually a type
  31318. * @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.
  31319. * @ignorenaming
  31320. */
  31321. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31322. /**
  31323. * Returns a promise that resolves after the given amount of time.
  31324. * @param delay Number of milliseconds to delay
  31325. * @returns Promise that resolves after the given amount of time
  31326. */
  31327. static DelayAsync(delay: number): Promise<void>;
  31328. /**
  31329. * Gets the current gradient from an array of IValueGradient
  31330. * @param ratio defines the current ratio to get
  31331. * @param gradients defines the array of IValueGradient
  31332. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31333. */
  31334. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31335. }
  31336. /**
  31337. * This class is used to track a performance counter which is number based.
  31338. * The user has access to many properties which give statistics of different nature.
  31339. *
  31340. * The implementer can track two kinds of Performance Counter: time and count.
  31341. * 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.
  31342. * 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.
  31343. */
  31344. export class PerfCounter {
  31345. /**
  31346. * Gets or sets a global boolean to turn on and off all the counters
  31347. */
  31348. static Enabled: boolean;
  31349. /**
  31350. * Returns the smallest value ever
  31351. */
  31352. readonly min: number;
  31353. /**
  31354. * Returns the biggest value ever
  31355. */
  31356. readonly max: number;
  31357. /**
  31358. * Returns the average value since the performance counter is running
  31359. */
  31360. readonly average: number;
  31361. /**
  31362. * Returns the average value of the last second the counter was monitored
  31363. */
  31364. readonly lastSecAverage: number;
  31365. /**
  31366. * Returns the current value
  31367. */
  31368. readonly current: number;
  31369. /**
  31370. * Gets the accumulated total
  31371. */
  31372. readonly total: number;
  31373. /**
  31374. * Gets the total value count
  31375. */
  31376. readonly count: number;
  31377. /**
  31378. * Creates a new counter
  31379. */
  31380. constructor();
  31381. /**
  31382. * Call this method to start monitoring a new frame.
  31383. * 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.
  31384. */
  31385. fetchNewFrame(): void;
  31386. /**
  31387. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31388. * @param newCount the count value to add to the monitored count
  31389. * @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.
  31390. */
  31391. addCount(newCount: number, fetchResult: boolean): void;
  31392. /**
  31393. * Start monitoring this performance counter
  31394. */
  31395. beginMonitoring(): void;
  31396. /**
  31397. * Compute the time lapsed since the previous beginMonitoring() call.
  31398. * @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
  31399. */
  31400. endMonitoring(newFrame?: boolean): void;
  31401. private _fetchResult;
  31402. private _startMonitoringTime;
  31403. private _min;
  31404. private _max;
  31405. private _average;
  31406. private _current;
  31407. private _totalValueCount;
  31408. private _totalAccumulated;
  31409. private _lastSecAverage;
  31410. private _lastSecAccumulated;
  31411. private _lastSecTime;
  31412. private _lastSecValueCount;
  31413. }
  31414. /**
  31415. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31416. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31417. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31418. * @param name The name of the class, case should be preserved
  31419. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31420. */
  31421. export function className(name: string, module?: string): (target: Object) => void;
  31422. /**
  31423. * An implementation of a loop for asynchronous functions.
  31424. */
  31425. export class AsyncLoop {
  31426. /**
  31427. * Defines the number of iterations for the loop
  31428. */
  31429. iterations: number;
  31430. /**
  31431. * Defines the current index of the loop.
  31432. */
  31433. index: number;
  31434. private _done;
  31435. private _fn;
  31436. private _successCallback;
  31437. /**
  31438. * Constructor.
  31439. * @param iterations the number of iterations.
  31440. * @param func the function to run each iteration
  31441. * @param successCallback the callback that will be called upon succesful execution
  31442. * @param offset starting offset.
  31443. */
  31444. constructor(
  31445. /**
  31446. * Defines the number of iterations for the loop
  31447. */
  31448. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31449. /**
  31450. * Execute the next iteration. Must be called after the last iteration was finished.
  31451. */
  31452. executeNext(): void;
  31453. /**
  31454. * Break the loop and run the success callback.
  31455. */
  31456. breakLoop(): void;
  31457. /**
  31458. * Create and run an async loop.
  31459. * @param iterations the number of iterations.
  31460. * @param fn the function to run each iteration
  31461. * @param successCallback the callback that will be called upon succesful execution
  31462. * @param offset starting offset.
  31463. * @returns the created async loop object
  31464. */
  31465. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31466. /**
  31467. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31468. * @param iterations total number of iterations
  31469. * @param syncedIterations number of synchronous iterations in each async iteration.
  31470. * @param fn the function to call each iteration.
  31471. * @param callback a success call back that will be called when iterating stops.
  31472. * @param breakFunction a break condition (optional)
  31473. * @param timeout timeout settings for the setTimeout function. default - 0.
  31474. * @returns the created async loop object
  31475. */
  31476. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31477. }
  31478. }
  31479. declare module BABYLON {
  31480. /** @hidden */
  31481. export interface ICollisionCoordinator {
  31482. createCollider(): Collider;
  31483. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31484. init(scene: Scene): void;
  31485. }
  31486. /** @hidden */
  31487. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31488. private _scene;
  31489. private _scaledPosition;
  31490. private _scaledVelocity;
  31491. private _finalPosition;
  31492. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31493. createCollider(): Collider;
  31494. init(scene: Scene): void;
  31495. private _collideWithWorld;
  31496. }
  31497. }
  31498. declare module BABYLON {
  31499. /**
  31500. * This class defines the direct association between an animation and a target
  31501. */
  31502. export class TargetedAnimation {
  31503. /**
  31504. * Animation to perform
  31505. */
  31506. animation: Animation;
  31507. /**
  31508. * Target to animate
  31509. */
  31510. target: any;
  31511. }
  31512. /**
  31513. * Use this class to create coordinated animations on multiple targets
  31514. */
  31515. export class AnimationGroup implements IDisposable {
  31516. /** The name of the animation group */
  31517. name: string;
  31518. private _scene;
  31519. private _targetedAnimations;
  31520. private _animatables;
  31521. private _from;
  31522. private _to;
  31523. private _isStarted;
  31524. private _isPaused;
  31525. private _speedRatio;
  31526. /**
  31527. * Gets or sets the unique id of the node
  31528. */
  31529. uniqueId: number;
  31530. /**
  31531. * This observable will notify when one animation have ended
  31532. */
  31533. onAnimationEndObservable: Observable<TargetedAnimation>;
  31534. /**
  31535. * Observer raised when one animation loops
  31536. */
  31537. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31538. /**
  31539. * This observable will notify when all animations have ended.
  31540. */
  31541. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31542. /**
  31543. * This observable will notify when all animations have paused.
  31544. */
  31545. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31546. /**
  31547. * This observable will notify when all animations are playing.
  31548. */
  31549. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31550. /**
  31551. * Gets the first frame
  31552. */
  31553. readonly from: number;
  31554. /**
  31555. * Gets the last frame
  31556. */
  31557. readonly to: number;
  31558. /**
  31559. * Define if the animations are started
  31560. */
  31561. readonly isStarted: boolean;
  31562. /**
  31563. * Gets a value indicating that the current group is playing
  31564. */
  31565. readonly isPlaying: boolean;
  31566. /**
  31567. * Gets or sets the speed ratio to use for all animations
  31568. */
  31569. /**
  31570. * Gets or sets the speed ratio to use for all animations
  31571. */
  31572. speedRatio: number;
  31573. /**
  31574. * Gets the targeted animations for this animation group
  31575. */
  31576. readonly targetedAnimations: Array<TargetedAnimation>;
  31577. /**
  31578. * returning the list of animatables controlled by this animation group.
  31579. */
  31580. readonly animatables: Array<Animatable>;
  31581. /**
  31582. * Instantiates a new Animation Group.
  31583. * This helps managing several animations at once.
  31584. * @see http://doc.babylonjs.com/how_to/group
  31585. * @param name Defines the name of the group
  31586. * @param scene Defines the scene the group belongs to
  31587. */
  31588. constructor(
  31589. /** The name of the animation group */
  31590. name: string, scene?: Nullable<Scene>);
  31591. /**
  31592. * Add an animation (with its target) in the group
  31593. * @param animation defines the animation we want to add
  31594. * @param target defines the target of the animation
  31595. * @returns the TargetedAnimation object
  31596. */
  31597. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31598. /**
  31599. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31600. * It can add constant keys at begin or end
  31601. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31602. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31603. * @returns the animation group
  31604. */
  31605. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31606. /**
  31607. * Start all animations on given targets
  31608. * @param loop defines if animations must loop
  31609. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31610. * @param from defines the from key (optional)
  31611. * @param to defines the to key (optional)
  31612. * @returns the current animation group
  31613. */
  31614. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31615. /**
  31616. * Pause all animations
  31617. * @returns the animation group
  31618. */
  31619. pause(): AnimationGroup;
  31620. /**
  31621. * Play all animations to initial state
  31622. * This function will start() the animations if they were not started or will restart() them if they were paused
  31623. * @param loop defines if animations must loop
  31624. * @returns the animation group
  31625. */
  31626. play(loop?: boolean): AnimationGroup;
  31627. /**
  31628. * Reset all animations to initial state
  31629. * @returns the animation group
  31630. */
  31631. reset(): AnimationGroup;
  31632. /**
  31633. * Restart animations from key 0
  31634. * @returns the animation group
  31635. */
  31636. restart(): AnimationGroup;
  31637. /**
  31638. * Stop all animations
  31639. * @returns the animation group
  31640. */
  31641. stop(): AnimationGroup;
  31642. /**
  31643. * Set animation weight for all animatables
  31644. * @param weight defines the weight to use
  31645. * @return the animationGroup
  31646. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31647. */
  31648. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31649. /**
  31650. * Synchronize and normalize all animatables with a source animatable
  31651. * @param root defines the root animatable to synchronize with
  31652. * @return the animationGroup
  31653. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31654. */
  31655. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31656. /**
  31657. * Goes to a specific frame in this animation group
  31658. * @param frame the frame number to go to
  31659. * @return the animationGroup
  31660. */
  31661. goToFrame(frame: number): AnimationGroup;
  31662. /**
  31663. * Dispose all associated resources
  31664. */
  31665. dispose(): void;
  31666. private _checkAnimationGroupEnded;
  31667. /**
  31668. * Clone the current animation group and returns a copy
  31669. * @param newName defines the name of the new group
  31670. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31671. * @returns the new aniamtion group
  31672. */
  31673. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31674. /**
  31675. * Returns a new AnimationGroup object parsed from the source provided.
  31676. * @param parsedAnimationGroup defines the source
  31677. * @param scene defines the scene that will receive the animationGroup
  31678. * @returns a new AnimationGroup
  31679. */
  31680. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31681. /**
  31682. * Returns the string "AnimationGroup"
  31683. * @returns "AnimationGroup"
  31684. */
  31685. getClassName(): string;
  31686. /**
  31687. * Creates a detailled string about the object
  31688. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31689. * @returns a string representing the object
  31690. */
  31691. toString(fullDetails?: boolean): string;
  31692. }
  31693. }
  31694. declare module BABYLON {
  31695. /**
  31696. * Define an interface for all classes that will hold resources
  31697. */
  31698. export interface IDisposable {
  31699. /**
  31700. * Releases all held resources
  31701. */
  31702. dispose(): void;
  31703. }
  31704. /** Interface defining initialization parameters for Scene class */
  31705. export interface SceneOptions {
  31706. /**
  31707. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31708. * It will improve performance when the number of geometries becomes important.
  31709. */
  31710. useGeometryUniqueIdsMap?: boolean;
  31711. /**
  31712. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31713. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31714. */
  31715. useMaterialMeshMap?: boolean;
  31716. /**
  31717. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31718. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31719. */
  31720. useClonedMeshhMap?: boolean;
  31721. }
  31722. /**
  31723. * Represents a scene to be rendered by the engine.
  31724. * @see http://doc.babylonjs.com/features/scene
  31725. */
  31726. export class Scene extends AbstractScene implements IAnimatable {
  31727. private static _uniqueIdCounter;
  31728. /** The fog is deactivated */
  31729. static readonly FOGMODE_NONE: number;
  31730. /** The fog density is following an exponential function */
  31731. static readonly FOGMODE_EXP: number;
  31732. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31733. static readonly FOGMODE_EXP2: number;
  31734. /** The fog density is following a linear function. */
  31735. static readonly FOGMODE_LINEAR: number;
  31736. /**
  31737. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31739. */
  31740. static MinDeltaTime: number;
  31741. /**
  31742. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31743. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31744. */
  31745. static MaxDeltaTime: number;
  31746. /**
  31747. * Factory used to create the default material.
  31748. * @param name The name of the material to create
  31749. * @param scene The scene to create the material for
  31750. * @returns The default material
  31751. */
  31752. static DefaultMaterialFactory(scene: Scene): Material;
  31753. /**
  31754. * Factory used to create the a collision coordinator.
  31755. * @returns The collision coordinator
  31756. */
  31757. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31758. /** @hidden */
  31759. readonly _isScene: boolean;
  31760. /**
  31761. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31762. */
  31763. autoClear: boolean;
  31764. /**
  31765. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31766. */
  31767. autoClearDepthAndStencil: boolean;
  31768. /**
  31769. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31770. */
  31771. clearColor: Color4;
  31772. /**
  31773. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31774. */
  31775. ambientColor: Color3;
  31776. /**
  31777. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31778. * It should only be one of the following (if not the default embedded one):
  31779. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31780. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31781. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31782. * The material properties need to be setup according to the type of texture in use.
  31783. */
  31784. environmentBRDFTexture: BaseTexture;
  31785. /** @hidden */
  31786. protected _environmentTexture: Nullable<BaseTexture>;
  31787. /**
  31788. * Texture used in all pbr material as the reflection texture.
  31789. * As in the majority of the scene they are the same (exception for multi room and so on),
  31790. * this is easier to reference from here than from all the materials.
  31791. */
  31792. /**
  31793. * Texture used in all pbr material as the reflection texture.
  31794. * As in the majority of the scene they are the same (exception for multi room and so on),
  31795. * this is easier to set here than in all the materials.
  31796. */
  31797. environmentTexture: Nullable<BaseTexture>;
  31798. /** @hidden */
  31799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31800. /**
  31801. * Default image processing configuration used either in the rendering
  31802. * Forward main pass or through the imageProcessingPostProcess if present.
  31803. * As in the majority of the scene they are the same (exception for multi camera),
  31804. * this is easier to reference from here than from all the materials and post process.
  31805. *
  31806. * No setter as we it is a shared configuration, you can set the values instead.
  31807. */
  31808. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31809. private _forceWireframe;
  31810. /**
  31811. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31812. */
  31813. forceWireframe: boolean;
  31814. private _forcePointsCloud;
  31815. /**
  31816. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31817. */
  31818. forcePointsCloud: boolean;
  31819. /**
  31820. * Gets or sets the active clipplane 1
  31821. */
  31822. clipPlane: Nullable<Plane>;
  31823. /**
  31824. * Gets or sets the active clipplane 2
  31825. */
  31826. clipPlane2: Nullable<Plane>;
  31827. /**
  31828. * Gets or sets the active clipplane 3
  31829. */
  31830. clipPlane3: Nullable<Plane>;
  31831. /**
  31832. * Gets or sets the active clipplane 4
  31833. */
  31834. clipPlane4: Nullable<Plane>;
  31835. /**
  31836. * Gets or sets a boolean indicating if animations are enabled
  31837. */
  31838. animationsEnabled: boolean;
  31839. private _animationPropertiesOverride;
  31840. /**
  31841. * Gets or sets the animation properties override
  31842. */
  31843. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31844. /**
  31845. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31846. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31847. */
  31848. useConstantAnimationDeltaTime: boolean;
  31849. /**
  31850. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31851. * Please note that it requires to run a ray cast through the scene on every frame
  31852. */
  31853. constantlyUpdateMeshUnderPointer: boolean;
  31854. /**
  31855. * Defines the HTML cursor to use when hovering over interactive elements
  31856. */
  31857. hoverCursor: string;
  31858. /**
  31859. * Defines the HTML default cursor to use (empty by default)
  31860. */
  31861. defaultCursor: string;
  31862. /**
  31863. * This is used to call preventDefault() on pointer down
  31864. * in order to block unwanted artifacts like system double clicks
  31865. */
  31866. preventDefaultOnPointerDown: boolean;
  31867. /**
  31868. * This is used to call preventDefault() on pointer up
  31869. * in order to block unwanted artifacts like system double clicks
  31870. */
  31871. preventDefaultOnPointerUp: boolean;
  31872. /**
  31873. * Gets or sets user defined metadata
  31874. */
  31875. metadata: any;
  31876. /**
  31877. * For internal use only. Please do not use.
  31878. */
  31879. reservedDataStore: any;
  31880. /**
  31881. * Gets the name of the plugin used to load this scene (null by default)
  31882. */
  31883. loadingPluginName: string;
  31884. /**
  31885. * Use this array to add regular expressions used to disable offline support for specific urls
  31886. */
  31887. disableOfflineSupportExceptionRules: RegExp[];
  31888. /**
  31889. * An event triggered when the scene is disposed.
  31890. */
  31891. onDisposeObservable: Observable<Scene>;
  31892. private _onDisposeObserver;
  31893. /** Sets a function to be executed when this scene is disposed. */
  31894. onDispose: () => void;
  31895. /**
  31896. * An event triggered before rendering the scene (right after animations and physics)
  31897. */
  31898. onBeforeRenderObservable: Observable<Scene>;
  31899. private _onBeforeRenderObserver;
  31900. /** Sets a function to be executed before rendering this scene */
  31901. beforeRender: Nullable<() => void>;
  31902. /**
  31903. * An event triggered after rendering the scene
  31904. */
  31905. onAfterRenderObservable: Observable<Scene>;
  31906. private _onAfterRenderObserver;
  31907. /** Sets a function to be executed after rendering this scene */
  31908. afterRender: Nullable<() => void>;
  31909. /**
  31910. * An event triggered before animating the scene
  31911. */
  31912. onBeforeAnimationsObservable: Observable<Scene>;
  31913. /**
  31914. * An event triggered after animations processing
  31915. */
  31916. onAfterAnimationsObservable: Observable<Scene>;
  31917. /**
  31918. * An event triggered before draw calls are ready to be sent
  31919. */
  31920. onBeforeDrawPhaseObservable: Observable<Scene>;
  31921. /**
  31922. * An event triggered after draw calls have been sent
  31923. */
  31924. onAfterDrawPhaseObservable: Observable<Scene>;
  31925. /**
  31926. * An event triggered when the scene is ready
  31927. */
  31928. onReadyObservable: Observable<Scene>;
  31929. /**
  31930. * An event triggered before rendering a camera
  31931. */
  31932. onBeforeCameraRenderObservable: Observable<Camera>;
  31933. private _onBeforeCameraRenderObserver;
  31934. /** Sets a function to be executed before rendering a camera*/
  31935. beforeCameraRender: () => void;
  31936. /**
  31937. * An event triggered after rendering a camera
  31938. */
  31939. onAfterCameraRenderObservable: Observable<Camera>;
  31940. private _onAfterCameraRenderObserver;
  31941. /** Sets a function to be executed after rendering a camera*/
  31942. afterCameraRender: () => void;
  31943. /**
  31944. * An event triggered when active meshes evaluation is about to start
  31945. */
  31946. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31947. /**
  31948. * An event triggered when active meshes evaluation is done
  31949. */
  31950. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31951. /**
  31952. * An event triggered when particles rendering is about to start
  31953. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31954. */
  31955. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31956. /**
  31957. * An event triggered when particles rendering is done
  31958. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31959. */
  31960. onAfterParticlesRenderingObservable: Observable<Scene>;
  31961. /**
  31962. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31963. */
  31964. onDataLoadedObservable: Observable<Scene>;
  31965. /**
  31966. * An event triggered when a camera is created
  31967. */
  31968. onNewCameraAddedObservable: Observable<Camera>;
  31969. /**
  31970. * An event triggered when a camera is removed
  31971. */
  31972. onCameraRemovedObservable: Observable<Camera>;
  31973. /**
  31974. * An event triggered when a light is created
  31975. */
  31976. onNewLightAddedObservable: Observable<Light>;
  31977. /**
  31978. * An event triggered when a light is removed
  31979. */
  31980. onLightRemovedObservable: Observable<Light>;
  31981. /**
  31982. * An event triggered when a geometry is created
  31983. */
  31984. onNewGeometryAddedObservable: Observable<Geometry>;
  31985. /**
  31986. * An event triggered when a geometry is removed
  31987. */
  31988. onGeometryRemovedObservable: Observable<Geometry>;
  31989. /**
  31990. * An event triggered when a transform node is created
  31991. */
  31992. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31993. /**
  31994. * An event triggered when a transform node is removed
  31995. */
  31996. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31997. /**
  31998. * An event triggered when a mesh is created
  31999. */
  32000. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32001. /**
  32002. * An event triggered when a mesh is removed
  32003. */
  32004. onMeshRemovedObservable: Observable<AbstractMesh>;
  32005. /**
  32006. * An event triggered when a skeleton is created
  32007. */
  32008. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32009. /**
  32010. * An event triggered when a skeleton is removed
  32011. */
  32012. onSkeletonRemovedObservable: Observable<Skeleton>;
  32013. /**
  32014. * An event triggered when a material is created
  32015. */
  32016. onNewMaterialAddedObservable: Observable<Material>;
  32017. /**
  32018. * An event triggered when a material is removed
  32019. */
  32020. onMaterialRemovedObservable: Observable<Material>;
  32021. /**
  32022. * An event triggered when a texture is created
  32023. */
  32024. onNewTextureAddedObservable: Observable<BaseTexture>;
  32025. /**
  32026. * An event triggered when a texture is removed
  32027. */
  32028. onTextureRemovedObservable: Observable<BaseTexture>;
  32029. /**
  32030. * An event triggered when render targets are about to be rendered
  32031. * Can happen multiple times per frame.
  32032. */
  32033. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32034. /**
  32035. * An event triggered when render targets were rendered.
  32036. * Can happen multiple times per frame.
  32037. */
  32038. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32039. /**
  32040. * An event triggered before calculating deterministic simulation step
  32041. */
  32042. onBeforeStepObservable: Observable<Scene>;
  32043. /**
  32044. * An event triggered after calculating deterministic simulation step
  32045. */
  32046. onAfterStepObservable: Observable<Scene>;
  32047. /**
  32048. * An event triggered when the activeCamera property is updated
  32049. */
  32050. onActiveCameraChanged: Observable<Scene>;
  32051. /**
  32052. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32053. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32054. * 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)
  32055. */
  32056. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32057. /**
  32058. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32059. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32060. * 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)
  32061. */
  32062. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32063. /**
  32064. * This Observable will when a mesh has been imported into the scene.
  32065. */
  32066. onMeshImportedObservable: Observable<AbstractMesh>;
  32067. /**
  32068. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32069. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32070. */
  32071. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32072. /** @hidden */
  32073. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32074. /**
  32075. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32076. */
  32077. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32078. /**
  32079. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32080. */
  32081. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32082. /**
  32083. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32084. */
  32085. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32086. private _onPointerMove;
  32087. private _onPointerDown;
  32088. private _onPointerUp;
  32089. /** Callback called when a pointer move is detected */
  32090. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32091. /** Callback called when a pointer down is detected */
  32092. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32093. /** Callback called when a pointer up is detected */
  32094. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32095. /** Callback called when a pointer pick is detected */
  32096. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32097. /**
  32098. * 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).
  32099. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32100. */
  32101. onPrePointerObservable: Observable<PointerInfoPre>;
  32102. /**
  32103. * Observable event triggered each time an input event is received from the rendering canvas
  32104. */
  32105. onPointerObservable: Observable<PointerInfo>;
  32106. /**
  32107. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32108. */
  32109. readonly unTranslatedPointer: Vector2;
  32110. /** The distance in pixel that you have to move to prevent some events */
  32111. static DragMovementThreshold: number;
  32112. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32113. static LongPressDelay: number;
  32114. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32115. static DoubleClickDelay: number;
  32116. /** If you need to check double click without raising a single click at first click, enable this flag */
  32117. static ExclusiveDoubleClickMode: boolean;
  32118. private _initClickEvent;
  32119. private _initActionManager;
  32120. private _delayedSimpleClick;
  32121. private _delayedSimpleClickTimeout;
  32122. private _previousDelayedSimpleClickTimeout;
  32123. private _meshPickProceed;
  32124. private _previousButtonPressed;
  32125. private _currentPickResult;
  32126. private _previousPickResult;
  32127. private _totalPointersPressed;
  32128. private _doubleClickOccured;
  32129. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32130. cameraToUseForPointers: Nullable<Camera>;
  32131. private _pointerX;
  32132. private _pointerY;
  32133. private _unTranslatedPointerX;
  32134. private _unTranslatedPointerY;
  32135. private _startingPointerPosition;
  32136. private _previousStartingPointerPosition;
  32137. private _startingPointerTime;
  32138. private _previousStartingPointerTime;
  32139. private _pointerCaptures;
  32140. private _timeAccumulator;
  32141. private _currentStepId;
  32142. private _currentInternalStep;
  32143. /** @hidden */
  32144. _mirroredCameraPosition: Nullable<Vector3>;
  32145. /**
  32146. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32147. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32148. */
  32149. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32150. /**
  32151. * Observable event triggered each time an keyboard event is received from the hosting window
  32152. */
  32153. onKeyboardObservable: Observable<KeyboardInfo>;
  32154. private _onKeyDown;
  32155. private _onKeyUp;
  32156. private _onCanvasFocusObserver;
  32157. private _onCanvasBlurObserver;
  32158. private _useRightHandedSystem;
  32159. /**
  32160. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32161. */
  32162. useRightHandedSystem: boolean;
  32163. /**
  32164. * Sets the step Id used by deterministic lock step
  32165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32166. * @param newStepId defines the step Id
  32167. */
  32168. setStepId(newStepId: number): void;
  32169. /**
  32170. * Gets the step Id used by deterministic lock step
  32171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32172. * @returns the step Id
  32173. */
  32174. getStepId(): number;
  32175. /**
  32176. * Gets the internal step used by deterministic lock step
  32177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32178. * @returns the internal step
  32179. */
  32180. getInternalStep(): number;
  32181. private _fogEnabled;
  32182. /**
  32183. * Gets or sets a boolean indicating if fog is enabled on this scene
  32184. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32185. * (Default is true)
  32186. */
  32187. fogEnabled: boolean;
  32188. private _fogMode;
  32189. /**
  32190. * Gets or sets the fog mode to use
  32191. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32192. * | mode | value |
  32193. * | --- | --- |
  32194. * | FOGMODE_NONE | 0 |
  32195. * | FOGMODE_EXP | 1 |
  32196. * | FOGMODE_EXP2 | 2 |
  32197. * | FOGMODE_LINEAR | 3 |
  32198. */
  32199. fogMode: number;
  32200. /**
  32201. * Gets or sets the fog color to use
  32202. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32203. * (Default is Color3(0.2, 0.2, 0.3))
  32204. */
  32205. fogColor: Color3;
  32206. /**
  32207. * Gets or sets the fog density to use
  32208. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32209. * (Default is 0.1)
  32210. */
  32211. fogDensity: number;
  32212. /**
  32213. * Gets or sets the fog start distance to use
  32214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32215. * (Default is 0)
  32216. */
  32217. fogStart: number;
  32218. /**
  32219. * Gets or sets the fog end distance to use
  32220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32221. * (Default is 1000)
  32222. */
  32223. fogEnd: number;
  32224. private _shadowsEnabled;
  32225. /**
  32226. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32227. */
  32228. shadowsEnabled: boolean;
  32229. private _lightsEnabled;
  32230. /**
  32231. * Gets or sets a boolean indicating if lights are enabled on this scene
  32232. */
  32233. lightsEnabled: boolean;
  32234. /** All of the active cameras added to this scene. */
  32235. activeCameras: Camera[];
  32236. /** @hidden */
  32237. _activeCamera: Nullable<Camera>;
  32238. /** Gets or sets the current active camera */
  32239. activeCamera: Nullable<Camera>;
  32240. private _defaultMaterial;
  32241. /** The default material used on meshes when no material is affected */
  32242. /** The default material used on meshes when no material is affected */
  32243. defaultMaterial: Material;
  32244. private _texturesEnabled;
  32245. /**
  32246. * Gets or sets a boolean indicating if textures are enabled on this scene
  32247. */
  32248. texturesEnabled: boolean;
  32249. /**
  32250. * Gets or sets a boolean indicating if particles are enabled on this scene
  32251. */
  32252. particlesEnabled: boolean;
  32253. /**
  32254. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32255. */
  32256. spritesEnabled: boolean;
  32257. private _skeletonsEnabled;
  32258. /**
  32259. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32260. */
  32261. skeletonsEnabled: boolean;
  32262. /**
  32263. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32264. */
  32265. lensFlaresEnabled: boolean;
  32266. /**
  32267. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32268. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32269. */
  32270. collisionsEnabled: boolean;
  32271. private _collisionCoordinator;
  32272. /** @hidden */
  32273. readonly collisionCoordinator: ICollisionCoordinator;
  32274. /**
  32275. * Defines the gravity applied to this scene (used only for collisions)
  32276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32277. */
  32278. gravity: Vector3;
  32279. /**
  32280. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32281. */
  32282. postProcessesEnabled: boolean;
  32283. /**
  32284. * The list of postprocesses added to the scene
  32285. */
  32286. postProcesses: PostProcess[];
  32287. /**
  32288. * Gets the current postprocess manager
  32289. */
  32290. postProcessManager: PostProcessManager;
  32291. /**
  32292. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32293. */
  32294. renderTargetsEnabled: boolean;
  32295. /**
  32296. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32297. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32298. */
  32299. dumpNextRenderTargets: boolean;
  32300. /**
  32301. * The list of user defined render targets added to the scene
  32302. */
  32303. customRenderTargets: RenderTargetTexture[];
  32304. /**
  32305. * Defines if texture loading must be delayed
  32306. * If true, textures will only be loaded when they need to be rendered
  32307. */
  32308. useDelayedTextureLoading: boolean;
  32309. /**
  32310. * Gets the list of meshes imported to the scene through SceneLoader
  32311. */
  32312. importedMeshesFiles: String[];
  32313. /**
  32314. * Gets or sets a boolean indicating if probes are enabled on this scene
  32315. */
  32316. probesEnabled: boolean;
  32317. /**
  32318. * Gets or sets the current offline provider to use to store scene data
  32319. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32320. */
  32321. offlineProvider: IOfflineProvider;
  32322. /**
  32323. * Gets or sets the action manager associated with the scene
  32324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32325. */
  32326. actionManager: AbstractActionManager;
  32327. private _meshesForIntersections;
  32328. /**
  32329. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32330. */
  32331. proceduralTexturesEnabled: boolean;
  32332. private _engine;
  32333. private _totalVertices;
  32334. /** @hidden */
  32335. _activeIndices: PerfCounter;
  32336. /** @hidden */
  32337. _activeParticles: PerfCounter;
  32338. /** @hidden */
  32339. _activeBones: PerfCounter;
  32340. private _animationRatio;
  32341. /** @hidden */
  32342. _animationTimeLast: number;
  32343. /** @hidden */
  32344. _animationTime: number;
  32345. /**
  32346. * Gets or sets a general scale for animation speed
  32347. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32348. */
  32349. animationTimeScale: number;
  32350. /** @hidden */
  32351. _cachedMaterial: Nullable<Material>;
  32352. /** @hidden */
  32353. _cachedEffect: Nullable<Effect>;
  32354. /** @hidden */
  32355. _cachedVisibility: Nullable<number>;
  32356. private _renderId;
  32357. private _frameId;
  32358. private _executeWhenReadyTimeoutId;
  32359. private _intermediateRendering;
  32360. private _viewUpdateFlag;
  32361. private _projectionUpdateFlag;
  32362. /** @hidden */
  32363. _toBeDisposed: Nullable<IDisposable>[];
  32364. private _activeRequests;
  32365. /** @hidden */
  32366. _pendingData: any[];
  32367. private _isDisposed;
  32368. /**
  32369. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32370. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32371. */
  32372. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32373. private _activeMeshes;
  32374. private _processedMaterials;
  32375. private _renderTargets;
  32376. /** @hidden */
  32377. _activeParticleSystems: SmartArray<IParticleSystem>;
  32378. private _activeSkeletons;
  32379. private _softwareSkinnedMeshes;
  32380. private _renderingManager;
  32381. /** @hidden */
  32382. _activeAnimatables: Animatable[];
  32383. private _transformMatrix;
  32384. private _sceneUbo;
  32385. /** @hidden */
  32386. _viewMatrix: Matrix;
  32387. private _projectionMatrix;
  32388. private _wheelEventName;
  32389. /** @hidden */
  32390. _forcedViewPosition: Nullable<Vector3>;
  32391. /** @hidden */
  32392. _frustumPlanes: Plane[];
  32393. /**
  32394. * Gets the list of frustum planes (built from the active camera)
  32395. */
  32396. readonly frustumPlanes: Plane[];
  32397. /**
  32398. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32399. * This is useful if there are more lights that the maximum simulteanous authorized
  32400. */
  32401. requireLightSorting: boolean;
  32402. /** @hidden */
  32403. readonly useMaterialMeshMap: boolean;
  32404. /** @hidden */
  32405. readonly useClonedMeshhMap: boolean;
  32406. private _pointerOverMesh;
  32407. private _pickedDownMesh;
  32408. private _pickedUpMesh;
  32409. private _externalData;
  32410. private _uid;
  32411. /**
  32412. * @hidden
  32413. * Backing store of defined scene components.
  32414. */
  32415. _components: ISceneComponent[];
  32416. /**
  32417. * @hidden
  32418. * Backing store of defined scene components.
  32419. */
  32420. _serializableComponents: ISceneSerializableComponent[];
  32421. /**
  32422. * List of components to register on the next registration step.
  32423. */
  32424. private _transientComponents;
  32425. /**
  32426. * Registers the transient components if needed.
  32427. */
  32428. private _registerTransientComponents;
  32429. /**
  32430. * @hidden
  32431. * Add a component to the scene.
  32432. * Note that the ccomponent could be registered on th next frame if this is called after
  32433. * the register component stage.
  32434. * @param component Defines the component to add to the scene
  32435. */
  32436. _addComponent(component: ISceneComponent): void;
  32437. /**
  32438. * @hidden
  32439. * Gets a component from the scene.
  32440. * @param name defines the name of the component to retrieve
  32441. * @returns the component or null if not present
  32442. */
  32443. _getComponent(name: string): Nullable<ISceneComponent>;
  32444. /**
  32445. * @hidden
  32446. * Defines the actions happening before camera updates.
  32447. */
  32448. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32449. /**
  32450. * @hidden
  32451. * Defines the actions happening before clear the canvas.
  32452. */
  32453. _beforeClearStage: Stage<SimpleStageAction>;
  32454. /**
  32455. * @hidden
  32456. * Defines the actions when collecting render targets for the frame.
  32457. */
  32458. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32459. /**
  32460. * @hidden
  32461. * Defines the actions happening for one camera in the frame.
  32462. */
  32463. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32464. /**
  32465. * @hidden
  32466. * Defines the actions happening during the per mesh ready checks.
  32467. */
  32468. _isReadyForMeshStage: Stage<MeshStageAction>;
  32469. /**
  32470. * @hidden
  32471. * Defines the actions happening before evaluate active mesh checks.
  32472. */
  32473. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32474. /**
  32475. * @hidden
  32476. * Defines the actions happening during the evaluate sub mesh checks.
  32477. */
  32478. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32479. /**
  32480. * @hidden
  32481. * Defines the actions happening during the active mesh stage.
  32482. */
  32483. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32484. /**
  32485. * @hidden
  32486. * Defines the actions happening during the per camera render target step.
  32487. */
  32488. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32489. /**
  32490. * @hidden
  32491. * Defines the actions happening just before the active camera is drawing.
  32492. */
  32493. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32494. /**
  32495. * @hidden
  32496. * Defines the actions happening just before a render target is drawing.
  32497. */
  32498. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32499. /**
  32500. * @hidden
  32501. * Defines the actions happening just before a rendering group is drawing.
  32502. */
  32503. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32504. /**
  32505. * @hidden
  32506. * Defines the actions happening just before a mesh is drawing.
  32507. */
  32508. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32509. /**
  32510. * @hidden
  32511. * Defines the actions happening just after a mesh has been drawn.
  32512. */
  32513. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32514. /**
  32515. * @hidden
  32516. * Defines the actions happening just after a rendering group has been drawn.
  32517. */
  32518. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32519. /**
  32520. * @hidden
  32521. * Defines the actions happening just after the active camera has been drawn.
  32522. */
  32523. _afterCameraDrawStage: Stage<CameraStageAction>;
  32524. /**
  32525. * @hidden
  32526. * Defines the actions happening just after a render target has been drawn.
  32527. */
  32528. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32529. /**
  32530. * @hidden
  32531. * Defines the actions happening just after rendering all cameras and computing intersections.
  32532. */
  32533. _afterRenderStage: Stage<SimpleStageAction>;
  32534. /**
  32535. * @hidden
  32536. * Defines the actions happening when a pointer move event happens.
  32537. */
  32538. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32539. /**
  32540. * @hidden
  32541. * Defines the actions happening when a pointer down event happens.
  32542. */
  32543. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32544. /**
  32545. * @hidden
  32546. * Defines the actions happening when a pointer up event happens.
  32547. */
  32548. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32549. /**
  32550. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32551. */
  32552. private geometriesByUniqueId;
  32553. /**
  32554. * Creates a new Scene
  32555. * @param engine defines the engine to use to render this scene
  32556. * @param options defines the scene options
  32557. */
  32558. constructor(engine: Engine, options?: SceneOptions);
  32559. /**
  32560. * Gets a string idenfifying the name of the class
  32561. * @returns "Scene" string
  32562. */
  32563. getClassName(): string;
  32564. private _defaultMeshCandidates;
  32565. /**
  32566. * @hidden
  32567. */
  32568. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32569. private _defaultSubMeshCandidates;
  32570. /**
  32571. * @hidden
  32572. */
  32573. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32574. /**
  32575. * Sets the default candidate providers for the scene.
  32576. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32577. * and getCollidingSubMeshCandidates to their default function
  32578. */
  32579. setDefaultCandidateProviders(): void;
  32580. /**
  32581. * Gets the mesh that is currently under the pointer
  32582. */
  32583. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32584. /**
  32585. * Gets or sets the current on-screen X position of the pointer
  32586. */
  32587. pointerX: number;
  32588. /**
  32589. * Gets or sets the current on-screen Y position of the pointer
  32590. */
  32591. pointerY: number;
  32592. /**
  32593. * Gets the cached material (ie. the latest rendered one)
  32594. * @returns the cached material
  32595. */
  32596. getCachedMaterial(): Nullable<Material>;
  32597. /**
  32598. * Gets the cached effect (ie. the latest rendered one)
  32599. * @returns the cached effect
  32600. */
  32601. getCachedEffect(): Nullable<Effect>;
  32602. /**
  32603. * Gets the cached visibility state (ie. the latest rendered one)
  32604. * @returns the cached visibility state
  32605. */
  32606. getCachedVisibility(): Nullable<number>;
  32607. /**
  32608. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32609. * @param material defines the current material
  32610. * @param effect defines the current effect
  32611. * @param visibility defines the current visibility state
  32612. * @returns true if one parameter is not cached
  32613. */
  32614. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32615. /**
  32616. * Gets the engine associated with the scene
  32617. * @returns an Engine
  32618. */
  32619. getEngine(): Engine;
  32620. /**
  32621. * Gets the total number of vertices rendered per frame
  32622. * @returns the total number of vertices rendered per frame
  32623. */
  32624. getTotalVertices(): number;
  32625. /**
  32626. * Gets the performance counter for total vertices
  32627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32628. */
  32629. readonly totalVerticesPerfCounter: PerfCounter;
  32630. /**
  32631. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32632. * @returns the total number of active indices rendered per frame
  32633. */
  32634. getActiveIndices(): number;
  32635. /**
  32636. * Gets the performance counter for active indices
  32637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32638. */
  32639. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32640. /**
  32641. * Gets the total number of active particles rendered per frame
  32642. * @returns the total number of active particles rendered per frame
  32643. */
  32644. getActiveParticles(): number;
  32645. /**
  32646. * Gets the performance counter for active particles
  32647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32648. */
  32649. readonly activeParticlesPerfCounter: PerfCounter;
  32650. /**
  32651. * Gets the total number of active bones rendered per frame
  32652. * @returns the total number of active bones rendered per frame
  32653. */
  32654. getActiveBones(): number;
  32655. /**
  32656. * Gets the performance counter for active bones
  32657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32658. */
  32659. readonly activeBonesPerfCounter: PerfCounter;
  32660. /**
  32661. * Gets the array of active meshes
  32662. * @returns an array of AbstractMesh
  32663. */
  32664. getActiveMeshes(): SmartArray<AbstractMesh>;
  32665. /**
  32666. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32667. * @returns a number
  32668. */
  32669. getAnimationRatio(): number;
  32670. /**
  32671. * Gets an unique Id for the current render phase
  32672. * @returns a number
  32673. */
  32674. getRenderId(): number;
  32675. /**
  32676. * Gets an unique Id for the current frame
  32677. * @returns a number
  32678. */
  32679. getFrameId(): number;
  32680. /** Call this function if you want to manually increment the render Id*/
  32681. incrementRenderId(): void;
  32682. private _updatePointerPosition;
  32683. private _createUbo;
  32684. private _setRayOnPointerInfo;
  32685. /**
  32686. * Use this method to simulate a pointer move on a mesh
  32687. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32688. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32689. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32690. * @returns the current scene
  32691. */
  32692. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32693. private _processPointerMove;
  32694. private _checkPrePointerObservable;
  32695. /**
  32696. * Use this method to simulate a pointer down on a mesh
  32697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32700. * @returns the current scene
  32701. */
  32702. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32703. private _processPointerDown;
  32704. /**
  32705. * Use this method to simulate a pointer up on a mesh
  32706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32709. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32710. * @returns the current scene
  32711. */
  32712. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32713. private _processPointerUp;
  32714. /**
  32715. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32716. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32717. * @returns true if the pointer was captured
  32718. */
  32719. isPointerCaptured(pointerId?: number): boolean;
  32720. /** @hidden */
  32721. _isPointerSwiping(): boolean;
  32722. /**
  32723. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32724. * @param attachUp defines if you want to attach events to pointerup
  32725. * @param attachDown defines if you want to attach events to pointerdown
  32726. * @param attachMove defines if you want to attach events to pointermove
  32727. */
  32728. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32729. /** Detaches all event handlers*/
  32730. detachControl(): void;
  32731. /**
  32732. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32733. * Delay loaded resources are not taking in account
  32734. * @return true if all required resources are ready
  32735. */
  32736. isReady(): boolean;
  32737. /** Resets all cached information relative to material (including effect and visibility) */
  32738. resetCachedMaterial(): void;
  32739. /**
  32740. * Registers a function to be called before every frame render
  32741. * @param func defines the function to register
  32742. */
  32743. registerBeforeRender(func: () => void): void;
  32744. /**
  32745. * Unregisters a function called before every frame render
  32746. * @param func defines the function to unregister
  32747. */
  32748. unregisterBeforeRender(func: () => void): void;
  32749. /**
  32750. * Registers a function to be called after every frame render
  32751. * @param func defines the function to register
  32752. */
  32753. registerAfterRender(func: () => void): void;
  32754. /**
  32755. * Unregisters a function called after every frame render
  32756. * @param func defines the function to unregister
  32757. */
  32758. unregisterAfterRender(func: () => void): void;
  32759. private _executeOnceBeforeRender;
  32760. /**
  32761. * The provided function will run before render once and will be disposed afterwards.
  32762. * A timeout delay can be provided so that the function will be executed in N ms.
  32763. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32764. * @param func The function to be executed.
  32765. * @param timeout optional delay in ms
  32766. */
  32767. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32768. /** @hidden */
  32769. _addPendingData(data: any): void;
  32770. /** @hidden */
  32771. _removePendingData(data: any): void;
  32772. /**
  32773. * Returns the number of items waiting to be loaded
  32774. * @returns the number of items waiting to be loaded
  32775. */
  32776. getWaitingItemsCount(): number;
  32777. /**
  32778. * Returns a boolean indicating if the scene is still loading data
  32779. */
  32780. readonly isLoading: boolean;
  32781. /**
  32782. * Registers a function to be executed when the scene is ready
  32783. * @param {Function} func - the function to be executed
  32784. */
  32785. executeWhenReady(func: () => void): void;
  32786. /**
  32787. * Returns a promise that resolves when the scene is ready
  32788. * @returns A promise that resolves when the scene is ready
  32789. */
  32790. whenReadyAsync(): Promise<void>;
  32791. /** @hidden */
  32792. _checkIsReady(): void;
  32793. /**
  32794. * Gets all animatable attached to the scene
  32795. */
  32796. readonly animatables: Animatable[];
  32797. /**
  32798. * Resets the last animation time frame.
  32799. * Useful to override when animations start running when loading a scene for the first time.
  32800. */
  32801. resetLastAnimationTimeFrame(): void;
  32802. /**
  32803. * Gets the current view matrix
  32804. * @returns a Matrix
  32805. */
  32806. getViewMatrix(): Matrix;
  32807. /**
  32808. * Gets the current projection matrix
  32809. * @returns a Matrix
  32810. */
  32811. getProjectionMatrix(): Matrix;
  32812. /**
  32813. * Gets the current transform matrix
  32814. * @returns a Matrix made of View * Projection
  32815. */
  32816. getTransformMatrix(): Matrix;
  32817. /**
  32818. * Sets the current transform matrix
  32819. * @param viewL defines the View matrix to use
  32820. * @param projectionL defines the Projection matrix to use
  32821. * @param viewR defines the right View matrix to use (if provided)
  32822. * @param projectionR defines the right Projection matrix to use (if provided)
  32823. */
  32824. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32825. /**
  32826. * Gets the uniform buffer used to store scene data
  32827. * @returns a UniformBuffer
  32828. */
  32829. getSceneUniformBuffer(): UniformBuffer;
  32830. /**
  32831. * Gets an unique (relatively to the current scene) Id
  32832. * @returns an unique number for the scene
  32833. */
  32834. getUniqueId(): number;
  32835. /**
  32836. * Add a mesh to the list of scene's meshes
  32837. * @param newMesh defines the mesh to add
  32838. * @param recursive if all child meshes should also be added to the scene
  32839. */
  32840. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32841. /**
  32842. * Remove a mesh for the list of scene's meshes
  32843. * @param toRemove defines the mesh to remove
  32844. * @param recursive if all child meshes should also be removed from the scene
  32845. * @returns the index where the mesh was in the mesh list
  32846. */
  32847. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32848. /**
  32849. * Add a transform node to the list of scene's transform nodes
  32850. * @param newTransformNode defines the transform node to add
  32851. */
  32852. addTransformNode(newTransformNode: TransformNode): void;
  32853. /**
  32854. * Remove a transform node for the list of scene's transform nodes
  32855. * @param toRemove defines the transform node to remove
  32856. * @returns the index where the transform node was in the transform node list
  32857. */
  32858. removeTransformNode(toRemove: TransformNode): number;
  32859. /**
  32860. * Remove a skeleton for the list of scene's skeletons
  32861. * @param toRemove defines the skeleton to remove
  32862. * @returns the index where the skeleton was in the skeleton list
  32863. */
  32864. removeSkeleton(toRemove: Skeleton): number;
  32865. /**
  32866. * Remove a morph target for the list of scene's morph targets
  32867. * @param toRemove defines the morph target to remove
  32868. * @returns the index where the morph target was in the morph target list
  32869. */
  32870. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32871. /**
  32872. * Remove a light for the list of scene's lights
  32873. * @param toRemove defines the light to remove
  32874. * @returns the index where the light was in the light list
  32875. */
  32876. removeLight(toRemove: Light): number;
  32877. /**
  32878. * Remove a camera for the list of scene's cameras
  32879. * @param toRemove defines the camera to remove
  32880. * @returns the index where the camera was in the camera list
  32881. */
  32882. removeCamera(toRemove: Camera): number;
  32883. /**
  32884. * Remove a particle system for the list of scene's particle systems
  32885. * @param toRemove defines the particle system to remove
  32886. * @returns the index where the particle system was in the particle system list
  32887. */
  32888. removeParticleSystem(toRemove: IParticleSystem): number;
  32889. /**
  32890. * Remove a animation for the list of scene's animations
  32891. * @param toRemove defines the animation to remove
  32892. * @returns the index where the animation was in the animation list
  32893. */
  32894. removeAnimation(toRemove: Animation): number;
  32895. /**
  32896. * Removes the given animation group from this scene.
  32897. * @param toRemove The animation group to remove
  32898. * @returns The index of the removed animation group
  32899. */
  32900. removeAnimationGroup(toRemove: AnimationGroup): number;
  32901. /**
  32902. * Removes the given multi-material from this scene.
  32903. * @param toRemove The multi-material to remove
  32904. * @returns The index of the removed multi-material
  32905. */
  32906. removeMultiMaterial(toRemove: MultiMaterial): number;
  32907. /**
  32908. * Removes the given material from this scene.
  32909. * @param toRemove The material to remove
  32910. * @returns The index of the removed material
  32911. */
  32912. removeMaterial(toRemove: Material): number;
  32913. /**
  32914. * Removes the given action manager from this scene.
  32915. * @param toRemove The action manager to remove
  32916. * @returns The index of the removed action manager
  32917. */
  32918. removeActionManager(toRemove: AbstractActionManager): number;
  32919. /**
  32920. * Removes the given texture from this scene.
  32921. * @param toRemove The texture to remove
  32922. * @returns The index of the removed texture
  32923. */
  32924. removeTexture(toRemove: BaseTexture): number;
  32925. /**
  32926. * Adds the given light to this scene
  32927. * @param newLight The light to add
  32928. */
  32929. addLight(newLight: Light): void;
  32930. /**
  32931. * Sorts the list list based on light priorities
  32932. */
  32933. sortLightsByPriority(): void;
  32934. /**
  32935. * Adds the given camera to this scene
  32936. * @param newCamera The camera to add
  32937. */
  32938. addCamera(newCamera: Camera): void;
  32939. /**
  32940. * Adds the given skeleton to this scene
  32941. * @param newSkeleton The skeleton to add
  32942. */
  32943. addSkeleton(newSkeleton: Skeleton): void;
  32944. /**
  32945. * Adds the given particle system to this scene
  32946. * @param newParticleSystem The particle system to add
  32947. */
  32948. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32949. /**
  32950. * Adds the given animation to this scene
  32951. * @param newAnimation The animation to add
  32952. */
  32953. addAnimation(newAnimation: Animation): void;
  32954. /**
  32955. * Adds the given animation group to this scene.
  32956. * @param newAnimationGroup The animation group to add
  32957. */
  32958. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32959. /**
  32960. * Adds the given multi-material to this scene
  32961. * @param newMultiMaterial The multi-material to add
  32962. */
  32963. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32964. /**
  32965. * Adds the given material to this scene
  32966. * @param newMaterial The material to add
  32967. */
  32968. addMaterial(newMaterial: Material): void;
  32969. /**
  32970. * Adds the given morph target to this scene
  32971. * @param newMorphTargetManager The morph target to add
  32972. */
  32973. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32974. /**
  32975. * Adds the given geometry to this scene
  32976. * @param newGeometry The geometry to add
  32977. */
  32978. addGeometry(newGeometry: Geometry): void;
  32979. /**
  32980. * Adds the given action manager to this scene
  32981. * @param newActionManager The action manager to add
  32982. */
  32983. addActionManager(newActionManager: AbstractActionManager): void;
  32984. /**
  32985. * Adds the given texture to this scene.
  32986. * @param newTexture The texture to add
  32987. */
  32988. addTexture(newTexture: BaseTexture): void;
  32989. /**
  32990. * Switch active camera
  32991. * @param newCamera defines the new active camera
  32992. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32993. */
  32994. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32995. /**
  32996. * sets the active camera of the scene using its ID
  32997. * @param id defines the camera's ID
  32998. * @return the new active camera or null if none found.
  32999. */
  33000. setActiveCameraByID(id: string): Nullable<Camera>;
  33001. /**
  33002. * sets the active camera of the scene using its name
  33003. * @param name defines the camera's name
  33004. * @returns the new active camera or null if none found.
  33005. */
  33006. setActiveCameraByName(name: string): Nullable<Camera>;
  33007. /**
  33008. * get an animation group using its name
  33009. * @param name defines the material's name
  33010. * @return the animation group or null if none found.
  33011. */
  33012. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33013. /**
  33014. * Get a material using its unique id
  33015. * @param uniqueId defines the material's unique id
  33016. * @return the material or null if none found.
  33017. */
  33018. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33019. /**
  33020. * get a material using its id
  33021. * @param id defines the material's ID
  33022. * @return the material or null if none found.
  33023. */
  33024. getMaterialByID(id: string): Nullable<Material>;
  33025. /**
  33026. * Gets a material using its name
  33027. * @param name defines the material's name
  33028. * @return the material or null if none found.
  33029. */
  33030. getMaterialByName(name: string): Nullable<Material>;
  33031. /**
  33032. * Gets a camera using its id
  33033. * @param id defines the id to look for
  33034. * @returns the camera or null if not found
  33035. */
  33036. getCameraByID(id: string): Nullable<Camera>;
  33037. /**
  33038. * Gets a camera using its unique id
  33039. * @param uniqueId defines the unique id to look for
  33040. * @returns the camera or null if not found
  33041. */
  33042. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33043. /**
  33044. * Gets a camera using its name
  33045. * @param name defines the camera's name
  33046. * @return the camera or null if none found.
  33047. */
  33048. getCameraByName(name: string): Nullable<Camera>;
  33049. /**
  33050. * Gets a bone using its id
  33051. * @param id defines the bone's id
  33052. * @return the bone or null if not found
  33053. */
  33054. getBoneByID(id: string): Nullable<Bone>;
  33055. /**
  33056. * Gets a bone using its id
  33057. * @param name defines the bone's name
  33058. * @return the bone or null if not found
  33059. */
  33060. getBoneByName(name: string): Nullable<Bone>;
  33061. /**
  33062. * Gets a light node using its name
  33063. * @param name defines the the light's name
  33064. * @return the light or null if none found.
  33065. */
  33066. getLightByName(name: string): Nullable<Light>;
  33067. /**
  33068. * Gets a light node using its id
  33069. * @param id defines the light's id
  33070. * @return the light or null if none found.
  33071. */
  33072. getLightByID(id: string): Nullable<Light>;
  33073. /**
  33074. * Gets a light node using its scene-generated unique ID
  33075. * @param uniqueId defines the light's unique id
  33076. * @return the light or null if none found.
  33077. */
  33078. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33079. /**
  33080. * Gets a particle system by id
  33081. * @param id defines the particle system id
  33082. * @return the corresponding system or null if none found
  33083. */
  33084. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33085. /**
  33086. * Gets a geometry using its ID
  33087. * @param id defines the geometry's id
  33088. * @return the geometry or null if none found.
  33089. */
  33090. getGeometryByID(id: string): Nullable<Geometry>;
  33091. private _getGeometryByUniqueID;
  33092. /**
  33093. * Add a new geometry to this scene
  33094. * @param geometry defines the geometry to be added to the scene.
  33095. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33096. * @return a boolean defining if the geometry was added or not
  33097. */
  33098. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33099. /**
  33100. * Removes an existing geometry
  33101. * @param geometry defines the geometry to be removed from the scene
  33102. * @return a boolean defining if the geometry was removed or not
  33103. */
  33104. removeGeometry(geometry: Geometry): boolean;
  33105. /**
  33106. * Gets the list of geometries attached to the scene
  33107. * @returns an array of Geometry
  33108. */
  33109. getGeometries(): Geometry[];
  33110. /**
  33111. * Gets the first added mesh found of a given ID
  33112. * @param id defines the id to search for
  33113. * @return the mesh found or null if not found at all
  33114. */
  33115. getMeshByID(id: string): Nullable<AbstractMesh>;
  33116. /**
  33117. * Gets a list of meshes using their id
  33118. * @param id defines the id to search for
  33119. * @returns a list of meshes
  33120. */
  33121. getMeshesByID(id: string): Array<AbstractMesh>;
  33122. /**
  33123. * Gets the first added transform node found of a given ID
  33124. * @param id defines the id to search for
  33125. * @return the found transform node or null if not found at all.
  33126. */
  33127. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33128. /**
  33129. * Gets a transform node with its auto-generated unique id
  33130. * @param uniqueId efines the unique id to search for
  33131. * @return the found transform node or null if not found at all.
  33132. */
  33133. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33134. /**
  33135. * Gets a list of transform nodes using their id
  33136. * @param id defines the id to search for
  33137. * @returns a list of transform nodes
  33138. */
  33139. getTransformNodesByID(id: string): Array<TransformNode>;
  33140. /**
  33141. * Gets a mesh with its auto-generated unique id
  33142. * @param uniqueId defines the unique id to search for
  33143. * @return the found mesh or null if not found at all.
  33144. */
  33145. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33146. /**
  33147. * Gets a the last added mesh using a given id
  33148. * @param id defines the id to search for
  33149. * @return the found mesh or null if not found at all.
  33150. */
  33151. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33152. /**
  33153. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33154. * @param id defines the id to search for
  33155. * @return the found node or null if not found at all
  33156. */
  33157. getLastEntryByID(id: string): Nullable<Node>;
  33158. /**
  33159. * Gets a node (Mesh, Camera, Light) using a given id
  33160. * @param id defines the id to search for
  33161. * @return the found node or null if not found at all
  33162. */
  33163. getNodeByID(id: string): Nullable<Node>;
  33164. /**
  33165. * Gets a node (Mesh, Camera, Light) using a given name
  33166. * @param name defines the name to search for
  33167. * @return the found node or null if not found at all.
  33168. */
  33169. getNodeByName(name: string): Nullable<Node>;
  33170. /**
  33171. * Gets a mesh using a given name
  33172. * @param name defines the name to search for
  33173. * @return the found mesh or null if not found at all.
  33174. */
  33175. getMeshByName(name: string): Nullable<AbstractMesh>;
  33176. /**
  33177. * Gets a transform node using a given name
  33178. * @param name defines the name to search for
  33179. * @return the found transform node or null if not found at all.
  33180. */
  33181. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33182. /**
  33183. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33184. * @param id defines the id to search for
  33185. * @return the found skeleton or null if not found at all.
  33186. */
  33187. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33188. /**
  33189. * Gets a skeleton using a given auto generated unique id
  33190. * @param uniqueId defines the unique id to search for
  33191. * @return the found skeleton or null if not found at all.
  33192. */
  33193. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33194. /**
  33195. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33196. * @param id defines the id to search for
  33197. * @return the found skeleton or null if not found at all.
  33198. */
  33199. getSkeletonById(id: string): Nullable<Skeleton>;
  33200. /**
  33201. * Gets a skeleton using a given name
  33202. * @param name defines the name to search for
  33203. * @return the found skeleton or null if not found at all.
  33204. */
  33205. getSkeletonByName(name: string): Nullable<Skeleton>;
  33206. /**
  33207. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33208. * @param id defines the id to search for
  33209. * @return the found morph target manager or null if not found at all.
  33210. */
  33211. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33212. /**
  33213. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33214. * @param id defines the id to search for
  33215. * @return the found morph target or null if not found at all.
  33216. */
  33217. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33218. /**
  33219. * Gets a boolean indicating if the given mesh is active
  33220. * @param mesh defines the mesh to look for
  33221. * @returns true if the mesh is in the active list
  33222. */
  33223. isActiveMesh(mesh: AbstractMesh): boolean;
  33224. /**
  33225. * Return a unique id as a string which can serve as an identifier for the scene
  33226. */
  33227. readonly uid: string;
  33228. /**
  33229. * Add an externaly attached data from its key.
  33230. * This method call will fail and return false, if such key already exists.
  33231. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33232. * @param key the unique key that identifies the data
  33233. * @param data the data object to associate to the key for this Engine instance
  33234. * @return true if no such key were already present and the data was added successfully, false otherwise
  33235. */
  33236. addExternalData<T>(key: string, data: T): boolean;
  33237. /**
  33238. * Get an externaly attached data from its key
  33239. * @param key the unique key that identifies the data
  33240. * @return the associated data, if present (can be null), or undefined if not present
  33241. */
  33242. getExternalData<T>(key: string): Nullable<T>;
  33243. /**
  33244. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33245. * @param key the unique key that identifies the data
  33246. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33247. * @return the associated data, can be null if the factory returned null.
  33248. */
  33249. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33250. /**
  33251. * Remove an externaly attached data from the Engine instance
  33252. * @param key the unique key that identifies the data
  33253. * @return true if the data was successfully removed, false if it doesn't exist
  33254. */
  33255. removeExternalData(key: string): boolean;
  33256. private _evaluateSubMesh;
  33257. /**
  33258. * Clear the processed materials smart array preventing retention point in material dispose.
  33259. */
  33260. freeProcessedMaterials(): void;
  33261. private _preventFreeActiveMeshesAndRenderingGroups;
  33262. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33263. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33264. * when disposing several meshes in a row or a hierarchy of meshes.
  33265. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33266. */
  33267. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33268. /**
  33269. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33270. */
  33271. freeActiveMeshes(): void;
  33272. /**
  33273. * Clear the info related to rendering groups preventing retention points during dispose.
  33274. */
  33275. freeRenderingGroups(): void;
  33276. /** @hidden */
  33277. _isInIntermediateRendering(): boolean;
  33278. /**
  33279. * Lambda returning the list of potentially active meshes.
  33280. */
  33281. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33282. /**
  33283. * Lambda returning the list of potentially active sub meshes.
  33284. */
  33285. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33286. /**
  33287. * Lambda returning the list of potentially intersecting sub meshes.
  33288. */
  33289. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33290. /**
  33291. * Lambda returning the list of potentially colliding sub meshes.
  33292. */
  33293. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33294. private _activeMeshesFrozen;
  33295. /**
  33296. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33297. * @returns the current scene
  33298. */
  33299. freezeActiveMeshes(): Scene;
  33300. /**
  33301. * Use this function to restart evaluating active meshes on every frame
  33302. * @returns the current scene
  33303. */
  33304. unfreezeActiveMeshes(): Scene;
  33305. private _evaluateActiveMeshes;
  33306. private _activeMesh;
  33307. /**
  33308. * Update the transform matrix to update from the current active camera
  33309. * @param force defines a boolean used to force the update even if cache is up to date
  33310. */
  33311. updateTransformMatrix(force?: boolean): void;
  33312. private _bindFrameBuffer;
  33313. /** @hidden */
  33314. _allowPostProcessClearColor: boolean;
  33315. /** @hidden */
  33316. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33317. private _processSubCameras;
  33318. private _checkIntersections;
  33319. /** @hidden */
  33320. _advancePhysicsEngineStep(step: number): void;
  33321. /**
  33322. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33323. */
  33324. getDeterministicFrameTime: () => number;
  33325. /** @hidden */
  33326. _animate(): void;
  33327. /** Execute all animations (for a frame) */
  33328. animate(): void;
  33329. /**
  33330. * Render the scene
  33331. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33332. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33333. */
  33334. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33335. /**
  33336. * Freeze all materials
  33337. * A frozen material will not be updatable but should be faster to render
  33338. */
  33339. freezeMaterials(): void;
  33340. /**
  33341. * Unfreeze all materials
  33342. * A frozen material will not be updatable but should be faster to render
  33343. */
  33344. unfreezeMaterials(): void;
  33345. /**
  33346. * Releases all held ressources
  33347. */
  33348. dispose(): void;
  33349. /**
  33350. * Gets if the scene is already disposed
  33351. */
  33352. readonly isDisposed: boolean;
  33353. /**
  33354. * Call this function to reduce memory footprint of the scene.
  33355. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33356. */
  33357. clearCachedVertexData(): void;
  33358. /**
  33359. * This function will remove the local cached buffer data from texture.
  33360. * It will save memory but will prevent the texture from being rebuilt
  33361. */
  33362. cleanCachedTextureBuffer(): void;
  33363. /**
  33364. * Get the world extend vectors with an optional filter
  33365. *
  33366. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33367. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33368. */
  33369. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33370. min: Vector3;
  33371. max: Vector3;
  33372. };
  33373. /**
  33374. * Creates a ray that can be used to pick in the scene
  33375. * @param x defines the x coordinate of the origin (on-screen)
  33376. * @param y defines the y coordinate of the origin (on-screen)
  33377. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33378. * @param camera defines the camera to use for the picking
  33379. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33380. * @returns a Ray
  33381. */
  33382. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33383. /**
  33384. * Creates a ray that can be used to pick in the scene
  33385. * @param x defines the x coordinate of the origin (on-screen)
  33386. * @param y defines the y coordinate of the origin (on-screen)
  33387. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33388. * @param result defines the ray where to store the picking ray
  33389. * @param camera defines the camera to use for the picking
  33390. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33391. * @returns the current scene
  33392. */
  33393. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33394. /**
  33395. * Creates a ray that can be used to pick in the scene
  33396. * @param x defines the x coordinate of the origin (on-screen)
  33397. * @param y defines the y coordinate of the origin (on-screen)
  33398. * @param camera defines the camera to use for the picking
  33399. * @returns a Ray
  33400. */
  33401. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33402. /**
  33403. * Creates a ray that can be used to pick in the scene
  33404. * @param x defines the x coordinate of the origin (on-screen)
  33405. * @param y defines the y coordinate of the origin (on-screen)
  33406. * @param result defines the ray where to store the picking ray
  33407. * @param camera defines the camera to use for the picking
  33408. * @returns the current scene
  33409. */
  33410. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33411. /** Launch a ray to try to pick a mesh in the scene
  33412. * @param x position on screen
  33413. * @param y position on screen
  33414. * @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
  33415. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33416. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33417. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33418. * @returns a PickingInfo
  33419. */
  33420. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33421. /** Use the given ray to pick a mesh in the scene
  33422. * @param ray The ray to use to pick meshes
  33423. * @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
  33424. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33425. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33426. * @returns a PickingInfo
  33427. */
  33428. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33429. /**
  33430. * Launch a ray to try to pick a mesh in the scene
  33431. * @param x X position on screen
  33432. * @param y Y position on screen
  33433. * @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
  33434. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33435. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33436. * @returns an array of PickingInfo
  33437. */
  33438. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33439. /**
  33440. * Launch a ray to try to pick a mesh in the scene
  33441. * @param ray Ray to use
  33442. * @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
  33443. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33444. * @returns an array of PickingInfo
  33445. */
  33446. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33447. /**
  33448. * Force the value of meshUnderPointer
  33449. * @param mesh defines the mesh to use
  33450. */
  33451. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33452. /**
  33453. * Gets the mesh under the pointer
  33454. * @returns a Mesh or null if no mesh is under the pointer
  33455. */
  33456. getPointerOverMesh(): Nullable<AbstractMesh>;
  33457. /** @hidden */
  33458. _rebuildGeometries(): void;
  33459. /** @hidden */
  33460. _rebuildTextures(): void;
  33461. private _getByTags;
  33462. /**
  33463. * Get a list of meshes by tags
  33464. * @param tagsQuery defines the tags query to use
  33465. * @param forEach defines a predicate used to filter results
  33466. * @returns an array of Mesh
  33467. */
  33468. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33469. /**
  33470. * Get a list of cameras by tags
  33471. * @param tagsQuery defines the tags query to use
  33472. * @param forEach defines a predicate used to filter results
  33473. * @returns an array of Camera
  33474. */
  33475. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33476. /**
  33477. * Get a list of lights by tags
  33478. * @param tagsQuery defines the tags query to use
  33479. * @param forEach defines a predicate used to filter results
  33480. * @returns an array of Light
  33481. */
  33482. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33483. /**
  33484. * Get a list of materials by tags
  33485. * @param tagsQuery defines the tags query to use
  33486. * @param forEach defines a predicate used to filter results
  33487. * @returns an array of Material
  33488. */
  33489. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33490. /**
  33491. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33492. * This allowed control for front to back rendering or reversly depending of the special needs.
  33493. *
  33494. * @param renderingGroupId The rendering group id corresponding to its index
  33495. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33496. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33497. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33498. */
  33499. 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;
  33500. /**
  33501. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33502. *
  33503. * @param renderingGroupId The rendering group id corresponding to its index
  33504. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33505. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33506. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33507. */
  33508. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33509. /**
  33510. * Gets the current auto clear configuration for one rendering group of the rendering
  33511. * manager.
  33512. * @param index the rendering group index to get the information for
  33513. * @returns The auto clear setup for the requested rendering group
  33514. */
  33515. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33516. private _blockMaterialDirtyMechanism;
  33517. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33518. blockMaterialDirtyMechanism: boolean;
  33519. /**
  33520. * Will flag all materials as dirty to trigger new shader compilation
  33521. * @param flag defines the flag used to specify which material part must be marked as dirty
  33522. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33523. */
  33524. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33525. /** @hidden */
  33526. _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;
  33527. /** @hidden */
  33528. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33529. }
  33530. }
  33531. declare module BABYLON {
  33532. /**
  33533. * Set of assets to keep when moving a scene into an asset container.
  33534. */
  33535. export class KeepAssets extends AbstractScene {
  33536. }
  33537. /**
  33538. * Container with a set of assets that can be added or removed from a scene.
  33539. */
  33540. export class AssetContainer extends AbstractScene {
  33541. /**
  33542. * The scene the AssetContainer belongs to.
  33543. */
  33544. scene: Scene;
  33545. /**
  33546. * Instantiates an AssetContainer.
  33547. * @param scene The scene the AssetContainer belongs to.
  33548. */
  33549. constructor(scene: Scene);
  33550. /**
  33551. * Adds all the assets from the container to the scene.
  33552. */
  33553. addAllToScene(): void;
  33554. /**
  33555. * Removes all the assets in the container from the scene
  33556. */
  33557. removeAllFromScene(): void;
  33558. /**
  33559. * Disposes all the assets in the container
  33560. */
  33561. dispose(): void;
  33562. private _moveAssets;
  33563. /**
  33564. * Removes all the assets contained in the scene and adds them to the container.
  33565. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33566. */
  33567. moveAllFromScene(keepAssets?: KeepAssets): void;
  33568. /**
  33569. * 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.
  33570. * @returns the root mesh
  33571. */
  33572. createRootMesh(): Mesh;
  33573. }
  33574. }
  33575. declare module BABYLON {
  33576. /**
  33577. * Defines how the parser contract is defined.
  33578. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33579. */
  33580. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33581. /**
  33582. * Defines how the individual parser contract is defined.
  33583. * These parser can parse an individual asset
  33584. */
  33585. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33586. /**
  33587. * Base class of the scene acting as a container for the different elements composing a scene.
  33588. * This class is dynamically extended by the different components of the scene increasing
  33589. * flexibility and reducing coupling
  33590. */
  33591. export abstract class AbstractScene {
  33592. /**
  33593. * Stores the list of available parsers in the application.
  33594. */
  33595. private static _BabylonFileParsers;
  33596. /**
  33597. * Stores the list of available individual parsers in the application.
  33598. */
  33599. private static _IndividualBabylonFileParsers;
  33600. /**
  33601. * Adds a parser in the list of available ones
  33602. * @param name Defines the name of the parser
  33603. * @param parser Defines the parser to add
  33604. */
  33605. static AddParser(name: string, parser: BabylonFileParser): void;
  33606. /**
  33607. * Gets a general parser from the list of avaialble ones
  33608. * @param name Defines the name of the parser
  33609. * @returns the requested parser or null
  33610. */
  33611. static GetParser(name: string): Nullable<BabylonFileParser>;
  33612. /**
  33613. * Adds n individual parser in the list of available ones
  33614. * @param name Defines the name of the parser
  33615. * @param parser Defines the parser to add
  33616. */
  33617. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33618. /**
  33619. * Gets an individual parser from the list of avaialble ones
  33620. * @param name Defines the name of the parser
  33621. * @returns the requested parser or null
  33622. */
  33623. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33624. /**
  33625. * Parser json data and populate both a scene and its associated container object
  33626. * @param jsonData Defines the data to parse
  33627. * @param scene Defines the scene to parse the data for
  33628. * @param container Defines the container attached to the parsing sequence
  33629. * @param rootUrl Defines the root url of the data
  33630. */
  33631. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33632. /**
  33633. * Gets the list of root nodes (ie. nodes with no parent)
  33634. */
  33635. rootNodes: Node[];
  33636. /** All of the cameras added to this scene
  33637. * @see http://doc.babylonjs.com/babylon101/cameras
  33638. */
  33639. cameras: Camera[];
  33640. /**
  33641. * All of the lights added to this scene
  33642. * @see http://doc.babylonjs.com/babylon101/lights
  33643. */
  33644. lights: Light[];
  33645. /**
  33646. * All of the (abstract) meshes added to this scene
  33647. */
  33648. meshes: AbstractMesh[];
  33649. /**
  33650. * The list of skeletons added to the scene
  33651. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33652. */
  33653. skeletons: Skeleton[];
  33654. /**
  33655. * All of the particle systems added to this scene
  33656. * @see http://doc.babylonjs.com/babylon101/particles
  33657. */
  33658. particleSystems: IParticleSystem[];
  33659. /**
  33660. * Gets a list of Animations associated with the scene
  33661. */
  33662. animations: Animation[];
  33663. /**
  33664. * All of the animation groups added to this scene
  33665. * @see http://doc.babylonjs.com/how_to/group
  33666. */
  33667. animationGroups: AnimationGroup[];
  33668. /**
  33669. * All of the multi-materials added to this scene
  33670. * @see http://doc.babylonjs.com/how_to/multi_materials
  33671. */
  33672. multiMaterials: MultiMaterial[];
  33673. /**
  33674. * All of the materials added to this scene
  33675. * In the context of a Scene, it is not supposed to be modified manually.
  33676. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33677. * Note also that the order of the Material wihin the array is not significant and might change.
  33678. * @see http://doc.babylonjs.com/babylon101/materials
  33679. */
  33680. materials: Material[];
  33681. /**
  33682. * The list of morph target managers added to the scene
  33683. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33684. */
  33685. morphTargetManagers: MorphTargetManager[];
  33686. /**
  33687. * The list of geometries used in the scene.
  33688. */
  33689. geometries: Geometry[];
  33690. /**
  33691. * All of the tranform nodes added to this scene
  33692. * In the context of a Scene, it is not supposed to be modified manually.
  33693. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33694. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33695. * @see http://doc.babylonjs.com/how_to/transformnode
  33696. */
  33697. transformNodes: TransformNode[];
  33698. /**
  33699. * ActionManagers available on the scene.
  33700. */
  33701. actionManagers: AbstractActionManager[];
  33702. /**
  33703. * Textures to keep.
  33704. */
  33705. textures: BaseTexture[];
  33706. /**
  33707. * Environment texture for the scene
  33708. */
  33709. environmentTexture: Nullable<BaseTexture>;
  33710. }
  33711. }
  33712. declare module BABYLON {
  33713. /**
  33714. * Defines a sound that can be played in the application.
  33715. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33717. */
  33718. export class Sound {
  33719. /**
  33720. * The name of the sound in the scene.
  33721. */
  33722. name: string;
  33723. /**
  33724. * Does the sound autoplay once loaded.
  33725. */
  33726. autoplay: boolean;
  33727. /**
  33728. * Does the sound loop after it finishes playing once.
  33729. */
  33730. loop: boolean;
  33731. /**
  33732. * Does the sound use a custom attenuation curve to simulate the falloff
  33733. * happening when the source gets further away from the camera.
  33734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33735. */
  33736. useCustomAttenuation: boolean;
  33737. /**
  33738. * The sound track id this sound belongs to.
  33739. */
  33740. soundTrackId: number;
  33741. /**
  33742. * Is this sound currently played.
  33743. */
  33744. isPlaying: boolean;
  33745. /**
  33746. * Is this sound currently paused.
  33747. */
  33748. isPaused: boolean;
  33749. /**
  33750. * Does this sound enables spatial sound.
  33751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33752. */
  33753. spatialSound: boolean;
  33754. /**
  33755. * Define the reference distance the sound should be heard perfectly.
  33756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33757. */
  33758. refDistance: number;
  33759. /**
  33760. * Define the roll off factor of spatial sounds.
  33761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33762. */
  33763. rolloffFactor: number;
  33764. /**
  33765. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33767. */
  33768. maxDistance: number;
  33769. /**
  33770. * Define the distance attenuation model the sound will follow.
  33771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33772. */
  33773. distanceModel: string;
  33774. /**
  33775. * @hidden
  33776. * Back Compat
  33777. **/
  33778. onended: () => any;
  33779. /**
  33780. * Observable event when the current playing sound finishes.
  33781. */
  33782. onEndedObservable: Observable<Sound>;
  33783. private _panningModel;
  33784. private _playbackRate;
  33785. private _streaming;
  33786. private _startTime;
  33787. private _startOffset;
  33788. private _position;
  33789. /** @hidden */
  33790. _positionInEmitterSpace: boolean;
  33791. private _localDirection;
  33792. private _volume;
  33793. private _isReadyToPlay;
  33794. private _isDirectional;
  33795. private _readyToPlayCallback;
  33796. private _audioBuffer;
  33797. private _soundSource;
  33798. private _streamingSource;
  33799. private _soundPanner;
  33800. private _soundGain;
  33801. private _inputAudioNode;
  33802. private _outputAudioNode;
  33803. private _coneInnerAngle;
  33804. private _coneOuterAngle;
  33805. private _coneOuterGain;
  33806. private _scene;
  33807. private _connectedTransformNode;
  33808. private _customAttenuationFunction;
  33809. private _registerFunc;
  33810. private _isOutputConnected;
  33811. private _htmlAudioElement;
  33812. private _urlType;
  33813. /** @hidden */
  33814. static _SceneComponentInitialization: (scene: Scene) => void;
  33815. /**
  33816. * Create a sound and attach it to a scene
  33817. * @param name Name of your sound
  33818. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33819. * @param scene defines the scene the sound belongs to
  33820. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33821. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33822. */
  33823. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33824. /**
  33825. * Release the sound and its associated resources
  33826. */
  33827. dispose(): void;
  33828. /**
  33829. * Gets if the sounds is ready to be played or not.
  33830. * @returns true if ready, otherwise false
  33831. */
  33832. isReady(): boolean;
  33833. private _soundLoaded;
  33834. /**
  33835. * Sets the data of the sound from an audiobuffer
  33836. * @param audioBuffer The audioBuffer containing the data
  33837. */
  33838. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33839. /**
  33840. * Updates the current sounds options such as maxdistance, loop...
  33841. * @param options A JSON object containing values named as the object properties
  33842. */
  33843. updateOptions(options: any): void;
  33844. private _createSpatialParameters;
  33845. private _updateSpatialParameters;
  33846. /**
  33847. * Switch the panning model to HRTF:
  33848. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33850. */
  33851. switchPanningModelToHRTF(): void;
  33852. /**
  33853. * Switch the panning model to Equal Power:
  33854. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33856. */
  33857. switchPanningModelToEqualPower(): void;
  33858. private _switchPanningModel;
  33859. /**
  33860. * Connect this sound to a sound track audio node like gain...
  33861. * @param soundTrackAudioNode the sound track audio node to connect to
  33862. */
  33863. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33864. /**
  33865. * Transform this sound into a directional source
  33866. * @param coneInnerAngle Size of the inner cone in degree
  33867. * @param coneOuterAngle Size of the outer cone in degree
  33868. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33869. */
  33870. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33871. /**
  33872. * Gets or sets the inner angle for the directional cone.
  33873. */
  33874. /**
  33875. * Gets or sets the inner angle for the directional cone.
  33876. */
  33877. directionalConeInnerAngle: number;
  33878. /**
  33879. * Gets or sets the outer angle for the directional cone.
  33880. */
  33881. /**
  33882. * Gets or sets the outer angle for the directional cone.
  33883. */
  33884. directionalConeOuterAngle: number;
  33885. /**
  33886. * Sets the position of the emitter if spatial sound is enabled
  33887. * @param newPosition Defines the new posisiton
  33888. */
  33889. setPosition(newPosition: Vector3): void;
  33890. /**
  33891. * Sets the local direction of the emitter if spatial sound is enabled
  33892. * @param newLocalDirection Defines the new local direction
  33893. */
  33894. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33895. private _updateDirection;
  33896. /** @hidden */
  33897. updateDistanceFromListener(): void;
  33898. /**
  33899. * Sets a new custom attenuation function for the sound.
  33900. * @param callback Defines the function used for the attenuation
  33901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33902. */
  33903. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33904. /**
  33905. * Play the sound
  33906. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33907. * @param offset (optional) Start the sound setting it at a specific time
  33908. */
  33909. play(time?: number, offset?: number): void;
  33910. private _onended;
  33911. /**
  33912. * Stop the sound
  33913. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33914. */
  33915. stop(time?: number): void;
  33916. /**
  33917. * Put the sound in pause
  33918. */
  33919. pause(): void;
  33920. /**
  33921. * Sets a dedicated volume for this sounds
  33922. * @param newVolume Define the new volume of the sound
  33923. * @param time Define in how long the sound should be at this value
  33924. */
  33925. setVolume(newVolume: number, time?: number): void;
  33926. /**
  33927. * Set the sound play back rate
  33928. * @param newPlaybackRate Define the playback rate the sound should be played at
  33929. */
  33930. setPlaybackRate(newPlaybackRate: number): void;
  33931. /**
  33932. * Gets the volume of the sound.
  33933. * @returns the volume of the sound
  33934. */
  33935. getVolume(): number;
  33936. /**
  33937. * Attach the sound to a dedicated mesh
  33938. * @param transformNode The transform node to connect the sound with
  33939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33940. */
  33941. attachToMesh(transformNode: TransformNode): void;
  33942. /**
  33943. * Detach the sound from the previously attached mesh
  33944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33945. */
  33946. detachFromMesh(): void;
  33947. private _onRegisterAfterWorldMatrixUpdate;
  33948. /**
  33949. * Clone the current sound in the scene.
  33950. * @returns the new sound clone
  33951. */
  33952. clone(): Nullable<Sound>;
  33953. /**
  33954. * Gets the current underlying audio buffer containing the data
  33955. * @returns the audio buffer
  33956. */
  33957. getAudioBuffer(): Nullable<AudioBuffer>;
  33958. /**
  33959. * Serializes the Sound in a JSON representation
  33960. * @returns the JSON representation of the sound
  33961. */
  33962. serialize(): any;
  33963. /**
  33964. * Parse a JSON representation of a sound to innstantiate in a given scene
  33965. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33966. * @param scene Define the scene the new parsed sound should be created in
  33967. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33968. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33969. * @returns the newly parsed sound
  33970. */
  33971. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33972. }
  33973. }
  33974. declare module BABYLON {
  33975. /**
  33976. * This defines an action helpful to play a defined sound on a triggered action.
  33977. */
  33978. export class PlaySoundAction extends Action {
  33979. private _sound;
  33980. /**
  33981. * Instantiate the action
  33982. * @param triggerOptions defines the trigger options
  33983. * @param sound defines the sound to play
  33984. * @param condition defines the trigger related conditions
  33985. */
  33986. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33987. /** @hidden */
  33988. _prepare(): void;
  33989. /**
  33990. * Execute the action and play the sound.
  33991. */
  33992. execute(): void;
  33993. /**
  33994. * Serializes the actions and its related information.
  33995. * @param parent defines the object to serialize in
  33996. * @returns the serialized object
  33997. */
  33998. serialize(parent: any): any;
  33999. }
  34000. /**
  34001. * This defines an action helpful to stop a defined sound on a triggered action.
  34002. */
  34003. export class StopSoundAction extends Action {
  34004. private _sound;
  34005. /**
  34006. * Instantiate the action
  34007. * @param triggerOptions defines the trigger options
  34008. * @param sound defines the sound to stop
  34009. * @param condition defines the trigger related conditions
  34010. */
  34011. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34012. /** @hidden */
  34013. _prepare(): void;
  34014. /**
  34015. * Execute the action and stop the sound.
  34016. */
  34017. execute(): void;
  34018. /**
  34019. * Serializes the actions and its related information.
  34020. * @param parent defines the object to serialize in
  34021. * @returns the serialized object
  34022. */
  34023. serialize(parent: any): any;
  34024. }
  34025. }
  34026. declare module BABYLON {
  34027. /**
  34028. * This defines an action responsible to change the value of a property
  34029. * by interpolating between its current value and the newly set one once triggered.
  34030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34031. */
  34032. export class InterpolateValueAction extends Action {
  34033. /**
  34034. * Defines the path of the property where the value should be interpolated
  34035. */
  34036. propertyPath: string;
  34037. /**
  34038. * Defines the target value at the end of the interpolation.
  34039. */
  34040. value: any;
  34041. /**
  34042. * Defines the time it will take for the property to interpolate to the value.
  34043. */
  34044. duration: number;
  34045. /**
  34046. * Defines if the other scene animations should be stopped when the action has been triggered
  34047. */
  34048. stopOtherAnimations?: boolean;
  34049. /**
  34050. * Defines a callback raised once the interpolation animation has been done.
  34051. */
  34052. onInterpolationDone?: () => void;
  34053. /**
  34054. * Observable triggered once the interpolation animation has been done.
  34055. */
  34056. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34057. private _target;
  34058. private _effectiveTarget;
  34059. private _property;
  34060. /**
  34061. * Instantiate the action
  34062. * @param triggerOptions defines the trigger options
  34063. * @param target defines the object containing the value to interpolate
  34064. * @param propertyPath defines the path to the property in the target object
  34065. * @param value defines the target value at the end of the interpolation
  34066. * @param duration deines the time it will take for the property to interpolate to the value.
  34067. * @param condition defines the trigger related conditions
  34068. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34069. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34070. */
  34071. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34072. /** @hidden */
  34073. _prepare(): void;
  34074. /**
  34075. * Execute the action starts the value interpolation.
  34076. */
  34077. execute(): void;
  34078. /**
  34079. * Serializes the actions and its related information.
  34080. * @param parent defines the object to serialize in
  34081. * @returns the serialized object
  34082. */
  34083. serialize(parent: any): any;
  34084. }
  34085. }
  34086. declare module BABYLON {
  34087. /**
  34088. * Options allowed during the creation of a sound track.
  34089. */
  34090. export interface ISoundTrackOptions {
  34091. /**
  34092. * The volume the sound track should take during creation
  34093. */
  34094. volume?: number;
  34095. /**
  34096. * Define if the sound track is the main sound track of the scene
  34097. */
  34098. mainTrack?: boolean;
  34099. }
  34100. /**
  34101. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34102. * It will be also used in a future release to apply effects on a specific track.
  34103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34104. */
  34105. export class SoundTrack {
  34106. /**
  34107. * The unique identifier of the sound track in the scene.
  34108. */
  34109. id: number;
  34110. /**
  34111. * The list of sounds included in the sound track.
  34112. */
  34113. soundCollection: Array<Sound>;
  34114. private _outputAudioNode;
  34115. private _scene;
  34116. private _isMainTrack;
  34117. private _connectedAnalyser;
  34118. private _options;
  34119. private _isInitialized;
  34120. /**
  34121. * Creates a new sound track.
  34122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34123. * @param scene Define the scene the sound track belongs to
  34124. * @param options
  34125. */
  34126. constructor(scene: Scene, options?: ISoundTrackOptions);
  34127. private _initializeSoundTrackAudioGraph;
  34128. /**
  34129. * Release the sound track and its associated resources
  34130. */
  34131. dispose(): void;
  34132. /**
  34133. * Adds a sound to this sound track
  34134. * @param sound define the cound to add
  34135. * @ignoreNaming
  34136. */
  34137. AddSound(sound: Sound): void;
  34138. /**
  34139. * Removes a sound to this sound track
  34140. * @param sound define the cound to remove
  34141. * @ignoreNaming
  34142. */
  34143. RemoveSound(sound: Sound): void;
  34144. /**
  34145. * Set a global volume for the full sound track.
  34146. * @param newVolume Define the new volume of the sound track
  34147. */
  34148. setVolume(newVolume: number): void;
  34149. /**
  34150. * Switch the panning model to HRTF:
  34151. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34153. */
  34154. switchPanningModelToHRTF(): void;
  34155. /**
  34156. * Switch the panning model to Equal Power:
  34157. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34159. */
  34160. switchPanningModelToEqualPower(): void;
  34161. /**
  34162. * Connect the sound track to an audio analyser allowing some amazing
  34163. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34165. * @param analyser The analyser to connect to the engine
  34166. */
  34167. connectToAnalyser(analyser: Analyser): void;
  34168. }
  34169. }
  34170. declare module BABYLON {
  34171. interface AbstractScene {
  34172. /**
  34173. * The list of sounds used in the scene.
  34174. */
  34175. sounds: Nullable<Array<Sound>>;
  34176. }
  34177. interface Scene {
  34178. /**
  34179. * @hidden
  34180. * Backing field
  34181. */
  34182. _mainSoundTrack: SoundTrack;
  34183. /**
  34184. * The main sound track played by the scene.
  34185. * It cotains your primary collection of sounds.
  34186. */
  34187. mainSoundTrack: SoundTrack;
  34188. /**
  34189. * The list of sound tracks added to the scene
  34190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34191. */
  34192. soundTracks: Nullable<Array<SoundTrack>>;
  34193. /**
  34194. * Gets a sound using a given name
  34195. * @param name defines the name to search for
  34196. * @return the found sound or null if not found at all.
  34197. */
  34198. getSoundByName(name: string): Nullable<Sound>;
  34199. /**
  34200. * Gets or sets if audio support is enabled
  34201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34202. */
  34203. audioEnabled: boolean;
  34204. /**
  34205. * Gets or sets if audio will be output to headphones
  34206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34207. */
  34208. headphone: boolean;
  34209. }
  34210. /**
  34211. * Defines the sound scene component responsible to manage any sounds
  34212. * in a given scene.
  34213. */
  34214. export class AudioSceneComponent implements ISceneSerializableComponent {
  34215. /**
  34216. * The component name helpfull to identify the component in the list of scene components.
  34217. */
  34218. readonly name: string;
  34219. /**
  34220. * The scene the component belongs to.
  34221. */
  34222. scene: Scene;
  34223. private _audioEnabled;
  34224. /**
  34225. * Gets whether audio is enabled or not.
  34226. * Please use related enable/disable method to switch state.
  34227. */
  34228. readonly audioEnabled: boolean;
  34229. private _headphone;
  34230. /**
  34231. * Gets whether audio is outputing to headphone or not.
  34232. * Please use the according Switch methods to change output.
  34233. */
  34234. readonly headphone: boolean;
  34235. /**
  34236. * Creates a new instance of the component for the given scene
  34237. * @param scene Defines the scene to register the component in
  34238. */
  34239. constructor(scene: Scene);
  34240. /**
  34241. * Registers the component in a given scene
  34242. */
  34243. register(): void;
  34244. /**
  34245. * Rebuilds the elements related to this component in case of
  34246. * context lost for instance.
  34247. */
  34248. rebuild(): void;
  34249. /**
  34250. * Serializes the component data to the specified json object
  34251. * @param serializationObject The object to serialize to
  34252. */
  34253. serialize(serializationObject: any): void;
  34254. /**
  34255. * Adds all the element from the container to the scene
  34256. * @param container the container holding the elements
  34257. */
  34258. addFromContainer(container: AbstractScene): void;
  34259. /**
  34260. * Removes all the elements in the container from the scene
  34261. * @param container contains the elements to remove
  34262. * @param dispose if the removed element should be disposed (default: false)
  34263. */
  34264. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34265. /**
  34266. * Disposes the component and the associated ressources.
  34267. */
  34268. dispose(): void;
  34269. /**
  34270. * Disables audio in the associated scene.
  34271. */
  34272. disableAudio(): void;
  34273. /**
  34274. * Enables audio in the associated scene.
  34275. */
  34276. enableAudio(): void;
  34277. /**
  34278. * Switch audio to headphone output.
  34279. */
  34280. switchAudioModeForHeadphones(): void;
  34281. /**
  34282. * Switch audio to normal speakers.
  34283. */
  34284. switchAudioModeForNormalSpeakers(): void;
  34285. private _afterRender;
  34286. }
  34287. }
  34288. declare module BABYLON {
  34289. /**
  34290. * Wraps one or more Sound objects and selects one with random weight for playback.
  34291. */
  34292. export class WeightedSound {
  34293. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34294. loop: boolean;
  34295. private _coneInnerAngle;
  34296. private _coneOuterAngle;
  34297. private _volume;
  34298. /** A Sound is currently playing. */
  34299. isPlaying: boolean;
  34300. /** A Sound is currently paused. */
  34301. isPaused: boolean;
  34302. private _sounds;
  34303. private _weights;
  34304. private _currentIndex?;
  34305. /**
  34306. * Creates a new WeightedSound from the list of sounds given.
  34307. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34308. * @param sounds Array of Sounds that will be selected from.
  34309. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34310. */
  34311. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34312. /**
  34313. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34314. */
  34315. /**
  34316. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34317. */
  34318. directionalConeInnerAngle: number;
  34319. /**
  34320. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34321. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34322. */
  34323. /**
  34324. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34325. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34326. */
  34327. directionalConeOuterAngle: number;
  34328. /**
  34329. * Playback volume.
  34330. */
  34331. /**
  34332. * Playback volume.
  34333. */
  34334. volume: number;
  34335. private _onended;
  34336. /**
  34337. * Suspend playback
  34338. */
  34339. pause(): void;
  34340. /**
  34341. * Stop playback
  34342. */
  34343. stop(): void;
  34344. /**
  34345. * Start playback.
  34346. * @param startOffset Position the clip head at a specific time in seconds.
  34347. */
  34348. play(startOffset?: number): void;
  34349. }
  34350. }
  34351. declare module BABYLON {
  34352. /**
  34353. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34355. */
  34356. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34357. /**
  34358. * Gets the name of the behavior.
  34359. */
  34360. readonly name: string;
  34361. /**
  34362. * The easing function used by animations
  34363. */
  34364. static EasingFunction: BackEase;
  34365. /**
  34366. * The easing mode used by animations
  34367. */
  34368. static EasingMode: number;
  34369. /**
  34370. * The duration of the animation, in milliseconds
  34371. */
  34372. transitionDuration: number;
  34373. /**
  34374. * Length of the distance animated by the transition when lower radius is reached
  34375. */
  34376. lowerRadiusTransitionRange: number;
  34377. /**
  34378. * Length of the distance animated by the transition when upper radius is reached
  34379. */
  34380. upperRadiusTransitionRange: number;
  34381. private _autoTransitionRange;
  34382. /**
  34383. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34384. */
  34385. /**
  34386. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34387. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34388. */
  34389. autoTransitionRange: boolean;
  34390. private _attachedCamera;
  34391. private _onAfterCheckInputsObserver;
  34392. private _onMeshTargetChangedObserver;
  34393. /**
  34394. * Initializes the behavior.
  34395. */
  34396. init(): void;
  34397. /**
  34398. * Attaches the behavior to its arc rotate camera.
  34399. * @param camera Defines the camera to attach the behavior to
  34400. */
  34401. attach(camera: ArcRotateCamera): void;
  34402. /**
  34403. * Detaches the behavior from its current arc rotate camera.
  34404. */
  34405. detach(): void;
  34406. private _radiusIsAnimating;
  34407. private _radiusBounceTransition;
  34408. private _animatables;
  34409. private _cachedWheelPrecision;
  34410. /**
  34411. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34412. * @param radiusLimit The limit to check against.
  34413. * @return Bool to indicate if at limit.
  34414. */
  34415. private _isRadiusAtLimit;
  34416. /**
  34417. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34418. * @param radiusDelta The delta by which to animate to. Can be negative.
  34419. */
  34420. private _applyBoundRadiusAnimation;
  34421. /**
  34422. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34423. */
  34424. protected _clearAnimationLocks(): void;
  34425. /**
  34426. * Stops and removes all animations that have been applied to the camera
  34427. */
  34428. stopAllAnimations(): void;
  34429. }
  34430. }
  34431. declare module BABYLON {
  34432. /**
  34433. * 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.
  34434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34435. */
  34436. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34437. /**
  34438. * Gets the name of the behavior.
  34439. */
  34440. readonly name: string;
  34441. private _mode;
  34442. private _radiusScale;
  34443. private _positionScale;
  34444. private _defaultElevation;
  34445. private _elevationReturnTime;
  34446. private _elevationReturnWaitTime;
  34447. private _zoomStopsAnimation;
  34448. private _framingTime;
  34449. /**
  34450. * The easing function used by animations
  34451. */
  34452. static EasingFunction: ExponentialEase;
  34453. /**
  34454. * The easing mode used by animations
  34455. */
  34456. static EasingMode: number;
  34457. /**
  34458. * Sets the current mode used by the behavior
  34459. */
  34460. /**
  34461. * Gets current mode used by the behavior.
  34462. */
  34463. mode: number;
  34464. /**
  34465. * Sets the scale applied to the radius (1 by default)
  34466. */
  34467. /**
  34468. * Gets the scale applied to the radius
  34469. */
  34470. radiusScale: number;
  34471. /**
  34472. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34473. */
  34474. /**
  34475. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34476. */
  34477. positionScale: number;
  34478. /**
  34479. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34480. * behaviour is triggered, in radians.
  34481. */
  34482. /**
  34483. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34484. * behaviour is triggered, in radians.
  34485. */
  34486. defaultElevation: number;
  34487. /**
  34488. * Sets the time (in milliseconds) taken to return to the default beta position.
  34489. * Negative value indicates camera should not return to default.
  34490. */
  34491. /**
  34492. * Gets the time (in milliseconds) taken to return to the default beta position.
  34493. * Negative value indicates camera should not return to default.
  34494. */
  34495. elevationReturnTime: number;
  34496. /**
  34497. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34498. */
  34499. /**
  34500. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34501. */
  34502. elevationReturnWaitTime: number;
  34503. /**
  34504. * Sets the flag that indicates if user zooming should stop animation.
  34505. */
  34506. /**
  34507. * Gets the flag that indicates if user zooming should stop animation.
  34508. */
  34509. zoomStopsAnimation: boolean;
  34510. /**
  34511. * Sets the transition time when framing the mesh, in milliseconds
  34512. */
  34513. /**
  34514. * Gets the transition time when framing the mesh, in milliseconds
  34515. */
  34516. framingTime: number;
  34517. /**
  34518. * Define if the behavior should automatically change the configured
  34519. * camera limits and sensibilities.
  34520. */
  34521. autoCorrectCameraLimitsAndSensibility: boolean;
  34522. private _onPrePointerObservableObserver;
  34523. private _onAfterCheckInputsObserver;
  34524. private _onMeshTargetChangedObserver;
  34525. private _attachedCamera;
  34526. private _isPointerDown;
  34527. private _lastInteractionTime;
  34528. /**
  34529. * Initializes the behavior.
  34530. */
  34531. init(): void;
  34532. /**
  34533. * Attaches the behavior to its arc rotate camera.
  34534. * @param camera Defines the camera to attach the behavior to
  34535. */
  34536. attach(camera: ArcRotateCamera): void;
  34537. /**
  34538. * Detaches the behavior from its current arc rotate camera.
  34539. */
  34540. detach(): void;
  34541. private _animatables;
  34542. private _betaIsAnimating;
  34543. private _betaTransition;
  34544. private _radiusTransition;
  34545. private _vectorTransition;
  34546. /**
  34547. * Targets the given mesh and updates zoom level accordingly.
  34548. * @param mesh The mesh to target.
  34549. * @param radius Optional. If a cached radius position already exists, overrides default.
  34550. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34553. */
  34554. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34555. /**
  34556. * Targets the given mesh with its children and updates zoom level accordingly.
  34557. * @param mesh The mesh to target.
  34558. * @param radius Optional. If a cached radius position already exists, overrides default.
  34559. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34560. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34561. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34562. */
  34563. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34564. /**
  34565. * Targets the given meshes with their children and updates zoom level accordingly.
  34566. * @param meshes The mesh to target.
  34567. * @param radius Optional. If a cached radius position already exists, overrides default.
  34568. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34569. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34570. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34571. */
  34572. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34573. /**
  34574. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34575. * @param minimumWorld Determines the smaller position of the bounding box extend
  34576. * @param maximumWorld Determines the bigger position of the bounding box extend
  34577. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34578. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34579. */
  34580. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34581. /**
  34582. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34583. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34584. * frustum width.
  34585. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34586. * to fully enclose the mesh in the viewing frustum.
  34587. */
  34588. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34589. /**
  34590. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34591. * is automatically returned to its default position (expected to be above ground plane).
  34592. */
  34593. private _maintainCameraAboveGround;
  34594. /**
  34595. * Returns the frustum slope based on the canvas ratio and camera FOV
  34596. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34597. */
  34598. private _getFrustumSlope;
  34599. /**
  34600. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34601. */
  34602. private _clearAnimationLocks;
  34603. /**
  34604. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34605. */
  34606. private _applyUserInteraction;
  34607. /**
  34608. * Stops and removes all animations that have been applied to the camera
  34609. */
  34610. stopAllAnimations(): void;
  34611. /**
  34612. * Gets a value indicating if the user is moving the camera
  34613. */
  34614. readonly isUserIsMoving: boolean;
  34615. /**
  34616. * The camera can move all the way towards the mesh.
  34617. */
  34618. static IgnoreBoundsSizeMode: number;
  34619. /**
  34620. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34621. */
  34622. static FitFrustumSidesMode: number;
  34623. }
  34624. }
  34625. declare module BABYLON {
  34626. /**
  34627. * Base class for Camera Pointer Inputs.
  34628. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34629. * for example usage.
  34630. */
  34631. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34632. /**
  34633. * Defines the camera the input is attached to.
  34634. */
  34635. abstract camera: Camera;
  34636. /**
  34637. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34638. */
  34639. protected _altKey: boolean;
  34640. protected _ctrlKey: boolean;
  34641. protected _metaKey: boolean;
  34642. protected _shiftKey: boolean;
  34643. /**
  34644. * Which mouse buttons were pressed at time of last mouse event.
  34645. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34646. */
  34647. protected _buttonsPressed: number;
  34648. /**
  34649. * Defines the buttons associated with the input to handle camera move.
  34650. */
  34651. buttons: number[];
  34652. /**
  34653. * Attach the input controls to a specific dom element to get the input from.
  34654. * @param element Defines the element the controls should be listened from
  34655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34656. */
  34657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34658. /**
  34659. * Detach the current controls from the specified dom element.
  34660. * @param element Defines the element to stop listening the inputs from
  34661. */
  34662. detachControl(element: Nullable<HTMLElement>): void;
  34663. /**
  34664. * Gets the class name of the current input.
  34665. * @returns the class name
  34666. */
  34667. getClassName(): string;
  34668. /**
  34669. * Get the friendly name associated with the input class.
  34670. * @returns the input friendly name
  34671. */
  34672. getSimpleName(): string;
  34673. /**
  34674. * Called on pointer POINTERDOUBLETAP event.
  34675. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34676. */
  34677. protected onDoubleTap(type: string): void;
  34678. /**
  34679. * Called on pointer POINTERMOVE event if only a single touch is active.
  34680. * Override this method to provide functionality.
  34681. */
  34682. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34683. /**
  34684. * Called on pointer POINTERMOVE event if multiple touches are active.
  34685. * Override this method to provide functionality.
  34686. */
  34687. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34688. /**
  34689. * Called on JS contextmenu event.
  34690. * Override this method to provide functionality.
  34691. */
  34692. protected onContextMenu(evt: PointerEvent): void;
  34693. /**
  34694. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34695. * press.
  34696. * Override this method to provide functionality.
  34697. */
  34698. protected onButtonDown(evt: PointerEvent): void;
  34699. /**
  34700. * Called each time a new POINTERUP event occurs. Ie, for each button
  34701. * release.
  34702. * Override this method to provide functionality.
  34703. */
  34704. protected onButtonUp(evt: PointerEvent): void;
  34705. /**
  34706. * Called when window becomes inactive.
  34707. * Override this method to provide functionality.
  34708. */
  34709. protected onLostFocus(): void;
  34710. private _pointerInput;
  34711. private _observer;
  34712. private _onLostFocus;
  34713. private pointA;
  34714. private pointB;
  34715. }
  34716. }
  34717. declare module BABYLON {
  34718. /**
  34719. * Manage the pointers inputs to control an arc rotate camera.
  34720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34721. */
  34722. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34723. /**
  34724. * Defines the camera the input is attached to.
  34725. */
  34726. camera: ArcRotateCamera;
  34727. /**
  34728. * Gets the class name of the current input.
  34729. * @returns the class name
  34730. */
  34731. getClassName(): string;
  34732. /**
  34733. * Defines the buttons associated with the input to handle camera move.
  34734. */
  34735. buttons: number[];
  34736. /**
  34737. * Defines the pointer angular sensibility along the X axis or how fast is
  34738. * the camera rotating.
  34739. */
  34740. angularSensibilityX: number;
  34741. /**
  34742. * Defines the pointer angular sensibility along the Y axis or how fast is
  34743. * the camera rotating.
  34744. */
  34745. angularSensibilityY: number;
  34746. /**
  34747. * Defines the pointer pinch precision or how fast is the camera zooming.
  34748. */
  34749. pinchPrecision: number;
  34750. /**
  34751. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34752. * from 0.
  34753. * It defines the percentage of current camera.radius to use as delta when
  34754. * pinch zoom is used.
  34755. */
  34756. pinchDeltaPercentage: number;
  34757. /**
  34758. * Defines the pointer panning sensibility or how fast is the camera moving.
  34759. */
  34760. panningSensibility: number;
  34761. /**
  34762. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34763. */
  34764. multiTouchPanning: boolean;
  34765. /**
  34766. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34767. * zoom (pinch) through multitouch.
  34768. */
  34769. multiTouchPanAndZoom: boolean;
  34770. /**
  34771. * Revers pinch action direction.
  34772. */
  34773. pinchInwards: boolean;
  34774. private _isPanClick;
  34775. private _twoFingerActivityCount;
  34776. private _isPinching;
  34777. /**
  34778. * Called on pointer POINTERMOVE event if only a single touch is active.
  34779. */
  34780. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34781. /**
  34782. * Called on pointer POINTERDOUBLETAP event.
  34783. */
  34784. protected onDoubleTap(type: string): void;
  34785. /**
  34786. * Called on pointer POINTERMOVE event if multiple touches are active.
  34787. */
  34788. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34789. /**
  34790. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34791. * press.
  34792. */
  34793. protected onButtonDown(evt: PointerEvent): void;
  34794. /**
  34795. * Called each time a new POINTERUP event occurs. Ie, for each button
  34796. * release.
  34797. */
  34798. protected onButtonUp(evt: PointerEvent): void;
  34799. /**
  34800. * Called when window becomes inactive.
  34801. */
  34802. protected onLostFocus(): void;
  34803. }
  34804. }
  34805. declare module BABYLON {
  34806. /**
  34807. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34809. */
  34810. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34811. /**
  34812. * Defines the camera the input is attached to.
  34813. */
  34814. camera: ArcRotateCamera;
  34815. /**
  34816. * Defines the list of key codes associated with the up action (increase alpha)
  34817. */
  34818. keysUp: number[];
  34819. /**
  34820. * Defines the list of key codes associated with the down action (decrease alpha)
  34821. */
  34822. keysDown: number[];
  34823. /**
  34824. * Defines the list of key codes associated with the left action (increase beta)
  34825. */
  34826. keysLeft: number[];
  34827. /**
  34828. * Defines the list of key codes associated with the right action (decrease beta)
  34829. */
  34830. keysRight: number[];
  34831. /**
  34832. * Defines the list of key codes associated with the reset action.
  34833. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34834. */
  34835. keysReset: number[];
  34836. /**
  34837. * Defines the panning sensibility of the inputs.
  34838. * (How fast is the camera paning)
  34839. */
  34840. panningSensibility: number;
  34841. /**
  34842. * Defines the zooming sensibility of the inputs.
  34843. * (How fast is the camera zooming)
  34844. */
  34845. zoomingSensibility: number;
  34846. /**
  34847. * Defines wether maintaining the alt key down switch the movement mode from
  34848. * orientation to zoom.
  34849. */
  34850. useAltToZoom: boolean;
  34851. /**
  34852. * Rotation speed of the camera
  34853. */
  34854. angularSpeed: number;
  34855. private _keys;
  34856. private _ctrlPressed;
  34857. private _altPressed;
  34858. private _onCanvasBlurObserver;
  34859. private _onKeyboardObserver;
  34860. private _engine;
  34861. private _scene;
  34862. /**
  34863. * Attach the input controls to a specific dom element to get the input from.
  34864. * @param element Defines the element the controls should be listened from
  34865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34866. */
  34867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34868. /**
  34869. * Detach the current controls from the specified dom element.
  34870. * @param element Defines the element to stop listening the inputs from
  34871. */
  34872. detachControl(element: Nullable<HTMLElement>): void;
  34873. /**
  34874. * Update the current camera state depending on the inputs that have been used this frame.
  34875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34876. */
  34877. checkInputs(): void;
  34878. /**
  34879. * Gets the class name of the current intput.
  34880. * @returns the class name
  34881. */
  34882. getClassName(): string;
  34883. /**
  34884. * Get the friendly name associated with the input class.
  34885. * @returns the input friendly name
  34886. */
  34887. getSimpleName(): string;
  34888. }
  34889. }
  34890. declare module BABYLON {
  34891. /**
  34892. * Manage the mouse wheel inputs to control an arc rotate camera.
  34893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34894. */
  34895. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34896. /**
  34897. * Defines the camera the input is attached to.
  34898. */
  34899. camera: ArcRotateCamera;
  34900. /**
  34901. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34902. */
  34903. wheelPrecision: number;
  34904. /**
  34905. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34906. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34907. */
  34908. wheelDeltaPercentage: number;
  34909. private _wheel;
  34910. private _observer;
  34911. /**
  34912. * Attach the input controls to a specific dom element to get the input from.
  34913. * @param element Defines the element the controls should be listened from
  34914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34915. */
  34916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34917. /**
  34918. * Detach the current controls from the specified dom element.
  34919. * @param element Defines the element to stop listening the inputs from
  34920. */
  34921. detachControl(element: Nullable<HTMLElement>): void;
  34922. /**
  34923. * Gets the class name of the current intput.
  34924. * @returns the class name
  34925. */
  34926. getClassName(): string;
  34927. /**
  34928. * Get the friendly name associated with the input class.
  34929. * @returns the input friendly name
  34930. */
  34931. getSimpleName(): string;
  34932. }
  34933. }
  34934. declare module BABYLON {
  34935. /**
  34936. * Default Inputs manager for the ArcRotateCamera.
  34937. * It groups all the default supported inputs for ease of use.
  34938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34939. */
  34940. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34941. /**
  34942. * Instantiates a new ArcRotateCameraInputsManager.
  34943. * @param camera Defines the camera the inputs belong to
  34944. */
  34945. constructor(camera: ArcRotateCamera);
  34946. /**
  34947. * Add mouse wheel input support to the input manager.
  34948. * @returns the current input manager
  34949. */
  34950. addMouseWheel(): ArcRotateCameraInputsManager;
  34951. /**
  34952. * Add pointers input support to the input manager.
  34953. * @returns the current input manager
  34954. */
  34955. addPointers(): ArcRotateCameraInputsManager;
  34956. /**
  34957. * Add keyboard input support to the input manager.
  34958. * @returns the current input manager
  34959. */
  34960. addKeyboard(): ArcRotateCameraInputsManager;
  34961. }
  34962. }
  34963. declare module BABYLON {
  34964. /**
  34965. * This represents an orbital type of camera.
  34966. *
  34967. * 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.
  34968. * 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.
  34969. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34970. */
  34971. export class ArcRotateCamera extends TargetCamera {
  34972. /**
  34973. * Defines the rotation angle of the camera along the longitudinal axis.
  34974. */
  34975. alpha: number;
  34976. /**
  34977. * Defines the rotation angle of the camera along the latitudinal axis.
  34978. */
  34979. beta: number;
  34980. /**
  34981. * Defines the radius of the camera from it s target point.
  34982. */
  34983. radius: number;
  34984. protected _target: Vector3;
  34985. protected _targetHost: Nullable<AbstractMesh>;
  34986. /**
  34987. * Defines the target point of the camera.
  34988. * The camera looks towards it form the radius distance.
  34989. */
  34990. target: Vector3;
  34991. /**
  34992. * Define the current local position of the camera in the scene
  34993. */
  34994. position: Vector3;
  34995. protected _upVector: Vector3;
  34996. protected _upToYMatrix: Matrix;
  34997. protected _YToUpMatrix: Matrix;
  34998. /**
  34999. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35000. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35001. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35002. */
  35003. upVector: Vector3;
  35004. /**
  35005. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35006. */
  35007. setMatUp(): void;
  35008. /**
  35009. * Current inertia value on the longitudinal axis.
  35010. * The bigger this number the longer it will take for the camera to stop.
  35011. */
  35012. inertialAlphaOffset: number;
  35013. /**
  35014. * Current inertia value on the latitudinal axis.
  35015. * The bigger this number the longer it will take for the camera to stop.
  35016. */
  35017. inertialBetaOffset: number;
  35018. /**
  35019. * Current inertia value on the radius axis.
  35020. * The bigger this number the longer it will take for the camera to stop.
  35021. */
  35022. inertialRadiusOffset: number;
  35023. /**
  35024. * Minimum allowed angle on the longitudinal axis.
  35025. * This can help limiting how the Camera is able to move in the scene.
  35026. */
  35027. lowerAlphaLimit: Nullable<number>;
  35028. /**
  35029. * Maximum allowed angle on the longitudinal axis.
  35030. * This can help limiting how the Camera is able to move in the scene.
  35031. */
  35032. upperAlphaLimit: Nullable<number>;
  35033. /**
  35034. * Minimum allowed angle on the latitudinal axis.
  35035. * This can help limiting how the Camera is able to move in the scene.
  35036. */
  35037. lowerBetaLimit: number;
  35038. /**
  35039. * Maximum allowed angle on the latitudinal axis.
  35040. * This can help limiting how the Camera is able to move in the scene.
  35041. */
  35042. upperBetaLimit: number;
  35043. /**
  35044. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35045. * This can help limiting how the Camera is able to move in the scene.
  35046. */
  35047. lowerRadiusLimit: Nullable<number>;
  35048. /**
  35049. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35050. * This can help limiting how the Camera is able to move in the scene.
  35051. */
  35052. upperRadiusLimit: Nullable<number>;
  35053. /**
  35054. * Defines the current inertia value used during panning of the camera along the X axis.
  35055. */
  35056. inertialPanningX: number;
  35057. /**
  35058. * Defines the current inertia value used during panning of the camera along the Y axis.
  35059. */
  35060. inertialPanningY: number;
  35061. /**
  35062. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35063. * Basically if your fingers moves away from more than this distance you will be considered
  35064. * in pinch mode.
  35065. */
  35066. pinchToPanMaxDistance: number;
  35067. /**
  35068. * Defines the maximum distance the camera can pan.
  35069. * This could help keeping the cammera always in your scene.
  35070. */
  35071. panningDistanceLimit: Nullable<number>;
  35072. /**
  35073. * Defines the target of the camera before paning.
  35074. */
  35075. panningOriginTarget: Vector3;
  35076. /**
  35077. * Defines the value of the inertia used during panning.
  35078. * 0 would mean stop inertia and one would mean no decelleration at all.
  35079. */
  35080. panningInertia: number;
  35081. /**
  35082. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35083. */
  35084. angularSensibilityX: number;
  35085. /**
  35086. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35087. */
  35088. angularSensibilityY: number;
  35089. /**
  35090. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35091. */
  35092. pinchPrecision: number;
  35093. /**
  35094. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35095. * It will be used instead of pinchDeltaPrecision if different from 0.
  35096. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35097. */
  35098. pinchDeltaPercentage: number;
  35099. /**
  35100. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35101. */
  35102. panningSensibility: number;
  35103. /**
  35104. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35105. */
  35106. keysUp: number[];
  35107. /**
  35108. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35109. */
  35110. keysDown: number[];
  35111. /**
  35112. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35113. */
  35114. keysLeft: number[];
  35115. /**
  35116. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35117. */
  35118. keysRight: number[];
  35119. /**
  35120. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35121. */
  35122. wheelPrecision: number;
  35123. /**
  35124. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35125. * It will be used instead of pinchDeltaPrecision if different from 0.
  35126. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35127. */
  35128. wheelDeltaPercentage: number;
  35129. /**
  35130. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35131. */
  35132. zoomOnFactor: number;
  35133. /**
  35134. * Defines a screen offset for the camera position.
  35135. */
  35136. targetScreenOffset: Vector2;
  35137. /**
  35138. * Allows the camera to be completely reversed.
  35139. * If false the camera can not arrive upside down.
  35140. */
  35141. allowUpsideDown: boolean;
  35142. /**
  35143. * Define if double tap/click is used to restore the previously saved state of the camera.
  35144. */
  35145. useInputToRestoreState: boolean;
  35146. /** @hidden */
  35147. _viewMatrix: Matrix;
  35148. /** @hidden */
  35149. _useCtrlForPanning: boolean;
  35150. /** @hidden */
  35151. _panningMouseButton: number;
  35152. /**
  35153. * Defines the input associated to the camera.
  35154. */
  35155. inputs: ArcRotateCameraInputsManager;
  35156. /** @hidden */
  35157. _reset: () => void;
  35158. /**
  35159. * Defines the allowed panning axis.
  35160. */
  35161. panningAxis: Vector3;
  35162. protected _localDirection: Vector3;
  35163. protected _transformedDirection: Vector3;
  35164. private _bouncingBehavior;
  35165. /**
  35166. * Gets the bouncing behavior of the camera if it has been enabled.
  35167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35168. */
  35169. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35170. /**
  35171. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35173. */
  35174. useBouncingBehavior: boolean;
  35175. private _framingBehavior;
  35176. /**
  35177. * Gets the framing behavior of the camera if it has been enabled.
  35178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35179. */
  35180. readonly framingBehavior: Nullable<FramingBehavior>;
  35181. /**
  35182. * Defines if the framing behavior of the camera is enabled on the camera.
  35183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35184. */
  35185. useFramingBehavior: boolean;
  35186. private _autoRotationBehavior;
  35187. /**
  35188. * Gets the auto rotation behavior of the camera if it has been enabled.
  35189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35190. */
  35191. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35192. /**
  35193. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35194. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35195. */
  35196. useAutoRotationBehavior: boolean;
  35197. /**
  35198. * Observable triggered when the mesh target has been changed on the camera.
  35199. */
  35200. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35201. /**
  35202. * Event raised when the camera is colliding with a mesh.
  35203. */
  35204. onCollide: (collidedMesh: AbstractMesh) => void;
  35205. /**
  35206. * Defines whether the camera should check collision with the objects oh the scene.
  35207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35208. */
  35209. checkCollisions: boolean;
  35210. /**
  35211. * Defines the collision radius of the camera.
  35212. * This simulates a sphere around the camera.
  35213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35214. */
  35215. collisionRadius: Vector3;
  35216. protected _collider: Collider;
  35217. protected _previousPosition: Vector3;
  35218. protected _collisionVelocity: Vector3;
  35219. protected _newPosition: Vector3;
  35220. protected _previousAlpha: number;
  35221. protected _previousBeta: number;
  35222. protected _previousRadius: number;
  35223. protected _collisionTriggered: boolean;
  35224. protected _targetBoundingCenter: Nullable<Vector3>;
  35225. private _computationVector;
  35226. /**
  35227. * Instantiates a new ArcRotateCamera in a given scene
  35228. * @param name Defines the name of the camera
  35229. * @param alpha Defines the camera rotation along the logitudinal axis
  35230. * @param beta Defines the camera rotation along the latitudinal axis
  35231. * @param radius Defines the camera distance from its target
  35232. * @param target Defines the camera target
  35233. * @param scene Defines the scene the camera belongs to
  35234. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35235. */
  35236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35237. /** @hidden */
  35238. _initCache(): void;
  35239. /** @hidden */
  35240. _updateCache(ignoreParentClass?: boolean): void;
  35241. protected _getTargetPosition(): Vector3;
  35242. private _storedAlpha;
  35243. private _storedBeta;
  35244. private _storedRadius;
  35245. private _storedTarget;
  35246. /**
  35247. * Stores the current state of the camera (alpha, beta, radius and target)
  35248. * @returns the camera itself
  35249. */
  35250. storeState(): Camera;
  35251. /**
  35252. * @hidden
  35253. * Restored camera state. You must call storeState() first
  35254. */
  35255. _restoreStateValues(): boolean;
  35256. /** @hidden */
  35257. _isSynchronizedViewMatrix(): boolean;
  35258. /**
  35259. * Attached controls to the current camera.
  35260. * @param element Defines the element the controls should be listened from
  35261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35262. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35263. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35264. */
  35265. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35266. /**
  35267. * Detach the current controls from the camera.
  35268. * The camera will stop reacting to inputs.
  35269. * @param element Defines the element to stop listening the inputs from
  35270. */
  35271. detachControl(element: HTMLElement): void;
  35272. /** @hidden */
  35273. _checkInputs(): void;
  35274. protected _checkLimits(): void;
  35275. /**
  35276. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35277. */
  35278. rebuildAnglesAndRadius(): void;
  35279. /**
  35280. * Use a position to define the current camera related information like aplha, beta and radius
  35281. * @param position Defines the position to set the camera at
  35282. */
  35283. setPosition(position: Vector3): void;
  35284. /**
  35285. * Defines the target the camera should look at.
  35286. * This will automatically adapt alpha beta and radius to fit within the new target.
  35287. * @param target Defines the new target as a Vector or a mesh
  35288. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35289. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35290. */
  35291. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35292. /** @hidden */
  35293. _getViewMatrix(): Matrix;
  35294. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35295. /**
  35296. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35297. * @param meshes Defines the mesh to zoom on
  35298. * @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)
  35299. */
  35300. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35301. /**
  35302. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35303. * The target will be changed but the radius
  35304. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35305. * @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)
  35306. */
  35307. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35308. min: Vector3;
  35309. max: Vector3;
  35310. distance: number;
  35311. }, doNotUpdateMaxZ?: boolean): void;
  35312. /**
  35313. * @override
  35314. * Override Camera.createRigCamera
  35315. */
  35316. createRigCamera(name: string, cameraIndex: number): Camera;
  35317. /**
  35318. * @hidden
  35319. * @override
  35320. * Override Camera._updateRigCameras
  35321. */
  35322. _updateRigCameras(): void;
  35323. /**
  35324. * Destroy the camera and release the current resources hold by it.
  35325. */
  35326. dispose(): void;
  35327. /**
  35328. * Gets the current object class name.
  35329. * @return the class name
  35330. */
  35331. getClassName(): string;
  35332. }
  35333. }
  35334. declare module BABYLON {
  35335. /**
  35336. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35338. */
  35339. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35340. /**
  35341. * Gets the name of the behavior.
  35342. */
  35343. readonly name: string;
  35344. private _zoomStopsAnimation;
  35345. private _idleRotationSpeed;
  35346. private _idleRotationWaitTime;
  35347. private _idleRotationSpinupTime;
  35348. /**
  35349. * Sets the flag that indicates if user zooming should stop animation.
  35350. */
  35351. /**
  35352. * Gets the flag that indicates if user zooming should stop animation.
  35353. */
  35354. zoomStopsAnimation: boolean;
  35355. /**
  35356. * Sets the default speed at which the camera rotates around the model.
  35357. */
  35358. /**
  35359. * Gets the default speed at which the camera rotates around the model.
  35360. */
  35361. idleRotationSpeed: number;
  35362. /**
  35363. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35364. */
  35365. /**
  35366. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35367. */
  35368. idleRotationWaitTime: number;
  35369. /**
  35370. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35371. */
  35372. /**
  35373. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35374. */
  35375. idleRotationSpinupTime: number;
  35376. /**
  35377. * Gets a value indicating if the camera is currently rotating because of this behavior
  35378. */
  35379. readonly rotationInProgress: boolean;
  35380. private _onPrePointerObservableObserver;
  35381. private _onAfterCheckInputsObserver;
  35382. private _attachedCamera;
  35383. private _isPointerDown;
  35384. private _lastFrameTime;
  35385. private _lastInteractionTime;
  35386. private _cameraRotationSpeed;
  35387. /**
  35388. * Initializes the behavior.
  35389. */
  35390. init(): void;
  35391. /**
  35392. * Attaches the behavior to its arc rotate camera.
  35393. * @param camera Defines the camera to attach the behavior to
  35394. */
  35395. attach(camera: ArcRotateCamera): void;
  35396. /**
  35397. * Detaches the behavior from its current arc rotate camera.
  35398. */
  35399. detach(): void;
  35400. /**
  35401. * Returns true if user is scrolling.
  35402. * @return true if user is scrolling.
  35403. */
  35404. private _userIsZooming;
  35405. private _lastFrameRadius;
  35406. private _shouldAnimationStopForInteraction;
  35407. /**
  35408. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35409. */
  35410. private _applyUserInteraction;
  35411. private _userIsMoving;
  35412. }
  35413. }
  35414. declare module BABYLON {
  35415. /**
  35416. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35417. */
  35418. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35419. private ui;
  35420. /**
  35421. * The name of the behavior
  35422. */
  35423. name: string;
  35424. /**
  35425. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35426. */
  35427. distanceAwayFromFace: number;
  35428. /**
  35429. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35430. */
  35431. distanceAwayFromBottomOfFace: number;
  35432. private _faceVectors;
  35433. private _target;
  35434. private _scene;
  35435. private _onRenderObserver;
  35436. private _tmpMatrix;
  35437. private _tmpVector;
  35438. /**
  35439. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35440. * @param ui The transform node that should be attched to the mesh
  35441. */
  35442. constructor(ui: TransformNode);
  35443. /**
  35444. * Initializes the behavior
  35445. */
  35446. init(): void;
  35447. private _closestFace;
  35448. private _zeroVector;
  35449. private _lookAtTmpMatrix;
  35450. private _lookAtToRef;
  35451. /**
  35452. * Attaches the AttachToBoxBehavior to the passed in mesh
  35453. * @param target The mesh that the specified node will be attached to
  35454. */
  35455. attach(target: Mesh): void;
  35456. /**
  35457. * Detaches the behavior from the mesh
  35458. */
  35459. detach(): void;
  35460. }
  35461. }
  35462. declare module BABYLON {
  35463. /**
  35464. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35465. */
  35466. export class FadeInOutBehavior implements Behavior<Mesh> {
  35467. /**
  35468. * Time in milliseconds to delay before fading in (Default: 0)
  35469. */
  35470. delay: number;
  35471. /**
  35472. * Time in milliseconds for the mesh to fade in (Default: 300)
  35473. */
  35474. fadeInTime: number;
  35475. private _millisecondsPerFrame;
  35476. private _hovered;
  35477. private _hoverValue;
  35478. private _ownerNode;
  35479. /**
  35480. * Instatiates the FadeInOutBehavior
  35481. */
  35482. constructor();
  35483. /**
  35484. * The name of the behavior
  35485. */
  35486. readonly name: string;
  35487. /**
  35488. * Initializes the behavior
  35489. */
  35490. init(): void;
  35491. /**
  35492. * Attaches the fade behavior on the passed in mesh
  35493. * @param ownerNode The mesh that will be faded in/out once attached
  35494. */
  35495. attach(ownerNode: Mesh): void;
  35496. /**
  35497. * Detaches the behavior from the mesh
  35498. */
  35499. detach(): void;
  35500. /**
  35501. * Triggers the mesh to begin fading in or out
  35502. * @param value if the object should fade in or out (true to fade in)
  35503. */
  35504. fadeIn(value: boolean): void;
  35505. private _update;
  35506. private _setAllVisibility;
  35507. }
  35508. }
  35509. declare module BABYLON {
  35510. /**
  35511. * Class containing a set of static utilities functions for managing Pivots
  35512. * @hidden
  35513. */
  35514. export class PivotTools {
  35515. private static _PivotCached;
  35516. private static _OldPivotPoint;
  35517. private static _PivotTranslation;
  35518. private static _PivotTmpVector;
  35519. /** @hidden */
  35520. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35521. /** @hidden */
  35522. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35523. }
  35524. }
  35525. declare module BABYLON {
  35526. /**
  35527. * Class containing static functions to help procedurally build meshes
  35528. */
  35529. export class PlaneBuilder {
  35530. /**
  35531. * Creates a plane mesh
  35532. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35533. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35534. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35536. * * 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
  35537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35538. * @param name defines the name of the mesh
  35539. * @param options defines the options used to create the mesh
  35540. * @param scene defines the hosting scene
  35541. * @returns the plane mesh
  35542. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35543. */
  35544. static CreatePlane(name: string, options: {
  35545. size?: number;
  35546. width?: number;
  35547. height?: number;
  35548. sideOrientation?: number;
  35549. frontUVs?: Vector4;
  35550. backUVs?: Vector4;
  35551. updatable?: boolean;
  35552. sourcePlane?: Plane;
  35553. }, scene?: Nullable<Scene>): Mesh;
  35554. }
  35555. }
  35556. declare module BABYLON {
  35557. /**
  35558. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35559. */
  35560. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35561. private static _AnyMouseID;
  35562. private _attachedNode;
  35563. private _dragPlane;
  35564. private _scene;
  35565. private _pointerObserver;
  35566. private _beforeRenderObserver;
  35567. private static _planeScene;
  35568. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35569. /**
  35570. * 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)
  35571. */
  35572. maxDragAngle: number;
  35573. /**
  35574. * @hidden
  35575. */
  35576. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35577. /**
  35578. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35579. */
  35580. currentDraggingPointerID: number;
  35581. /**
  35582. * The last position where the pointer hit the drag plane in world space
  35583. */
  35584. lastDragPosition: Vector3;
  35585. /**
  35586. * If the behavior is currently in a dragging state
  35587. */
  35588. dragging: boolean;
  35589. /**
  35590. * 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)
  35591. */
  35592. dragDeltaRatio: number;
  35593. /**
  35594. * If the drag plane orientation should be updated during the dragging (Default: true)
  35595. */
  35596. updateDragPlane: boolean;
  35597. private _debugMode;
  35598. private _moving;
  35599. /**
  35600. * Fires each time the attached mesh is dragged with the pointer
  35601. * * delta between last drag position and current drag position in world space
  35602. * * dragDistance along the drag axis
  35603. * * dragPlaneNormal normal of the current drag plane used during the drag
  35604. * * dragPlanePoint in world space where the drag intersects the drag plane
  35605. */
  35606. onDragObservable: Observable<{
  35607. delta: Vector3;
  35608. dragPlanePoint: Vector3;
  35609. dragPlaneNormal: Vector3;
  35610. dragDistance: number;
  35611. pointerId: number;
  35612. }>;
  35613. /**
  35614. * Fires each time a drag begins (eg. mouse down on mesh)
  35615. */
  35616. onDragStartObservable: Observable<{
  35617. dragPlanePoint: Vector3;
  35618. pointerId: number;
  35619. }>;
  35620. /**
  35621. * Fires each time a drag ends (eg. mouse release after drag)
  35622. */
  35623. onDragEndObservable: Observable<{
  35624. dragPlanePoint: Vector3;
  35625. pointerId: number;
  35626. }>;
  35627. /**
  35628. * If the attached mesh should be moved when dragged
  35629. */
  35630. moveAttached: boolean;
  35631. /**
  35632. * If the drag behavior will react to drag events (Default: true)
  35633. */
  35634. enabled: boolean;
  35635. /**
  35636. * If camera controls should be detached during the drag
  35637. */
  35638. detachCameraControls: boolean;
  35639. /**
  35640. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35641. */
  35642. useObjectOrienationForDragging: boolean;
  35643. private _options;
  35644. /**
  35645. * Creates a pointer drag behavior that can be attached to a mesh
  35646. * @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)
  35647. */
  35648. constructor(options?: {
  35649. dragAxis?: Vector3;
  35650. dragPlaneNormal?: Vector3;
  35651. });
  35652. /**
  35653. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35654. */
  35655. validateDrag: (targetPosition: Vector3) => boolean;
  35656. /**
  35657. * The name of the behavior
  35658. */
  35659. readonly name: string;
  35660. /**
  35661. * Initializes the behavior
  35662. */
  35663. init(): void;
  35664. private _tmpVector;
  35665. private _alternatePickedPoint;
  35666. private _worldDragAxis;
  35667. private _targetPosition;
  35668. private _attachedElement;
  35669. /**
  35670. * Attaches the drag behavior the passed in mesh
  35671. * @param ownerNode The mesh that will be dragged around once attached
  35672. */
  35673. attach(ownerNode: AbstractMesh): void;
  35674. /**
  35675. * Force relase the drag action by code.
  35676. */
  35677. releaseDrag(): void;
  35678. private _startDragRay;
  35679. private _lastPointerRay;
  35680. /**
  35681. * Simulates the start of a pointer drag event on the behavior
  35682. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35683. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35684. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35685. */
  35686. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35687. private _startDrag;
  35688. private _dragDelta;
  35689. private _moveDrag;
  35690. private _pickWithRayOnDragPlane;
  35691. private _pointA;
  35692. private _pointB;
  35693. private _pointC;
  35694. private _lineA;
  35695. private _lineB;
  35696. private _localAxis;
  35697. private _lookAt;
  35698. private _updateDragPlanePosition;
  35699. /**
  35700. * Detaches the behavior from the mesh
  35701. */
  35702. detach(): void;
  35703. }
  35704. }
  35705. declare module BABYLON {
  35706. /**
  35707. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35708. */
  35709. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35710. private _dragBehaviorA;
  35711. private _dragBehaviorB;
  35712. private _startDistance;
  35713. private _initialScale;
  35714. private _targetScale;
  35715. private _ownerNode;
  35716. private _sceneRenderObserver;
  35717. /**
  35718. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35719. */
  35720. constructor();
  35721. /**
  35722. * The name of the behavior
  35723. */
  35724. readonly name: string;
  35725. /**
  35726. * Initializes the behavior
  35727. */
  35728. init(): void;
  35729. private _getCurrentDistance;
  35730. /**
  35731. * Attaches the scale behavior the passed in mesh
  35732. * @param ownerNode The mesh that will be scaled around once attached
  35733. */
  35734. attach(ownerNode: Mesh): void;
  35735. /**
  35736. * Detaches the behavior from the mesh
  35737. */
  35738. detach(): void;
  35739. }
  35740. }
  35741. declare module BABYLON {
  35742. /**
  35743. * 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
  35744. */
  35745. export class SixDofDragBehavior implements Behavior<Mesh> {
  35746. private static _virtualScene;
  35747. private _ownerNode;
  35748. private _sceneRenderObserver;
  35749. private _scene;
  35750. private _targetPosition;
  35751. private _virtualOriginMesh;
  35752. private _virtualDragMesh;
  35753. private _pointerObserver;
  35754. private _moving;
  35755. private _startingOrientation;
  35756. /**
  35757. * 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)
  35758. */
  35759. private zDragFactor;
  35760. /**
  35761. * If the object should rotate to face the drag origin
  35762. */
  35763. rotateDraggedObject: boolean;
  35764. /**
  35765. * If the behavior is currently in a dragging state
  35766. */
  35767. dragging: boolean;
  35768. /**
  35769. * 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)
  35770. */
  35771. dragDeltaRatio: number;
  35772. /**
  35773. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35774. */
  35775. currentDraggingPointerID: number;
  35776. /**
  35777. * If camera controls should be detached during the drag
  35778. */
  35779. detachCameraControls: boolean;
  35780. /**
  35781. * Fires each time a drag starts
  35782. */
  35783. onDragStartObservable: Observable<{}>;
  35784. /**
  35785. * Fires each time a drag ends (eg. mouse release after drag)
  35786. */
  35787. onDragEndObservable: Observable<{}>;
  35788. /**
  35789. * 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
  35790. */
  35791. constructor();
  35792. /**
  35793. * The name of the behavior
  35794. */
  35795. readonly name: string;
  35796. /**
  35797. * Initializes the behavior
  35798. */
  35799. init(): void;
  35800. /**
  35801. * Attaches the scale behavior the passed in mesh
  35802. * @param ownerNode The mesh that will be scaled around once attached
  35803. */
  35804. attach(ownerNode: Mesh): void;
  35805. /**
  35806. * Detaches the behavior from the mesh
  35807. */
  35808. detach(): void;
  35809. }
  35810. }
  35811. declare module BABYLON {
  35812. /**
  35813. * Class used to apply inverse kinematics to bones
  35814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35815. */
  35816. export class BoneIKController {
  35817. private static _tmpVecs;
  35818. private static _tmpQuat;
  35819. private static _tmpMats;
  35820. /**
  35821. * Gets or sets the target mesh
  35822. */
  35823. targetMesh: AbstractMesh;
  35824. /** Gets or sets the mesh used as pole */
  35825. poleTargetMesh: AbstractMesh;
  35826. /**
  35827. * Gets or sets the bone used as pole
  35828. */
  35829. poleTargetBone: Nullable<Bone>;
  35830. /**
  35831. * Gets or sets the target position
  35832. */
  35833. targetPosition: Vector3;
  35834. /**
  35835. * Gets or sets the pole target position
  35836. */
  35837. poleTargetPosition: Vector3;
  35838. /**
  35839. * Gets or sets the pole target local offset
  35840. */
  35841. poleTargetLocalOffset: Vector3;
  35842. /**
  35843. * Gets or sets the pole angle
  35844. */
  35845. poleAngle: number;
  35846. /**
  35847. * Gets or sets the mesh associated with the controller
  35848. */
  35849. mesh: AbstractMesh;
  35850. /**
  35851. * 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)
  35852. */
  35853. slerpAmount: number;
  35854. private _bone1Quat;
  35855. private _bone1Mat;
  35856. private _bone2Ang;
  35857. private _bone1;
  35858. private _bone2;
  35859. private _bone1Length;
  35860. private _bone2Length;
  35861. private _maxAngle;
  35862. private _maxReach;
  35863. private _rightHandedSystem;
  35864. private _bendAxis;
  35865. private _slerping;
  35866. private _adjustRoll;
  35867. /**
  35868. * Gets or sets maximum allowed angle
  35869. */
  35870. maxAngle: number;
  35871. /**
  35872. * Creates a new BoneIKController
  35873. * @param mesh defines the mesh to control
  35874. * @param bone defines the bone to control
  35875. * @param options defines options to set up the controller
  35876. */
  35877. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35878. targetMesh?: AbstractMesh;
  35879. poleTargetMesh?: AbstractMesh;
  35880. poleTargetBone?: Bone;
  35881. poleTargetLocalOffset?: Vector3;
  35882. poleAngle?: number;
  35883. bendAxis?: Vector3;
  35884. maxAngle?: number;
  35885. slerpAmount?: number;
  35886. });
  35887. private _setMaxAngle;
  35888. /**
  35889. * Force the controller to update the bones
  35890. */
  35891. update(): void;
  35892. }
  35893. }
  35894. declare module BABYLON {
  35895. /**
  35896. * Class used to make a bone look toward a point in space
  35897. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35898. */
  35899. export class BoneLookController {
  35900. private static _tmpVecs;
  35901. private static _tmpQuat;
  35902. private static _tmpMats;
  35903. /**
  35904. * The target Vector3 that the bone will look at
  35905. */
  35906. target: Vector3;
  35907. /**
  35908. * The mesh that the bone is attached to
  35909. */
  35910. mesh: AbstractMesh;
  35911. /**
  35912. * The bone that will be looking to the target
  35913. */
  35914. bone: Bone;
  35915. /**
  35916. * The up axis of the coordinate system that is used when the bone is rotated
  35917. */
  35918. upAxis: Vector3;
  35919. /**
  35920. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35921. */
  35922. upAxisSpace: Space;
  35923. /**
  35924. * Used to make an adjustment to the yaw of the bone
  35925. */
  35926. adjustYaw: number;
  35927. /**
  35928. * Used to make an adjustment to the pitch of the bone
  35929. */
  35930. adjustPitch: number;
  35931. /**
  35932. * Used to make an adjustment to the roll of the bone
  35933. */
  35934. adjustRoll: number;
  35935. /**
  35936. * 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)
  35937. */
  35938. slerpAmount: number;
  35939. private _minYaw;
  35940. private _maxYaw;
  35941. private _minPitch;
  35942. private _maxPitch;
  35943. private _minYawSin;
  35944. private _minYawCos;
  35945. private _maxYawSin;
  35946. private _maxYawCos;
  35947. private _midYawConstraint;
  35948. private _minPitchTan;
  35949. private _maxPitchTan;
  35950. private _boneQuat;
  35951. private _slerping;
  35952. private _transformYawPitch;
  35953. private _transformYawPitchInv;
  35954. private _firstFrameSkipped;
  35955. private _yawRange;
  35956. private _fowardAxis;
  35957. /**
  35958. * Gets or sets the minimum yaw angle that the bone can look to
  35959. */
  35960. minYaw: number;
  35961. /**
  35962. * Gets or sets the maximum yaw angle that the bone can look to
  35963. */
  35964. maxYaw: number;
  35965. /**
  35966. * Gets or sets the minimum pitch angle that the bone can look to
  35967. */
  35968. minPitch: number;
  35969. /**
  35970. * Gets or sets the maximum pitch angle that the bone can look to
  35971. */
  35972. maxPitch: number;
  35973. /**
  35974. * Create a BoneLookController
  35975. * @param mesh the mesh that the bone belongs to
  35976. * @param bone the bone that will be looking to the target
  35977. * @param target the target Vector3 to look at
  35978. * @param options optional settings:
  35979. * * maxYaw: the maximum angle the bone will yaw to
  35980. * * minYaw: the minimum angle the bone will yaw to
  35981. * * maxPitch: the maximum angle the bone will pitch to
  35982. * * minPitch: the minimum angle the bone will yaw to
  35983. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35984. * * upAxis: the up axis of the coordinate system
  35985. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35986. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35987. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35988. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35989. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35990. * * adjustRoll: used to make an adjustment to the roll of the bone
  35991. **/
  35992. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35993. maxYaw?: number;
  35994. minYaw?: number;
  35995. maxPitch?: number;
  35996. minPitch?: number;
  35997. slerpAmount?: number;
  35998. upAxis?: Vector3;
  35999. upAxisSpace?: Space;
  36000. yawAxis?: Vector3;
  36001. pitchAxis?: Vector3;
  36002. adjustYaw?: number;
  36003. adjustPitch?: number;
  36004. adjustRoll?: number;
  36005. });
  36006. /**
  36007. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36008. */
  36009. update(): void;
  36010. private _getAngleDiff;
  36011. private _getAngleBetween;
  36012. private _isAngleBetween;
  36013. }
  36014. }
  36015. declare module BABYLON {
  36016. /**
  36017. * Manage the gamepad inputs to control an arc rotate camera.
  36018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36019. */
  36020. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36021. /**
  36022. * Defines the camera the input is attached to.
  36023. */
  36024. camera: ArcRotateCamera;
  36025. /**
  36026. * Defines the gamepad the input is gathering event from.
  36027. */
  36028. gamepad: Nullable<Gamepad>;
  36029. /**
  36030. * Defines the gamepad rotation sensiblity.
  36031. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36032. */
  36033. gamepadRotationSensibility: number;
  36034. /**
  36035. * Defines the gamepad move sensiblity.
  36036. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36037. */
  36038. gamepadMoveSensibility: number;
  36039. private _onGamepadConnectedObserver;
  36040. private _onGamepadDisconnectedObserver;
  36041. /**
  36042. * Attach the input controls to a specific dom element to get the input from.
  36043. * @param element Defines the element the controls should be listened from
  36044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36045. */
  36046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36047. /**
  36048. * Detach the current controls from the specified dom element.
  36049. * @param element Defines the element to stop listening the inputs from
  36050. */
  36051. detachControl(element: Nullable<HTMLElement>): void;
  36052. /**
  36053. * Update the current camera state depending on the inputs that have been used this frame.
  36054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36055. */
  36056. checkInputs(): void;
  36057. /**
  36058. * Gets the class name of the current intput.
  36059. * @returns the class name
  36060. */
  36061. getClassName(): string;
  36062. /**
  36063. * Get the friendly name associated with the input class.
  36064. * @returns the input friendly name
  36065. */
  36066. getSimpleName(): string;
  36067. }
  36068. }
  36069. declare module BABYLON {
  36070. interface ArcRotateCameraInputsManager {
  36071. /**
  36072. * Add orientation input support to the input manager.
  36073. * @returns the current input manager
  36074. */
  36075. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36076. }
  36077. /**
  36078. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36080. */
  36081. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36082. /**
  36083. * Defines the camera the input is attached to.
  36084. */
  36085. camera: ArcRotateCamera;
  36086. /**
  36087. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36088. */
  36089. alphaCorrection: number;
  36090. /**
  36091. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36092. */
  36093. gammaCorrection: number;
  36094. private _alpha;
  36095. private _gamma;
  36096. private _dirty;
  36097. private _deviceOrientationHandler;
  36098. /**
  36099. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36100. */
  36101. constructor();
  36102. /**
  36103. * Attach the input controls to a specific dom element to get the input from.
  36104. * @param element Defines the element the controls should be listened from
  36105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36106. */
  36107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36108. /** @hidden */
  36109. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36110. /**
  36111. * Update the current camera state depending on the inputs that have been used this frame.
  36112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36113. */
  36114. checkInputs(): void;
  36115. /**
  36116. * Detach the current controls from the specified dom element.
  36117. * @param element Defines the element to stop listening the inputs from
  36118. */
  36119. detachControl(element: Nullable<HTMLElement>): void;
  36120. /**
  36121. * Gets the class name of the current intput.
  36122. * @returns the class name
  36123. */
  36124. getClassName(): string;
  36125. /**
  36126. * Get the friendly name associated with the input class.
  36127. * @returns the input friendly name
  36128. */
  36129. getSimpleName(): string;
  36130. }
  36131. }
  36132. declare module BABYLON {
  36133. /**
  36134. * Listen to mouse events to control the camera.
  36135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36136. */
  36137. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36138. /**
  36139. * Defines the camera the input is attached to.
  36140. */
  36141. camera: FlyCamera;
  36142. /**
  36143. * Defines if touch is enabled. (Default is true.)
  36144. */
  36145. touchEnabled: boolean;
  36146. /**
  36147. * Defines the buttons associated with the input to handle camera rotation.
  36148. */
  36149. buttons: number[];
  36150. /**
  36151. * Assign buttons for Yaw control.
  36152. */
  36153. buttonsYaw: number[];
  36154. /**
  36155. * Assign buttons for Pitch control.
  36156. */
  36157. buttonsPitch: number[];
  36158. /**
  36159. * Assign buttons for Roll control.
  36160. */
  36161. buttonsRoll: number[];
  36162. /**
  36163. * Detect if any button is being pressed while mouse is moved.
  36164. * -1 = Mouse locked.
  36165. * 0 = Left button.
  36166. * 1 = Middle Button.
  36167. * 2 = Right Button.
  36168. */
  36169. activeButton: number;
  36170. /**
  36171. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36172. * Higher values reduce its sensitivity.
  36173. */
  36174. angularSensibility: number;
  36175. private _mousemoveCallback;
  36176. private _observer;
  36177. private _rollObserver;
  36178. private previousPosition;
  36179. private noPreventDefault;
  36180. private element;
  36181. /**
  36182. * Listen to mouse events to control the camera.
  36183. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36185. */
  36186. constructor(touchEnabled?: boolean);
  36187. /**
  36188. * Attach the mouse control to the HTML DOM element.
  36189. * @param element Defines the element that listens to the input events.
  36190. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36191. */
  36192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36193. /**
  36194. * Detach the current controls from the specified dom element.
  36195. * @param element Defines the element to stop listening the inputs from
  36196. */
  36197. detachControl(element: Nullable<HTMLElement>): void;
  36198. /**
  36199. * Gets the class name of the current input.
  36200. * @returns the class name.
  36201. */
  36202. getClassName(): string;
  36203. /**
  36204. * Get the friendly name associated with the input class.
  36205. * @returns the input's friendly name.
  36206. */
  36207. getSimpleName(): string;
  36208. private _pointerInput;
  36209. private _onMouseMove;
  36210. /**
  36211. * Rotate camera by mouse offset.
  36212. */
  36213. private rotateCamera;
  36214. }
  36215. }
  36216. declare module BABYLON {
  36217. /**
  36218. * Default Inputs manager for the FlyCamera.
  36219. * It groups all the default supported inputs for ease of use.
  36220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36221. */
  36222. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36223. /**
  36224. * Instantiates a new FlyCameraInputsManager.
  36225. * @param camera Defines the camera the inputs belong to.
  36226. */
  36227. constructor(camera: FlyCamera);
  36228. /**
  36229. * Add keyboard input support to the input manager.
  36230. * @returns the new FlyCameraKeyboardMoveInput().
  36231. */
  36232. addKeyboard(): FlyCameraInputsManager;
  36233. /**
  36234. * Add mouse input support to the input manager.
  36235. * @param touchEnabled Enable touch screen support.
  36236. * @returns the new FlyCameraMouseInput().
  36237. */
  36238. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36239. }
  36240. }
  36241. declare module BABYLON {
  36242. /**
  36243. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36244. * such as in a 3D Space Shooter or a Flight Simulator.
  36245. */
  36246. export class FlyCamera extends TargetCamera {
  36247. /**
  36248. * Define the collision ellipsoid of the camera.
  36249. * This is helpful for simulating a camera body, like a player's body.
  36250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36251. */
  36252. ellipsoid: Vector3;
  36253. /**
  36254. * Define an offset for the position of the ellipsoid around the camera.
  36255. * This can be helpful if the camera is attached away from the player's body center,
  36256. * such as at its head.
  36257. */
  36258. ellipsoidOffset: Vector3;
  36259. /**
  36260. * Enable or disable collisions of the camera with the rest of the scene objects.
  36261. */
  36262. checkCollisions: boolean;
  36263. /**
  36264. * Enable or disable gravity on the camera.
  36265. */
  36266. applyGravity: boolean;
  36267. /**
  36268. * Define the current direction the camera is moving to.
  36269. */
  36270. cameraDirection: Vector3;
  36271. /**
  36272. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36273. * This overrides and empties cameraRotation.
  36274. */
  36275. rotationQuaternion: Quaternion;
  36276. /**
  36277. * Track Roll to maintain the wanted Rolling when looking around.
  36278. */
  36279. _trackRoll: number;
  36280. /**
  36281. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36282. */
  36283. rollCorrect: number;
  36284. /**
  36285. * Mimic a banked turn, Rolling the camera when Yawing.
  36286. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36287. */
  36288. bankedTurn: boolean;
  36289. /**
  36290. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36291. */
  36292. bankedTurnLimit: number;
  36293. /**
  36294. * Value of 0 disables the banked Roll.
  36295. * Value of 1 is equal to the Yaw angle in radians.
  36296. */
  36297. bankedTurnMultiplier: number;
  36298. /**
  36299. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36300. */
  36301. inputs: FlyCameraInputsManager;
  36302. /**
  36303. * Gets the input sensibility for mouse input.
  36304. * Higher values reduce sensitivity.
  36305. */
  36306. /**
  36307. * Sets the input sensibility for a mouse input.
  36308. * Higher values reduce sensitivity.
  36309. */
  36310. angularSensibility: number;
  36311. /**
  36312. * Get the keys for camera movement forward.
  36313. */
  36314. /**
  36315. * Set the keys for camera movement forward.
  36316. */
  36317. keysForward: number[];
  36318. /**
  36319. * Get the keys for camera movement backward.
  36320. */
  36321. keysBackward: number[];
  36322. /**
  36323. * Get the keys for camera movement up.
  36324. */
  36325. /**
  36326. * Set the keys for camera movement up.
  36327. */
  36328. keysUp: number[];
  36329. /**
  36330. * Get the keys for camera movement down.
  36331. */
  36332. /**
  36333. * Set the keys for camera movement down.
  36334. */
  36335. keysDown: number[];
  36336. /**
  36337. * Get the keys for camera movement left.
  36338. */
  36339. /**
  36340. * Set the keys for camera movement left.
  36341. */
  36342. keysLeft: number[];
  36343. /**
  36344. * Set the keys for camera movement right.
  36345. */
  36346. /**
  36347. * Set the keys for camera movement right.
  36348. */
  36349. keysRight: number[];
  36350. /**
  36351. * Event raised when the camera collides with a mesh in the scene.
  36352. */
  36353. onCollide: (collidedMesh: AbstractMesh) => void;
  36354. private _collider;
  36355. private _needMoveForGravity;
  36356. private _oldPosition;
  36357. private _diffPosition;
  36358. private _newPosition;
  36359. /** @hidden */
  36360. _localDirection: Vector3;
  36361. /** @hidden */
  36362. _transformedDirection: Vector3;
  36363. /**
  36364. * Instantiates a FlyCamera.
  36365. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36366. * such as in a 3D Space Shooter or a Flight Simulator.
  36367. * @param name Define the name of the camera in the scene.
  36368. * @param position Define the starting position of the camera in the scene.
  36369. * @param scene Define the scene the camera belongs to.
  36370. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36371. */
  36372. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36373. /**
  36374. * Attach a control to the HTML DOM element.
  36375. * @param element Defines the element that listens to the input events.
  36376. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36377. */
  36378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36379. /**
  36380. * Detach a control from the HTML DOM element.
  36381. * The camera will stop reacting to that input.
  36382. * @param element Defines the element that listens to the input events.
  36383. */
  36384. detachControl(element: HTMLElement): void;
  36385. private _collisionMask;
  36386. /**
  36387. * Get the mask that the camera ignores in collision events.
  36388. */
  36389. /**
  36390. * Set the mask that the camera ignores in collision events.
  36391. */
  36392. collisionMask: number;
  36393. /** @hidden */
  36394. _collideWithWorld(displacement: Vector3): void;
  36395. /** @hidden */
  36396. private _onCollisionPositionChange;
  36397. /** @hidden */
  36398. _checkInputs(): void;
  36399. /** @hidden */
  36400. _decideIfNeedsToMove(): boolean;
  36401. /** @hidden */
  36402. _updatePosition(): void;
  36403. /**
  36404. * Restore the Roll to its target value at the rate specified.
  36405. * @param rate - Higher means slower restoring.
  36406. * @hidden
  36407. */
  36408. restoreRoll(rate: number): void;
  36409. /**
  36410. * Destroy the camera and release the current resources held by it.
  36411. */
  36412. dispose(): void;
  36413. /**
  36414. * Get the current object class name.
  36415. * @returns the class name.
  36416. */
  36417. getClassName(): string;
  36418. }
  36419. }
  36420. declare module BABYLON {
  36421. /**
  36422. * Listen to keyboard events to control the camera.
  36423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36424. */
  36425. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36426. /**
  36427. * Defines the camera the input is attached to.
  36428. */
  36429. camera: FlyCamera;
  36430. /**
  36431. * The list of keyboard keys used to control the forward move of the camera.
  36432. */
  36433. keysForward: number[];
  36434. /**
  36435. * The list of keyboard keys used to control the backward move of the camera.
  36436. */
  36437. keysBackward: number[];
  36438. /**
  36439. * The list of keyboard keys used to control the forward move of the camera.
  36440. */
  36441. keysUp: number[];
  36442. /**
  36443. * The list of keyboard keys used to control the backward move of the camera.
  36444. */
  36445. keysDown: number[];
  36446. /**
  36447. * The list of keyboard keys used to control the right strafe move of the camera.
  36448. */
  36449. keysRight: number[];
  36450. /**
  36451. * The list of keyboard keys used to control the left strafe move of the camera.
  36452. */
  36453. keysLeft: number[];
  36454. private _keys;
  36455. private _onCanvasBlurObserver;
  36456. private _onKeyboardObserver;
  36457. private _engine;
  36458. private _scene;
  36459. /**
  36460. * Attach the input controls to a specific dom element to get the input from.
  36461. * @param element Defines the element the controls should be listened from
  36462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36463. */
  36464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36465. /**
  36466. * Detach the current controls from the specified dom element.
  36467. * @param element Defines the element to stop listening the inputs from
  36468. */
  36469. detachControl(element: Nullable<HTMLElement>): void;
  36470. /**
  36471. * Gets the class name of the current intput.
  36472. * @returns the class name
  36473. */
  36474. getClassName(): string;
  36475. /** @hidden */
  36476. _onLostFocus(e: FocusEvent): void;
  36477. /**
  36478. * Get the friendly name associated with the input class.
  36479. * @returns the input friendly name
  36480. */
  36481. getSimpleName(): string;
  36482. /**
  36483. * Update the current camera state depending on the inputs that have been used this frame.
  36484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36485. */
  36486. checkInputs(): void;
  36487. }
  36488. }
  36489. declare module BABYLON {
  36490. /**
  36491. * Manage the mouse wheel inputs to control a follow camera.
  36492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36493. */
  36494. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36495. /**
  36496. * Defines the camera the input is attached to.
  36497. */
  36498. camera: FollowCamera;
  36499. /**
  36500. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36501. */
  36502. axisControlRadius: boolean;
  36503. /**
  36504. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36505. */
  36506. axisControlHeight: boolean;
  36507. /**
  36508. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36509. */
  36510. axisControlRotation: boolean;
  36511. /**
  36512. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36513. * relation to mouseWheel events.
  36514. */
  36515. wheelPrecision: number;
  36516. /**
  36517. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36518. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36519. */
  36520. wheelDeltaPercentage: number;
  36521. private _wheel;
  36522. private _observer;
  36523. /**
  36524. * Attach the input controls to a specific dom element to get the input from.
  36525. * @param element Defines the element the controls should be listened from
  36526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36527. */
  36528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36529. /**
  36530. * Detach the current controls from the specified dom element.
  36531. * @param element Defines the element to stop listening the inputs from
  36532. */
  36533. detachControl(element: Nullable<HTMLElement>): void;
  36534. /**
  36535. * Gets the class name of the current intput.
  36536. * @returns the class name
  36537. */
  36538. getClassName(): string;
  36539. /**
  36540. * Get the friendly name associated with the input class.
  36541. * @returns the input friendly name
  36542. */
  36543. getSimpleName(): string;
  36544. }
  36545. }
  36546. declare module BABYLON {
  36547. /**
  36548. * Manage the pointers inputs to control an follow camera.
  36549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36550. */
  36551. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36552. /**
  36553. * Defines the camera the input is attached to.
  36554. */
  36555. camera: FollowCamera;
  36556. /**
  36557. * Gets the class name of the current input.
  36558. * @returns the class name
  36559. */
  36560. getClassName(): string;
  36561. /**
  36562. * Defines the pointer angular sensibility along the X axis or how fast is
  36563. * the camera rotating.
  36564. * A negative number will reverse the axis direction.
  36565. */
  36566. angularSensibilityX: number;
  36567. /**
  36568. * Defines the pointer angular sensibility along the Y axis or how fast is
  36569. * the camera rotating.
  36570. * A negative number will reverse the axis direction.
  36571. */
  36572. angularSensibilityY: number;
  36573. /**
  36574. * Defines the pointer pinch precision or how fast is the camera zooming.
  36575. * A negative number will reverse the axis direction.
  36576. */
  36577. pinchPrecision: number;
  36578. /**
  36579. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36580. * from 0.
  36581. * It defines the percentage of current camera.radius to use as delta when
  36582. * pinch zoom is used.
  36583. */
  36584. pinchDeltaPercentage: number;
  36585. /**
  36586. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36587. */
  36588. axisXControlRadius: boolean;
  36589. /**
  36590. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36591. */
  36592. axisXControlHeight: boolean;
  36593. /**
  36594. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36595. */
  36596. axisXControlRotation: boolean;
  36597. /**
  36598. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36599. */
  36600. axisYControlRadius: boolean;
  36601. /**
  36602. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36603. */
  36604. axisYControlHeight: boolean;
  36605. /**
  36606. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36607. */
  36608. axisYControlRotation: boolean;
  36609. /**
  36610. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36611. */
  36612. axisPinchControlRadius: boolean;
  36613. /**
  36614. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36615. */
  36616. axisPinchControlHeight: boolean;
  36617. /**
  36618. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36619. */
  36620. axisPinchControlRotation: boolean;
  36621. /**
  36622. * Log error messages if basic misconfiguration has occurred.
  36623. */
  36624. warningEnable: boolean;
  36625. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36626. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36627. private _warningCounter;
  36628. private _warning;
  36629. }
  36630. }
  36631. declare module BABYLON {
  36632. /**
  36633. * Default Inputs manager for the FollowCamera.
  36634. * It groups all the default supported inputs for ease of use.
  36635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36636. */
  36637. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36638. /**
  36639. * Instantiates a new FollowCameraInputsManager.
  36640. * @param camera Defines the camera the inputs belong to
  36641. */
  36642. constructor(camera: FollowCamera);
  36643. /**
  36644. * Add keyboard input support to the input manager.
  36645. * @returns the current input manager
  36646. */
  36647. addKeyboard(): FollowCameraInputsManager;
  36648. /**
  36649. * Add mouse wheel input support to the input manager.
  36650. * @returns the current input manager
  36651. */
  36652. addMouseWheel(): FollowCameraInputsManager;
  36653. /**
  36654. * Add pointers input support to the input manager.
  36655. * @returns the current input manager
  36656. */
  36657. addPointers(): FollowCameraInputsManager;
  36658. /**
  36659. * Add orientation input support to the input manager.
  36660. * @returns the current input manager
  36661. */
  36662. addVRDeviceOrientation(): FollowCameraInputsManager;
  36663. }
  36664. }
  36665. declare module BABYLON {
  36666. /**
  36667. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36668. * an arc rotate version arcFollowCamera are available.
  36669. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36670. */
  36671. export class FollowCamera extends TargetCamera {
  36672. /**
  36673. * Distance the follow camera should follow an object at
  36674. */
  36675. radius: number;
  36676. /**
  36677. * Minimum allowed distance of the camera to the axis of rotation
  36678. * (The camera can not get closer).
  36679. * This can help limiting how the Camera is able to move in the scene.
  36680. */
  36681. lowerRadiusLimit: Nullable<number>;
  36682. /**
  36683. * Maximum allowed distance of the camera to the axis of rotation
  36684. * (The camera can not get further).
  36685. * This can help limiting how the Camera is able to move in the scene.
  36686. */
  36687. upperRadiusLimit: Nullable<number>;
  36688. /**
  36689. * Define a rotation offset between the camera and the object it follows
  36690. */
  36691. rotationOffset: number;
  36692. /**
  36693. * Minimum allowed angle to camera position relative to target object.
  36694. * This can help limiting how the Camera is able to move in the scene.
  36695. */
  36696. lowerRotationOffsetLimit: Nullable<number>;
  36697. /**
  36698. * Maximum allowed angle to camera position relative to target object.
  36699. * This can help limiting how the Camera is able to move in the scene.
  36700. */
  36701. upperRotationOffsetLimit: Nullable<number>;
  36702. /**
  36703. * Define a height offset between the camera and the object it follows.
  36704. * It can help following an object from the top (like a car chaing a plane)
  36705. */
  36706. heightOffset: number;
  36707. /**
  36708. * Minimum allowed height of camera position relative to target object.
  36709. * This can help limiting how the Camera is able to move in the scene.
  36710. */
  36711. lowerHeightOffsetLimit: Nullable<number>;
  36712. /**
  36713. * Maximum allowed height of camera position relative to target object.
  36714. * This can help limiting how the Camera is able to move in the scene.
  36715. */
  36716. upperHeightOffsetLimit: Nullable<number>;
  36717. /**
  36718. * Define how fast the camera can accelerate to follow it s target.
  36719. */
  36720. cameraAcceleration: number;
  36721. /**
  36722. * Define the speed limit of the camera following an object.
  36723. */
  36724. maxCameraSpeed: number;
  36725. /**
  36726. * Define the target of the camera.
  36727. */
  36728. lockedTarget: Nullable<AbstractMesh>;
  36729. /**
  36730. * Defines the input associated with the camera.
  36731. */
  36732. inputs: FollowCameraInputsManager;
  36733. /**
  36734. * Instantiates the follow camera.
  36735. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36736. * @param name Define the name of the camera in the scene
  36737. * @param position Define the position of the camera
  36738. * @param scene Define the scene the camera belong to
  36739. * @param lockedTarget Define the target of the camera
  36740. */
  36741. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36742. private _follow;
  36743. /**
  36744. * Attached controls to the current camera.
  36745. * @param element Defines the element the controls should be listened from
  36746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36747. */
  36748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36749. /**
  36750. * Detach the current controls from the camera.
  36751. * The camera will stop reacting to inputs.
  36752. * @param element Defines the element to stop listening the inputs from
  36753. */
  36754. detachControl(element: HTMLElement): void;
  36755. /** @hidden */
  36756. _checkInputs(): void;
  36757. private _checkLimits;
  36758. /**
  36759. * Gets the camera class name.
  36760. * @returns the class name
  36761. */
  36762. getClassName(): string;
  36763. }
  36764. /**
  36765. * Arc Rotate version of the follow camera.
  36766. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36767. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36768. */
  36769. export class ArcFollowCamera extends TargetCamera {
  36770. /** The longitudinal angle of the camera */
  36771. alpha: number;
  36772. /** The latitudinal angle of the camera */
  36773. beta: number;
  36774. /** The radius of the camera from its target */
  36775. radius: number;
  36776. /** Define the camera target (the messh it should follow) */
  36777. target: Nullable<AbstractMesh>;
  36778. private _cartesianCoordinates;
  36779. /**
  36780. * Instantiates a new ArcFollowCamera
  36781. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36782. * @param name Define the name of the camera
  36783. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36784. * @param beta Define the rotation angle of the camera around the elevation axis
  36785. * @param radius Define the radius of the camera from its target point
  36786. * @param target Define the target of the camera
  36787. * @param scene Define the scene the camera belongs to
  36788. */
  36789. constructor(name: string,
  36790. /** The longitudinal angle of the camera */
  36791. alpha: number,
  36792. /** The latitudinal angle of the camera */
  36793. beta: number,
  36794. /** The radius of the camera from its target */
  36795. radius: number,
  36796. /** Define the camera target (the messh it should follow) */
  36797. target: Nullable<AbstractMesh>, scene: Scene);
  36798. private _follow;
  36799. /** @hidden */
  36800. _checkInputs(): void;
  36801. /**
  36802. * Returns the class name of the object.
  36803. * It is mostly used internally for serialization purposes.
  36804. */
  36805. getClassName(): string;
  36806. }
  36807. }
  36808. declare module BABYLON {
  36809. /**
  36810. * Manage the keyboard inputs to control the movement of a follow camera.
  36811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36812. */
  36813. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36814. /**
  36815. * Defines the camera the input is attached to.
  36816. */
  36817. camera: FollowCamera;
  36818. /**
  36819. * Defines the list of key codes associated with the up action (increase heightOffset)
  36820. */
  36821. keysHeightOffsetIncr: number[];
  36822. /**
  36823. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36824. */
  36825. keysHeightOffsetDecr: number[];
  36826. /**
  36827. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36828. */
  36829. keysHeightOffsetModifierAlt: boolean;
  36830. /**
  36831. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36832. */
  36833. keysHeightOffsetModifierCtrl: boolean;
  36834. /**
  36835. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36836. */
  36837. keysHeightOffsetModifierShift: boolean;
  36838. /**
  36839. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36840. */
  36841. keysRotationOffsetIncr: number[];
  36842. /**
  36843. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36844. */
  36845. keysRotationOffsetDecr: number[];
  36846. /**
  36847. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36848. */
  36849. keysRotationOffsetModifierAlt: boolean;
  36850. /**
  36851. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36852. */
  36853. keysRotationOffsetModifierCtrl: boolean;
  36854. /**
  36855. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36856. */
  36857. keysRotationOffsetModifierShift: boolean;
  36858. /**
  36859. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36860. */
  36861. keysRadiusIncr: number[];
  36862. /**
  36863. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36864. */
  36865. keysRadiusDecr: number[];
  36866. /**
  36867. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36868. */
  36869. keysRadiusModifierAlt: boolean;
  36870. /**
  36871. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36872. */
  36873. keysRadiusModifierCtrl: boolean;
  36874. /**
  36875. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36876. */
  36877. keysRadiusModifierShift: boolean;
  36878. /**
  36879. * Defines the rate of change of heightOffset.
  36880. */
  36881. heightSensibility: number;
  36882. /**
  36883. * Defines the rate of change of rotationOffset.
  36884. */
  36885. rotationSensibility: number;
  36886. /**
  36887. * Defines the rate of change of radius.
  36888. */
  36889. radiusSensibility: number;
  36890. private _keys;
  36891. private _ctrlPressed;
  36892. private _altPressed;
  36893. private _shiftPressed;
  36894. private _onCanvasBlurObserver;
  36895. private _onKeyboardObserver;
  36896. private _engine;
  36897. private _scene;
  36898. /**
  36899. * Attach the input controls to a specific dom element to get the input from.
  36900. * @param element Defines the element the controls should be listened from
  36901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36902. */
  36903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36904. /**
  36905. * Detach the current controls from the specified dom element.
  36906. * @param element Defines the element to stop listening the inputs from
  36907. */
  36908. detachControl(element: Nullable<HTMLElement>): void;
  36909. /**
  36910. * Update the current camera state depending on the inputs that have been used this frame.
  36911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36912. */
  36913. checkInputs(): void;
  36914. /**
  36915. * Gets the class name of the current input.
  36916. * @returns the class name
  36917. */
  36918. getClassName(): string;
  36919. /**
  36920. * Get the friendly name associated with the input class.
  36921. * @returns the input friendly name
  36922. */
  36923. getSimpleName(): string;
  36924. /**
  36925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36926. * allow modification of the heightOffset value.
  36927. */
  36928. private _modifierHeightOffset;
  36929. /**
  36930. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36931. * allow modification of the rotationOffset value.
  36932. */
  36933. private _modifierRotationOffset;
  36934. /**
  36935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36936. * allow modification of the radius value.
  36937. */
  36938. private _modifierRadius;
  36939. }
  36940. }
  36941. declare module BABYLON {
  36942. interface FreeCameraInputsManager {
  36943. /**
  36944. * @hidden
  36945. */
  36946. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36947. /**
  36948. * Add orientation input support to the input manager.
  36949. * @returns the current input manager
  36950. */
  36951. addDeviceOrientation(): FreeCameraInputsManager;
  36952. }
  36953. /**
  36954. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36955. * Screen rotation is taken into account.
  36956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36957. */
  36958. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36959. private _camera;
  36960. private _screenOrientationAngle;
  36961. private _constantTranform;
  36962. private _screenQuaternion;
  36963. private _alpha;
  36964. private _beta;
  36965. private _gamma;
  36966. /**
  36967. * @hidden
  36968. */
  36969. _onDeviceOrientationChangedObservable: Observable<void>;
  36970. /**
  36971. * Instantiates a new input
  36972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36973. */
  36974. constructor();
  36975. /**
  36976. * Define the camera controlled by the input.
  36977. */
  36978. camera: FreeCamera;
  36979. /**
  36980. * Attach the input controls to a specific dom element to get the input from.
  36981. * @param element Defines the element the controls should be listened from
  36982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36983. */
  36984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36985. private _orientationChanged;
  36986. private _deviceOrientation;
  36987. /**
  36988. * Detach the current controls from the specified dom element.
  36989. * @param element Defines the element to stop listening the inputs from
  36990. */
  36991. detachControl(element: Nullable<HTMLElement>): void;
  36992. /**
  36993. * Update the current camera state depending on the inputs that have been used this frame.
  36994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36995. */
  36996. checkInputs(): void;
  36997. /**
  36998. * Gets the class name of the current intput.
  36999. * @returns the class name
  37000. */
  37001. getClassName(): string;
  37002. /**
  37003. * Get the friendly name associated with the input class.
  37004. * @returns the input friendly name
  37005. */
  37006. getSimpleName(): string;
  37007. }
  37008. }
  37009. declare module BABYLON {
  37010. /**
  37011. * Manage the gamepad inputs to control a free camera.
  37012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37013. */
  37014. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37015. /**
  37016. * Define the camera the input is attached to.
  37017. */
  37018. camera: FreeCamera;
  37019. /**
  37020. * Define the Gamepad controlling the input
  37021. */
  37022. gamepad: Nullable<Gamepad>;
  37023. /**
  37024. * Defines the gamepad rotation sensiblity.
  37025. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37026. */
  37027. gamepadAngularSensibility: number;
  37028. /**
  37029. * Defines the gamepad move sensiblity.
  37030. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37031. */
  37032. gamepadMoveSensibility: number;
  37033. private _onGamepadConnectedObserver;
  37034. private _onGamepadDisconnectedObserver;
  37035. private _cameraTransform;
  37036. private _deltaTransform;
  37037. private _vector3;
  37038. private _vector2;
  37039. /**
  37040. * Attach the input controls to a specific dom element to get the input from.
  37041. * @param element Defines the element the controls should be listened from
  37042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37043. */
  37044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37045. /**
  37046. * Detach the current controls from the specified dom element.
  37047. * @param element Defines the element to stop listening the inputs from
  37048. */
  37049. detachControl(element: Nullable<HTMLElement>): void;
  37050. /**
  37051. * Update the current camera state depending on the inputs that have been used this frame.
  37052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37053. */
  37054. checkInputs(): void;
  37055. /**
  37056. * Gets the class name of the current intput.
  37057. * @returns the class name
  37058. */
  37059. getClassName(): string;
  37060. /**
  37061. * Get the friendly name associated with the input class.
  37062. * @returns the input friendly name
  37063. */
  37064. getSimpleName(): string;
  37065. }
  37066. }
  37067. declare module BABYLON {
  37068. /**
  37069. * Defines the potential axis of a Joystick
  37070. */
  37071. export enum JoystickAxis {
  37072. /** X axis */
  37073. X = 0,
  37074. /** Y axis */
  37075. Y = 1,
  37076. /** Z axis */
  37077. Z = 2
  37078. }
  37079. /**
  37080. * Class used to define virtual joystick (used in touch mode)
  37081. */
  37082. export class VirtualJoystick {
  37083. /**
  37084. * Gets or sets a boolean indicating that left and right values must be inverted
  37085. */
  37086. reverseLeftRight: boolean;
  37087. /**
  37088. * Gets or sets a boolean indicating that up and down values must be inverted
  37089. */
  37090. reverseUpDown: boolean;
  37091. /**
  37092. * Gets the offset value for the position (ie. the change of the position value)
  37093. */
  37094. deltaPosition: Vector3;
  37095. /**
  37096. * Gets a boolean indicating if the virtual joystick was pressed
  37097. */
  37098. pressed: boolean;
  37099. /**
  37100. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37101. */
  37102. static Canvas: Nullable<HTMLCanvasElement>;
  37103. private static _globalJoystickIndex;
  37104. private static vjCanvasContext;
  37105. private static vjCanvasWidth;
  37106. private static vjCanvasHeight;
  37107. private static halfWidth;
  37108. private _action;
  37109. private _axisTargetedByLeftAndRight;
  37110. private _axisTargetedByUpAndDown;
  37111. private _joystickSensibility;
  37112. private _inversedSensibility;
  37113. private _joystickPointerID;
  37114. private _joystickColor;
  37115. private _joystickPointerPos;
  37116. private _joystickPreviousPointerPos;
  37117. private _joystickPointerStartPos;
  37118. private _deltaJoystickVector;
  37119. private _leftJoystick;
  37120. private _touches;
  37121. private _onPointerDownHandlerRef;
  37122. private _onPointerMoveHandlerRef;
  37123. private _onPointerUpHandlerRef;
  37124. private _onResize;
  37125. /**
  37126. * Creates a new virtual joystick
  37127. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37128. */
  37129. constructor(leftJoystick?: boolean);
  37130. /**
  37131. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37132. * @param newJoystickSensibility defines the new sensibility
  37133. */
  37134. setJoystickSensibility(newJoystickSensibility: number): void;
  37135. private _onPointerDown;
  37136. private _onPointerMove;
  37137. private _onPointerUp;
  37138. /**
  37139. * Change the color of the virtual joystick
  37140. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37141. */
  37142. setJoystickColor(newColor: string): void;
  37143. /**
  37144. * Defines a callback to call when the joystick is touched
  37145. * @param action defines the callback
  37146. */
  37147. setActionOnTouch(action: () => any): void;
  37148. /**
  37149. * Defines which axis you'd like to control for left & right
  37150. * @param axis defines the axis to use
  37151. */
  37152. setAxisForLeftRight(axis: JoystickAxis): void;
  37153. /**
  37154. * Defines which axis you'd like to control for up & down
  37155. * @param axis defines the axis to use
  37156. */
  37157. setAxisForUpDown(axis: JoystickAxis): void;
  37158. private _drawVirtualJoystick;
  37159. /**
  37160. * Release internal HTML canvas
  37161. */
  37162. releaseCanvas(): void;
  37163. }
  37164. }
  37165. declare module BABYLON {
  37166. interface FreeCameraInputsManager {
  37167. /**
  37168. * Add virtual joystick input support to the input manager.
  37169. * @returns the current input manager
  37170. */
  37171. addVirtualJoystick(): FreeCameraInputsManager;
  37172. }
  37173. /**
  37174. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37176. */
  37177. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37178. /**
  37179. * Defines the camera the input is attached to.
  37180. */
  37181. camera: FreeCamera;
  37182. private _leftjoystick;
  37183. private _rightjoystick;
  37184. /**
  37185. * Gets the left stick of the virtual joystick.
  37186. * @returns The virtual Joystick
  37187. */
  37188. getLeftJoystick(): VirtualJoystick;
  37189. /**
  37190. * Gets the right stick of the virtual joystick.
  37191. * @returns The virtual Joystick
  37192. */
  37193. getRightJoystick(): VirtualJoystick;
  37194. /**
  37195. * Update the current camera state depending on the inputs that have been used this frame.
  37196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37197. */
  37198. checkInputs(): void;
  37199. /**
  37200. * Attach the input controls to a specific dom element to get the input from.
  37201. * @param element Defines the element the controls should be listened from
  37202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37203. */
  37204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37205. /**
  37206. * Detach the current controls from the specified dom element.
  37207. * @param element Defines the element to stop listening the inputs from
  37208. */
  37209. detachControl(element: Nullable<HTMLElement>): void;
  37210. /**
  37211. * Gets the class name of the current intput.
  37212. * @returns the class name
  37213. */
  37214. getClassName(): string;
  37215. /**
  37216. * Get the friendly name associated with the input class.
  37217. * @returns the input friendly name
  37218. */
  37219. getSimpleName(): string;
  37220. }
  37221. }
  37222. declare module BABYLON {
  37223. /**
  37224. * This represents a FPS type of camera controlled by touch.
  37225. * This is like a universal camera minus the Gamepad controls.
  37226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37227. */
  37228. export class TouchCamera extends FreeCamera {
  37229. /**
  37230. * Defines the touch sensibility for rotation.
  37231. * The higher the faster.
  37232. */
  37233. touchAngularSensibility: number;
  37234. /**
  37235. * Defines the touch sensibility for move.
  37236. * The higher the faster.
  37237. */
  37238. touchMoveSensibility: number;
  37239. /**
  37240. * Instantiates a new touch camera.
  37241. * This represents a FPS type of camera controlled by touch.
  37242. * This is like a universal camera minus the Gamepad controls.
  37243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37244. * @param name Define the name of the camera in the scene
  37245. * @param position Define the start position of the camera in the scene
  37246. * @param scene Define the scene the camera belongs to
  37247. */
  37248. constructor(name: string, position: Vector3, scene: Scene);
  37249. /**
  37250. * Gets the current object class name.
  37251. * @return the class name
  37252. */
  37253. getClassName(): string;
  37254. /** @hidden */
  37255. _setupInputs(): void;
  37256. }
  37257. }
  37258. declare module BABYLON {
  37259. /**
  37260. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37261. * being tilted forward or back and left or right.
  37262. */
  37263. export class DeviceOrientationCamera extends FreeCamera {
  37264. private _initialQuaternion;
  37265. private _quaternionCache;
  37266. private _tmpDragQuaternion;
  37267. /**
  37268. * Creates a new device orientation camera
  37269. * @param name The name of the camera
  37270. * @param position The start position camera
  37271. * @param scene The scene the camera belongs to
  37272. */
  37273. constructor(name: string, position: Vector3, scene: Scene);
  37274. /**
  37275. * @hidden
  37276. * Disabled pointer input on first orientation sensor update (Default: true)
  37277. */
  37278. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37279. private _dragFactor;
  37280. /**
  37281. * Enabled turning on the y axis when the orientation sensor is active
  37282. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37283. */
  37284. enableHorizontalDragging(dragFactor?: number): void;
  37285. /**
  37286. * Gets the current instance class name ("DeviceOrientationCamera").
  37287. * This helps avoiding instanceof at run time.
  37288. * @returns the class name
  37289. */
  37290. getClassName(): string;
  37291. /**
  37292. * @hidden
  37293. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37294. */
  37295. _checkInputs(): void;
  37296. /**
  37297. * Reset the camera to its default orientation on the specified axis only.
  37298. * @param axis The axis to reset
  37299. */
  37300. resetToCurrentRotation(axis?: Axis): void;
  37301. }
  37302. }
  37303. declare module BABYLON {
  37304. /**
  37305. * 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,
  37306. * which still works and will still be found in many Playgrounds.
  37307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37308. */
  37309. export class UniversalCamera extends TouchCamera {
  37310. /**
  37311. * Defines the gamepad rotation sensiblity.
  37312. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37313. */
  37314. gamepadAngularSensibility: number;
  37315. /**
  37316. * Defines the gamepad move sensiblity.
  37317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37318. */
  37319. gamepadMoveSensibility: number;
  37320. /**
  37321. * 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,
  37322. * which still works and will still be found in many Playgrounds.
  37323. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37324. * @param name Define the name of the camera in the scene
  37325. * @param position Define the start position of the camera in the scene
  37326. * @param scene Define the scene the camera belongs to
  37327. */
  37328. constructor(name: string, position: Vector3, scene: Scene);
  37329. /**
  37330. * Gets the current object class name.
  37331. * @return the class name
  37332. */
  37333. getClassName(): string;
  37334. }
  37335. }
  37336. declare module BABYLON {
  37337. /**
  37338. * This represents a FPS type of camera. This is only here for back compat purpose.
  37339. * Please use the UniversalCamera instead as both are identical.
  37340. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37341. */
  37342. export class GamepadCamera extends UniversalCamera {
  37343. /**
  37344. * Instantiates a new Gamepad Camera
  37345. * This represents a FPS type of camera. This is only here for back compat purpose.
  37346. * Please use the UniversalCamera instead as both are identical.
  37347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37348. * @param name Define the name of the camera in the scene
  37349. * @param position Define the start position of the camera in the scene
  37350. * @param scene Define the scene the camera belongs to
  37351. */
  37352. constructor(name: string, position: Vector3, scene: Scene);
  37353. /**
  37354. * Gets the current object class name.
  37355. * @return the class name
  37356. */
  37357. getClassName(): string;
  37358. }
  37359. }
  37360. declare module BABYLON {
  37361. /** @hidden */
  37362. export var passPixelShader: {
  37363. name: string;
  37364. shader: string;
  37365. };
  37366. }
  37367. declare module BABYLON {
  37368. /** @hidden */
  37369. export var passCubePixelShader: {
  37370. name: string;
  37371. shader: string;
  37372. };
  37373. }
  37374. declare module BABYLON {
  37375. /**
  37376. * PassPostProcess which produces an output the same as it's input
  37377. */
  37378. export class PassPostProcess extends PostProcess {
  37379. /**
  37380. * Creates the PassPostProcess
  37381. * @param name The name of the effect.
  37382. * @param options The required width/height ratio to downsize to before computing the render pass.
  37383. * @param camera The camera to apply the render pass to.
  37384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37385. * @param engine The engine which the post process will be applied. (default: current engine)
  37386. * @param reusable If the post process can be reused on the same frame. (default: false)
  37387. * @param textureType The type of texture to be used when performing the post processing.
  37388. * @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)
  37389. */
  37390. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37391. }
  37392. /**
  37393. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37394. */
  37395. export class PassCubePostProcess extends PostProcess {
  37396. private _face;
  37397. /**
  37398. * Gets or sets the cube face to display.
  37399. * * 0 is +X
  37400. * * 1 is -X
  37401. * * 2 is +Y
  37402. * * 3 is -Y
  37403. * * 4 is +Z
  37404. * * 5 is -Z
  37405. */
  37406. face: number;
  37407. /**
  37408. * Creates the PassCubePostProcess
  37409. * @param name The name of the effect.
  37410. * @param options The required width/height ratio to downsize to before computing the render pass.
  37411. * @param camera The camera to apply the render pass to.
  37412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37413. * @param engine The engine which the post process will be applied. (default: current engine)
  37414. * @param reusable If the post process can be reused on the same frame. (default: false)
  37415. * @param textureType The type of texture to be used when performing the post processing.
  37416. * @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)
  37417. */
  37418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37419. }
  37420. }
  37421. declare module BABYLON {
  37422. /** @hidden */
  37423. export var anaglyphPixelShader: {
  37424. name: string;
  37425. shader: string;
  37426. };
  37427. }
  37428. declare module BABYLON {
  37429. /**
  37430. * Postprocess used to generate anaglyphic rendering
  37431. */
  37432. export class AnaglyphPostProcess extends PostProcess {
  37433. private _passedProcess;
  37434. /**
  37435. * Creates a new AnaglyphPostProcess
  37436. * @param name defines postprocess name
  37437. * @param options defines creation options or target ratio scale
  37438. * @param rigCameras defines cameras using this postprocess
  37439. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37440. * @param engine defines hosting engine
  37441. * @param reusable defines if the postprocess will be reused multiple times per frame
  37442. */
  37443. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37444. }
  37445. }
  37446. declare module BABYLON {
  37447. /**
  37448. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37449. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37450. */
  37451. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37452. /**
  37453. * Creates a new AnaglyphArcRotateCamera
  37454. * @param name defines camera name
  37455. * @param alpha defines alpha angle (in radians)
  37456. * @param beta defines beta angle (in radians)
  37457. * @param radius defines radius
  37458. * @param target defines camera target
  37459. * @param interaxialDistance defines distance between each color axis
  37460. * @param scene defines the hosting scene
  37461. */
  37462. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37463. /**
  37464. * Gets camera class name
  37465. * @returns AnaglyphArcRotateCamera
  37466. */
  37467. getClassName(): string;
  37468. }
  37469. }
  37470. declare module BABYLON {
  37471. /**
  37472. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37473. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37474. */
  37475. export class AnaglyphFreeCamera extends FreeCamera {
  37476. /**
  37477. * Creates a new AnaglyphFreeCamera
  37478. * @param name defines camera name
  37479. * @param position defines initial position
  37480. * @param interaxialDistance defines distance between each color axis
  37481. * @param scene defines the hosting scene
  37482. */
  37483. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37484. /**
  37485. * Gets camera class name
  37486. * @returns AnaglyphFreeCamera
  37487. */
  37488. getClassName(): string;
  37489. }
  37490. }
  37491. declare module BABYLON {
  37492. /**
  37493. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37494. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37495. */
  37496. export class AnaglyphGamepadCamera extends GamepadCamera {
  37497. /**
  37498. * Creates a new AnaglyphGamepadCamera
  37499. * @param name defines camera name
  37500. * @param position defines initial position
  37501. * @param interaxialDistance defines distance between each color axis
  37502. * @param scene defines the hosting scene
  37503. */
  37504. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37505. /**
  37506. * Gets camera class name
  37507. * @returns AnaglyphGamepadCamera
  37508. */
  37509. getClassName(): string;
  37510. }
  37511. }
  37512. declare module BABYLON {
  37513. /**
  37514. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37515. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37516. */
  37517. export class AnaglyphUniversalCamera extends UniversalCamera {
  37518. /**
  37519. * Creates a new AnaglyphUniversalCamera
  37520. * @param name defines camera name
  37521. * @param position defines initial position
  37522. * @param interaxialDistance defines distance between each color axis
  37523. * @param scene defines the hosting scene
  37524. */
  37525. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37526. /**
  37527. * Gets camera class name
  37528. * @returns AnaglyphUniversalCamera
  37529. */
  37530. getClassName(): string;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /** @hidden */
  37535. export var stereoscopicInterlacePixelShader: {
  37536. name: string;
  37537. shader: string;
  37538. };
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37543. */
  37544. export class StereoscopicInterlacePostProcess extends PostProcess {
  37545. private _stepSize;
  37546. private _passedProcess;
  37547. /**
  37548. * Initializes a StereoscopicInterlacePostProcess
  37549. * @param name The name of the effect.
  37550. * @param rigCameras The rig cameras to be appled to the post process
  37551. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37553. * @param engine The engine which the post process will be applied. (default: current engine)
  37554. * @param reusable If the post process can be reused on the same frame. (default: false)
  37555. */
  37556. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37557. }
  37558. }
  37559. declare module BABYLON {
  37560. /**
  37561. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37562. * @see http://doc.babylonjs.com/features/cameras
  37563. */
  37564. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37565. /**
  37566. * Creates a new StereoscopicArcRotateCamera
  37567. * @param name defines camera name
  37568. * @param alpha defines alpha angle (in radians)
  37569. * @param beta defines beta angle (in radians)
  37570. * @param radius defines radius
  37571. * @param target defines camera target
  37572. * @param interaxialDistance defines distance between each color axis
  37573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37574. * @param scene defines the hosting scene
  37575. */
  37576. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37577. /**
  37578. * Gets camera class name
  37579. * @returns StereoscopicArcRotateCamera
  37580. */
  37581. getClassName(): string;
  37582. }
  37583. }
  37584. declare module BABYLON {
  37585. /**
  37586. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37587. * @see http://doc.babylonjs.com/features/cameras
  37588. */
  37589. export class StereoscopicFreeCamera extends FreeCamera {
  37590. /**
  37591. * Creates a new StereoscopicFreeCamera
  37592. * @param name defines camera name
  37593. * @param position defines initial position
  37594. * @param interaxialDistance defines distance between each color axis
  37595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37596. * @param scene defines the hosting scene
  37597. */
  37598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37599. /**
  37600. * Gets camera class name
  37601. * @returns StereoscopicFreeCamera
  37602. */
  37603. getClassName(): string;
  37604. }
  37605. }
  37606. declare module BABYLON {
  37607. /**
  37608. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37609. * @see http://doc.babylonjs.com/features/cameras
  37610. */
  37611. export class StereoscopicGamepadCamera extends GamepadCamera {
  37612. /**
  37613. * Creates a new StereoscopicGamepadCamera
  37614. * @param name defines camera name
  37615. * @param position defines initial position
  37616. * @param interaxialDistance defines distance between each color axis
  37617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37618. * @param scene defines the hosting scene
  37619. */
  37620. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37621. /**
  37622. * Gets camera class name
  37623. * @returns StereoscopicGamepadCamera
  37624. */
  37625. getClassName(): string;
  37626. }
  37627. }
  37628. declare module BABYLON {
  37629. /**
  37630. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37631. * @see http://doc.babylonjs.com/features/cameras
  37632. */
  37633. export class StereoscopicUniversalCamera extends UniversalCamera {
  37634. /**
  37635. * Creates a new StereoscopicUniversalCamera
  37636. * @param name defines camera name
  37637. * @param position defines initial position
  37638. * @param interaxialDistance defines distance between each color axis
  37639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37640. * @param scene defines the hosting scene
  37641. */
  37642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37643. /**
  37644. * Gets camera class name
  37645. * @returns StereoscopicUniversalCamera
  37646. */
  37647. getClassName(): string;
  37648. }
  37649. }
  37650. declare module BABYLON {
  37651. /**
  37652. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37653. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37654. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37655. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37656. */
  37657. export class VirtualJoysticksCamera extends FreeCamera {
  37658. /**
  37659. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37660. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37661. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37662. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37663. * @param name Define the name of the camera in the scene
  37664. * @param position Define the start position of the camera in the scene
  37665. * @param scene Define the scene the camera belongs to
  37666. */
  37667. constructor(name: string, position: Vector3, scene: Scene);
  37668. /**
  37669. * Gets the current object class name.
  37670. * @return the class name
  37671. */
  37672. getClassName(): string;
  37673. }
  37674. }
  37675. declare module BABYLON {
  37676. /**
  37677. * This represents all the required metrics to create a VR camera.
  37678. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37679. */
  37680. export class VRCameraMetrics {
  37681. /**
  37682. * Define the horizontal resolution off the screen.
  37683. */
  37684. hResolution: number;
  37685. /**
  37686. * Define the vertical resolution off the screen.
  37687. */
  37688. vResolution: number;
  37689. /**
  37690. * Define the horizontal screen size.
  37691. */
  37692. hScreenSize: number;
  37693. /**
  37694. * Define the vertical screen size.
  37695. */
  37696. vScreenSize: number;
  37697. /**
  37698. * Define the vertical screen center position.
  37699. */
  37700. vScreenCenter: number;
  37701. /**
  37702. * Define the distance of the eyes to the screen.
  37703. */
  37704. eyeToScreenDistance: number;
  37705. /**
  37706. * Define the distance between both lenses
  37707. */
  37708. lensSeparationDistance: number;
  37709. /**
  37710. * Define the distance between both viewer's eyes.
  37711. */
  37712. interpupillaryDistance: number;
  37713. /**
  37714. * Define the distortion factor of the VR postprocess.
  37715. * Please, touch with care.
  37716. */
  37717. distortionK: number[];
  37718. /**
  37719. * Define the chromatic aberration correction factors for the VR post process.
  37720. */
  37721. chromaAbCorrection: number[];
  37722. /**
  37723. * Define the scale factor of the post process.
  37724. * The smaller the better but the slower.
  37725. */
  37726. postProcessScaleFactor: number;
  37727. /**
  37728. * Define an offset for the lens center.
  37729. */
  37730. lensCenterOffset: number;
  37731. /**
  37732. * Define if the current vr camera should compensate the distortion of the lense or not.
  37733. */
  37734. compensateDistortion: boolean;
  37735. /**
  37736. * Defines if multiview should be enabled when rendering (Default: false)
  37737. */
  37738. multiviewEnabled: boolean;
  37739. /**
  37740. * Gets the rendering aspect ratio based on the provided resolutions.
  37741. */
  37742. readonly aspectRatio: number;
  37743. /**
  37744. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37745. */
  37746. readonly aspectRatioFov: number;
  37747. /**
  37748. * @hidden
  37749. */
  37750. readonly leftHMatrix: Matrix;
  37751. /**
  37752. * @hidden
  37753. */
  37754. readonly rightHMatrix: Matrix;
  37755. /**
  37756. * @hidden
  37757. */
  37758. readonly leftPreViewMatrix: Matrix;
  37759. /**
  37760. * @hidden
  37761. */
  37762. readonly rightPreViewMatrix: Matrix;
  37763. /**
  37764. * Get the default VRMetrics based on the most generic setup.
  37765. * @returns the default vr metrics
  37766. */
  37767. static GetDefault(): VRCameraMetrics;
  37768. }
  37769. }
  37770. declare module BABYLON {
  37771. /** @hidden */
  37772. export var vrDistortionCorrectionPixelShader: {
  37773. name: string;
  37774. shader: string;
  37775. };
  37776. }
  37777. declare module BABYLON {
  37778. /**
  37779. * VRDistortionCorrectionPostProcess used for mobile VR
  37780. */
  37781. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37782. private _isRightEye;
  37783. private _distortionFactors;
  37784. private _postProcessScaleFactor;
  37785. private _lensCenterOffset;
  37786. private _scaleIn;
  37787. private _scaleFactor;
  37788. private _lensCenter;
  37789. /**
  37790. * Initializes the VRDistortionCorrectionPostProcess
  37791. * @param name The name of the effect.
  37792. * @param camera The camera to apply the render pass to.
  37793. * @param isRightEye If this is for the right eye distortion
  37794. * @param vrMetrics All the required metrics for the VR camera
  37795. */
  37796. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37797. }
  37798. }
  37799. declare module BABYLON {
  37800. /**
  37801. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37802. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37803. */
  37804. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37805. /**
  37806. * Creates a new VRDeviceOrientationArcRotateCamera
  37807. * @param name defines camera name
  37808. * @param alpha defines the camera rotation along the logitudinal axis
  37809. * @param beta defines the camera rotation along the latitudinal axis
  37810. * @param radius defines the camera distance from its target
  37811. * @param target defines the camera target
  37812. * @param scene defines the scene the camera belongs to
  37813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37815. */
  37816. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37817. /**
  37818. * Gets camera class name
  37819. * @returns VRDeviceOrientationArcRotateCamera
  37820. */
  37821. getClassName(): string;
  37822. }
  37823. }
  37824. declare module BABYLON {
  37825. /**
  37826. * Camera used to simulate VR rendering (based on FreeCamera)
  37827. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37828. */
  37829. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37830. /**
  37831. * Creates a new VRDeviceOrientationFreeCamera
  37832. * @param name defines camera name
  37833. * @param position defines the start position of the camera
  37834. * @param scene defines the scene the camera belongs to
  37835. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37836. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37837. */
  37838. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37839. /**
  37840. * Gets camera class name
  37841. * @returns VRDeviceOrientationFreeCamera
  37842. */
  37843. getClassName(): string;
  37844. }
  37845. }
  37846. declare module BABYLON {
  37847. /**
  37848. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37849. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37850. */
  37851. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37852. /**
  37853. * Creates a new VRDeviceOrientationGamepadCamera
  37854. * @param name defines camera name
  37855. * @param position defines the start position of the camera
  37856. * @param scene defines the scene the camera belongs to
  37857. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37858. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37859. */
  37860. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37861. /**
  37862. * Gets camera class name
  37863. * @returns VRDeviceOrientationGamepadCamera
  37864. */
  37865. getClassName(): string;
  37866. }
  37867. }
  37868. declare module BABYLON {
  37869. /**
  37870. * Defines supported buttons for XBox360 compatible gamepads
  37871. */
  37872. export enum Xbox360Button {
  37873. /** A */
  37874. A = 0,
  37875. /** B */
  37876. B = 1,
  37877. /** X */
  37878. X = 2,
  37879. /** Y */
  37880. Y = 3,
  37881. /** Start */
  37882. Start = 4,
  37883. /** Back */
  37884. Back = 5,
  37885. /** Left button */
  37886. LB = 6,
  37887. /** Right button */
  37888. RB = 7,
  37889. /** Left stick */
  37890. LeftStick = 8,
  37891. /** Right stick */
  37892. RightStick = 9
  37893. }
  37894. /** Defines values for XBox360 DPad */
  37895. export enum Xbox360Dpad {
  37896. /** Up */
  37897. Up = 0,
  37898. /** Down */
  37899. Down = 1,
  37900. /** Left */
  37901. Left = 2,
  37902. /** Right */
  37903. Right = 3
  37904. }
  37905. /**
  37906. * Defines a XBox360 gamepad
  37907. */
  37908. export class Xbox360Pad extends Gamepad {
  37909. private _leftTrigger;
  37910. private _rightTrigger;
  37911. private _onlefttriggerchanged;
  37912. private _onrighttriggerchanged;
  37913. private _onbuttondown;
  37914. private _onbuttonup;
  37915. private _ondpaddown;
  37916. private _ondpadup;
  37917. /** Observable raised when a button is pressed */
  37918. onButtonDownObservable: Observable<Xbox360Button>;
  37919. /** Observable raised when a button is released */
  37920. onButtonUpObservable: Observable<Xbox360Button>;
  37921. /** Observable raised when a pad is pressed */
  37922. onPadDownObservable: Observable<Xbox360Dpad>;
  37923. /** Observable raised when a pad is released */
  37924. onPadUpObservable: Observable<Xbox360Dpad>;
  37925. private _buttonA;
  37926. private _buttonB;
  37927. private _buttonX;
  37928. private _buttonY;
  37929. private _buttonBack;
  37930. private _buttonStart;
  37931. private _buttonLB;
  37932. private _buttonRB;
  37933. private _buttonLeftStick;
  37934. private _buttonRightStick;
  37935. private _dPadUp;
  37936. private _dPadDown;
  37937. private _dPadLeft;
  37938. private _dPadRight;
  37939. private _isXboxOnePad;
  37940. /**
  37941. * Creates a new XBox360 gamepad object
  37942. * @param id defines the id of this gamepad
  37943. * @param index defines its index
  37944. * @param gamepad defines the internal HTML gamepad object
  37945. * @param xboxOne defines if it is a XBox One gamepad
  37946. */
  37947. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37948. /**
  37949. * Defines the callback to call when left trigger is pressed
  37950. * @param callback defines the callback to use
  37951. */
  37952. onlefttriggerchanged(callback: (value: number) => void): void;
  37953. /**
  37954. * Defines the callback to call when right trigger is pressed
  37955. * @param callback defines the callback to use
  37956. */
  37957. onrighttriggerchanged(callback: (value: number) => void): void;
  37958. /**
  37959. * Gets the left trigger value
  37960. */
  37961. /**
  37962. * Sets the left trigger value
  37963. */
  37964. leftTrigger: number;
  37965. /**
  37966. * Gets the right trigger value
  37967. */
  37968. /**
  37969. * Sets the right trigger value
  37970. */
  37971. rightTrigger: number;
  37972. /**
  37973. * Defines the callback to call when a button is pressed
  37974. * @param callback defines the callback to use
  37975. */
  37976. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37977. /**
  37978. * Defines the callback to call when a button is released
  37979. * @param callback defines the callback to use
  37980. */
  37981. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37982. /**
  37983. * Defines the callback to call when a pad is pressed
  37984. * @param callback defines the callback to use
  37985. */
  37986. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37987. /**
  37988. * Defines the callback to call when a pad is released
  37989. * @param callback defines the callback to use
  37990. */
  37991. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37992. private _setButtonValue;
  37993. private _setDPadValue;
  37994. /**
  37995. * Gets the value of the `A` button
  37996. */
  37997. /**
  37998. * Sets the value of the `A` button
  37999. */
  38000. buttonA: number;
  38001. /**
  38002. * Gets the value of the `B` button
  38003. */
  38004. /**
  38005. * Sets the value of the `B` button
  38006. */
  38007. buttonB: number;
  38008. /**
  38009. * Gets the value of the `X` button
  38010. */
  38011. /**
  38012. * Sets the value of the `X` button
  38013. */
  38014. buttonX: number;
  38015. /**
  38016. * Gets the value of the `Y` button
  38017. */
  38018. /**
  38019. * Sets the value of the `Y` button
  38020. */
  38021. buttonY: number;
  38022. /**
  38023. * Gets the value of the `Start` button
  38024. */
  38025. /**
  38026. * Sets the value of the `Start` button
  38027. */
  38028. buttonStart: number;
  38029. /**
  38030. * Gets the value of the `Back` button
  38031. */
  38032. /**
  38033. * Sets the value of the `Back` button
  38034. */
  38035. buttonBack: number;
  38036. /**
  38037. * Gets the value of the `Left` button
  38038. */
  38039. /**
  38040. * Sets the value of the `Left` button
  38041. */
  38042. buttonLB: number;
  38043. /**
  38044. * Gets the value of the `Right` button
  38045. */
  38046. /**
  38047. * Sets the value of the `Right` button
  38048. */
  38049. buttonRB: number;
  38050. /**
  38051. * Gets the value of the Left joystick
  38052. */
  38053. /**
  38054. * Sets the value of the Left joystick
  38055. */
  38056. buttonLeftStick: number;
  38057. /**
  38058. * Gets the value of the Right joystick
  38059. */
  38060. /**
  38061. * Sets the value of the Right joystick
  38062. */
  38063. buttonRightStick: number;
  38064. /**
  38065. * Gets the value of D-pad up
  38066. */
  38067. /**
  38068. * Sets the value of D-pad up
  38069. */
  38070. dPadUp: number;
  38071. /**
  38072. * Gets the value of D-pad down
  38073. */
  38074. /**
  38075. * Sets the value of D-pad down
  38076. */
  38077. dPadDown: number;
  38078. /**
  38079. * Gets the value of D-pad left
  38080. */
  38081. /**
  38082. * Sets the value of D-pad left
  38083. */
  38084. dPadLeft: number;
  38085. /**
  38086. * Gets the value of D-pad right
  38087. */
  38088. /**
  38089. * Sets the value of D-pad right
  38090. */
  38091. dPadRight: number;
  38092. /**
  38093. * Force the gamepad to synchronize with device values
  38094. */
  38095. update(): void;
  38096. /**
  38097. * Disposes the gamepad
  38098. */
  38099. dispose(): void;
  38100. }
  38101. }
  38102. declare module BABYLON {
  38103. /**
  38104. * Base class of materials working in push mode in babylon JS
  38105. * @hidden
  38106. */
  38107. export class PushMaterial extends Material {
  38108. protected _activeEffect: Effect;
  38109. protected _normalMatrix: Matrix;
  38110. /**
  38111. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38112. * This means that the material can keep using a previous shader while a new one is being compiled.
  38113. * This is mostly used when shader parallel compilation is supported (true by default)
  38114. */
  38115. allowShaderHotSwapping: boolean;
  38116. constructor(name: string, scene: Scene);
  38117. getEffect(): Effect;
  38118. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38119. /**
  38120. * Binds the given world matrix to the active effect
  38121. *
  38122. * @param world the matrix to bind
  38123. */
  38124. bindOnlyWorldMatrix(world: Matrix): void;
  38125. /**
  38126. * Binds the given normal matrix to the active effect
  38127. *
  38128. * @param normalMatrix the matrix to bind
  38129. */
  38130. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38131. bind(world: Matrix, mesh?: Mesh): void;
  38132. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38133. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38134. }
  38135. }
  38136. declare module BABYLON {
  38137. /**
  38138. * This groups all the flags used to control the materials channel.
  38139. */
  38140. export class MaterialFlags {
  38141. private static _DiffuseTextureEnabled;
  38142. /**
  38143. * Are diffuse textures enabled in the application.
  38144. */
  38145. static DiffuseTextureEnabled: boolean;
  38146. private static _AmbientTextureEnabled;
  38147. /**
  38148. * Are ambient textures enabled in the application.
  38149. */
  38150. static AmbientTextureEnabled: boolean;
  38151. private static _OpacityTextureEnabled;
  38152. /**
  38153. * Are opacity textures enabled in the application.
  38154. */
  38155. static OpacityTextureEnabled: boolean;
  38156. private static _ReflectionTextureEnabled;
  38157. /**
  38158. * Are reflection textures enabled in the application.
  38159. */
  38160. static ReflectionTextureEnabled: boolean;
  38161. private static _EmissiveTextureEnabled;
  38162. /**
  38163. * Are emissive textures enabled in the application.
  38164. */
  38165. static EmissiveTextureEnabled: boolean;
  38166. private static _SpecularTextureEnabled;
  38167. /**
  38168. * Are specular textures enabled in the application.
  38169. */
  38170. static SpecularTextureEnabled: boolean;
  38171. private static _BumpTextureEnabled;
  38172. /**
  38173. * Are bump textures enabled in the application.
  38174. */
  38175. static BumpTextureEnabled: boolean;
  38176. private static _LightmapTextureEnabled;
  38177. /**
  38178. * Are lightmap textures enabled in the application.
  38179. */
  38180. static LightmapTextureEnabled: boolean;
  38181. private static _RefractionTextureEnabled;
  38182. /**
  38183. * Are refraction textures enabled in the application.
  38184. */
  38185. static RefractionTextureEnabled: boolean;
  38186. private static _ColorGradingTextureEnabled;
  38187. /**
  38188. * Are color grading textures enabled in the application.
  38189. */
  38190. static ColorGradingTextureEnabled: boolean;
  38191. private static _FresnelEnabled;
  38192. /**
  38193. * Are fresnels enabled in the application.
  38194. */
  38195. static FresnelEnabled: boolean;
  38196. private static _ClearCoatTextureEnabled;
  38197. /**
  38198. * Are clear coat textures enabled in the application.
  38199. */
  38200. static ClearCoatTextureEnabled: boolean;
  38201. private static _ClearCoatBumpTextureEnabled;
  38202. /**
  38203. * Are clear coat bump textures enabled in the application.
  38204. */
  38205. static ClearCoatBumpTextureEnabled: boolean;
  38206. private static _ClearCoatTintTextureEnabled;
  38207. /**
  38208. * Are clear coat tint textures enabled in the application.
  38209. */
  38210. static ClearCoatTintTextureEnabled: boolean;
  38211. private static _SheenTextureEnabled;
  38212. /**
  38213. * Are sheen textures enabled in the application.
  38214. */
  38215. static SheenTextureEnabled: boolean;
  38216. private static _AnisotropicTextureEnabled;
  38217. /**
  38218. * Are anisotropic textures enabled in the application.
  38219. */
  38220. static AnisotropicTextureEnabled: boolean;
  38221. private static _ThicknessTextureEnabled;
  38222. /**
  38223. * Are thickness textures enabled in the application.
  38224. */
  38225. static ThicknessTextureEnabled: boolean;
  38226. }
  38227. }
  38228. declare module BABYLON {
  38229. /** @hidden */
  38230. export var defaultFragmentDeclaration: {
  38231. name: string;
  38232. shader: string;
  38233. };
  38234. }
  38235. declare module BABYLON {
  38236. /** @hidden */
  38237. export var defaultUboDeclaration: {
  38238. name: string;
  38239. shader: string;
  38240. };
  38241. }
  38242. declare module BABYLON {
  38243. /** @hidden */
  38244. export var lightFragmentDeclaration: {
  38245. name: string;
  38246. shader: string;
  38247. };
  38248. }
  38249. declare module BABYLON {
  38250. /** @hidden */
  38251. export var lightUboDeclaration: {
  38252. name: string;
  38253. shader: string;
  38254. };
  38255. }
  38256. declare module BABYLON {
  38257. /** @hidden */
  38258. export var lightsFragmentFunctions: {
  38259. name: string;
  38260. shader: string;
  38261. };
  38262. }
  38263. declare module BABYLON {
  38264. /** @hidden */
  38265. export var shadowsFragmentFunctions: {
  38266. name: string;
  38267. shader: string;
  38268. };
  38269. }
  38270. declare module BABYLON {
  38271. /** @hidden */
  38272. export var fresnelFunction: {
  38273. name: string;
  38274. shader: string;
  38275. };
  38276. }
  38277. declare module BABYLON {
  38278. /** @hidden */
  38279. export var reflectionFunction: {
  38280. name: string;
  38281. shader: string;
  38282. };
  38283. }
  38284. declare module BABYLON {
  38285. /** @hidden */
  38286. export var bumpFragmentFunctions: {
  38287. name: string;
  38288. shader: string;
  38289. };
  38290. }
  38291. declare module BABYLON {
  38292. /** @hidden */
  38293. export var logDepthDeclaration: {
  38294. name: string;
  38295. shader: string;
  38296. };
  38297. }
  38298. declare module BABYLON {
  38299. /** @hidden */
  38300. export var bumpFragment: {
  38301. name: string;
  38302. shader: string;
  38303. };
  38304. }
  38305. declare module BABYLON {
  38306. /** @hidden */
  38307. export var depthPrePass: {
  38308. name: string;
  38309. shader: string;
  38310. };
  38311. }
  38312. declare module BABYLON {
  38313. /** @hidden */
  38314. export var lightFragment: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module BABYLON {
  38320. /** @hidden */
  38321. export var logDepthFragment: {
  38322. name: string;
  38323. shader: string;
  38324. };
  38325. }
  38326. declare module BABYLON {
  38327. /** @hidden */
  38328. export var defaultPixelShader: {
  38329. name: string;
  38330. shader: string;
  38331. };
  38332. }
  38333. declare module BABYLON {
  38334. /** @hidden */
  38335. export var defaultVertexDeclaration: {
  38336. name: string;
  38337. shader: string;
  38338. };
  38339. }
  38340. declare module BABYLON {
  38341. /** @hidden */
  38342. export var bumpVertexDeclaration: {
  38343. name: string;
  38344. shader: string;
  38345. };
  38346. }
  38347. declare module BABYLON {
  38348. /** @hidden */
  38349. export var bumpVertex: {
  38350. name: string;
  38351. shader: string;
  38352. };
  38353. }
  38354. declare module BABYLON {
  38355. /** @hidden */
  38356. export var fogVertex: {
  38357. name: string;
  38358. shader: string;
  38359. };
  38360. }
  38361. declare module BABYLON {
  38362. /** @hidden */
  38363. export var shadowsVertex: {
  38364. name: string;
  38365. shader: string;
  38366. };
  38367. }
  38368. declare module BABYLON {
  38369. /** @hidden */
  38370. export var pointCloudVertex: {
  38371. name: string;
  38372. shader: string;
  38373. };
  38374. }
  38375. declare module BABYLON {
  38376. /** @hidden */
  38377. export var logDepthVertex: {
  38378. name: string;
  38379. shader: string;
  38380. };
  38381. }
  38382. declare module BABYLON {
  38383. /** @hidden */
  38384. export var defaultVertexShader: {
  38385. name: string;
  38386. shader: string;
  38387. };
  38388. }
  38389. declare module BABYLON {
  38390. /** @hidden */
  38391. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38392. MAINUV1: boolean;
  38393. MAINUV2: boolean;
  38394. DIFFUSE: boolean;
  38395. DIFFUSEDIRECTUV: number;
  38396. AMBIENT: boolean;
  38397. AMBIENTDIRECTUV: number;
  38398. OPACITY: boolean;
  38399. OPACITYDIRECTUV: number;
  38400. OPACITYRGB: boolean;
  38401. REFLECTION: boolean;
  38402. EMISSIVE: boolean;
  38403. EMISSIVEDIRECTUV: number;
  38404. SPECULAR: boolean;
  38405. SPECULARDIRECTUV: number;
  38406. BUMP: boolean;
  38407. BUMPDIRECTUV: number;
  38408. PARALLAX: boolean;
  38409. PARALLAXOCCLUSION: boolean;
  38410. SPECULAROVERALPHA: boolean;
  38411. CLIPPLANE: boolean;
  38412. CLIPPLANE2: boolean;
  38413. CLIPPLANE3: boolean;
  38414. CLIPPLANE4: boolean;
  38415. ALPHATEST: boolean;
  38416. DEPTHPREPASS: boolean;
  38417. ALPHAFROMDIFFUSE: boolean;
  38418. POINTSIZE: boolean;
  38419. FOG: boolean;
  38420. SPECULARTERM: boolean;
  38421. DIFFUSEFRESNEL: boolean;
  38422. OPACITYFRESNEL: boolean;
  38423. REFLECTIONFRESNEL: boolean;
  38424. REFRACTIONFRESNEL: boolean;
  38425. EMISSIVEFRESNEL: boolean;
  38426. FRESNEL: boolean;
  38427. NORMAL: boolean;
  38428. UV1: boolean;
  38429. UV2: boolean;
  38430. VERTEXCOLOR: boolean;
  38431. VERTEXALPHA: boolean;
  38432. NUM_BONE_INFLUENCERS: number;
  38433. BonesPerMesh: number;
  38434. BONETEXTURE: boolean;
  38435. INSTANCES: boolean;
  38436. GLOSSINESS: boolean;
  38437. ROUGHNESS: boolean;
  38438. EMISSIVEASILLUMINATION: boolean;
  38439. LINKEMISSIVEWITHDIFFUSE: boolean;
  38440. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38441. LIGHTMAP: boolean;
  38442. LIGHTMAPDIRECTUV: number;
  38443. OBJECTSPACE_NORMALMAP: boolean;
  38444. USELIGHTMAPASSHADOWMAP: boolean;
  38445. REFLECTIONMAP_3D: boolean;
  38446. REFLECTIONMAP_SPHERICAL: boolean;
  38447. REFLECTIONMAP_PLANAR: boolean;
  38448. REFLECTIONMAP_CUBIC: boolean;
  38449. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38450. REFLECTIONMAP_PROJECTION: boolean;
  38451. REFLECTIONMAP_SKYBOX: boolean;
  38452. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38453. REFLECTIONMAP_EXPLICIT: boolean;
  38454. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38455. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38456. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38457. INVERTCUBICMAP: boolean;
  38458. LOGARITHMICDEPTH: boolean;
  38459. REFRACTION: boolean;
  38460. REFRACTIONMAP_3D: boolean;
  38461. REFLECTIONOVERALPHA: boolean;
  38462. TWOSIDEDLIGHTING: boolean;
  38463. SHADOWFLOAT: boolean;
  38464. MORPHTARGETS: boolean;
  38465. MORPHTARGETS_NORMAL: boolean;
  38466. MORPHTARGETS_TANGENT: boolean;
  38467. NUM_MORPH_INFLUENCERS: number;
  38468. NONUNIFORMSCALING: boolean;
  38469. PREMULTIPLYALPHA: boolean;
  38470. IMAGEPROCESSING: boolean;
  38471. VIGNETTE: boolean;
  38472. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38473. VIGNETTEBLENDMODEOPAQUE: boolean;
  38474. TONEMAPPING: boolean;
  38475. TONEMAPPING_ACES: boolean;
  38476. CONTRAST: boolean;
  38477. COLORCURVES: boolean;
  38478. COLORGRADING: boolean;
  38479. COLORGRADING3D: boolean;
  38480. SAMPLER3DGREENDEPTH: boolean;
  38481. SAMPLER3DBGRMAP: boolean;
  38482. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38483. MULTIVIEW: boolean;
  38484. /**
  38485. * If the reflection texture on this material is in linear color space
  38486. * @hidden
  38487. */
  38488. IS_REFLECTION_LINEAR: boolean;
  38489. /**
  38490. * If the refraction texture on this material is in linear color space
  38491. * @hidden
  38492. */
  38493. IS_REFRACTION_LINEAR: boolean;
  38494. EXPOSURE: boolean;
  38495. constructor();
  38496. setReflectionMode(modeToEnable: string): void;
  38497. }
  38498. /**
  38499. * This is the default material used in Babylon. It is the best trade off between quality
  38500. * and performances.
  38501. * @see http://doc.babylonjs.com/babylon101/materials
  38502. */
  38503. export class StandardMaterial extends PushMaterial {
  38504. private _diffuseTexture;
  38505. /**
  38506. * The basic texture of the material as viewed under a light.
  38507. */
  38508. diffuseTexture: Nullable<BaseTexture>;
  38509. private _ambientTexture;
  38510. /**
  38511. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38512. */
  38513. ambientTexture: Nullable<BaseTexture>;
  38514. private _opacityTexture;
  38515. /**
  38516. * Define the transparency of the material from a texture.
  38517. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38518. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38519. */
  38520. opacityTexture: Nullable<BaseTexture>;
  38521. private _reflectionTexture;
  38522. /**
  38523. * Define the texture used to display the reflection.
  38524. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38525. */
  38526. reflectionTexture: Nullable<BaseTexture>;
  38527. private _emissiveTexture;
  38528. /**
  38529. * Define texture of the material as if self lit.
  38530. * This will be mixed in the final result even in the absence of light.
  38531. */
  38532. emissiveTexture: Nullable<BaseTexture>;
  38533. private _specularTexture;
  38534. /**
  38535. * Define how the color and intensity of the highlight given by the light in the material.
  38536. */
  38537. specularTexture: Nullable<BaseTexture>;
  38538. private _bumpTexture;
  38539. /**
  38540. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38541. * 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.
  38542. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38543. */
  38544. bumpTexture: Nullable<BaseTexture>;
  38545. private _lightmapTexture;
  38546. /**
  38547. * Complex lighting can be computationally expensive to compute at runtime.
  38548. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38549. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38550. */
  38551. lightmapTexture: Nullable<BaseTexture>;
  38552. private _refractionTexture;
  38553. /**
  38554. * Define the texture used to display the refraction.
  38555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38556. */
  38557. refractionTexture: Nullable<BaseTexture>;
  38558. /**
  38559. * The color of the material lit by the environmental background lighting.
  38560. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38561. */
  38562. ambientColor: Color3;
  38563. /**
  38564. * The basic color of the material as viewed under a light.
  38565. */
  38566. diffuseColor: Color3;
  38567. /**
  38568. * Define how the color and intensity of the highlight given by the light in the material.
  38569. */
  38570. specularColor: Color3;
  38571. /**
  38572. * Define the color of the material as if self lit.
  38573. * This will be mixed in the final result even in the absence of light.
  38574. */
  38575. emissiveColor: Color3;
  38576. /**
  38577. * Defines how sharp are the highlights in the material.
  38578. * The bigger the value the sharper giving a more glossy feeling to the result.
  38579. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38580. */
  38581. specularPower: number;
  38582. private _useAlphaFromDiffuseTexture;
  38583. /**
  38584. * Does the transparency come from the diffuse texture alpha channel.
  38585. */
  38586. useAlphaFromDiffuseTexture: boolean;
  38587. private _useEmissiveAsIllumination;
  38588. /**
  38589. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38590. */
  38591. useEmissiveAsIllumination: boolean;
  38592. private _linkEmissiveWithDiffuse;
  38593. /**
  38594. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38595. * the emissive level when the final color is close to one.
  38596. */
  38597. linkEmissiveWithDiffuse: boolean;
  38598. private _useSpecularOverAlpha;
  38599. /**
  38600. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38601. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38602. */
  38603. useSpecularOverAlpha: boolean;
  38604. private _useReflectionOverAlpha;
  38605. /**
  38606. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38607. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38608. */
  38609. useReflectionOverAlpha: boolean;
  38610. private _disableLighting;
  38611. /**
  38612. * Does lights from the scene impacts this material.
  38613. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38614. */
  38615. disableLighting: boolean;
  38616. private _useObjectSpaceNormalMap;
  38617. /**
  38618. * Allows using an object space normal map (instead of tangent space).
  38619. */
  38620. useObjectSpaceNormalMap: boolean;
  38621. private _useParallax;
  38622. /**
  38623. * Is parallax enabled or not.
  38624. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38625. */
  38626. useParallax: boolean;
  38627. private _useParallaxOcclusion;
  38628. /**
  38629. * Is parallax occlusion enabled or not.
  38630. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38631. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38632. */
  38633. useParallaxOcclusion: boolean;
  38634. /**
  38635. * 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.
  38636. */
  38637. parallaxScaleBias: number;
  38638. private _roughness;
  38639. /**
  38640. * Helps to define how blurry the reflections should appears in the material.
  38641. */
  38642. roughness: number;
  38643. /**
  38644. * In case of refraction, define the value of the indice of refraction.
  38645. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38646. */
  38647. indexOfRefraction: number;
  38648. /**
  38649. * Invert the refraction texture alongside the y axis.
  38650. * It can be useful with procedural textures or probe for instance.
  38651. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38652. */
  38653. invertRefractionY: boolean;
  38654. /**
  38655. * Defines the alpha limits in alpha test mode.
  38656. */
  38657. alphaCutOff: number;
  38658. private _useLightmapAsShadowmap;
  38659. /**
  38660. * In case of light mapping, define whether the map contains light or shadow informations.
  38661. */
  38662. useLightmapAsShadowmap: boolean;
  38663. private _diffuseFresnelParameters;
  38664. /**
  38665. * Define the diffuse fresnel parameters of the material.
  38666. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38667. */
  38668. diffuseFresnelParameters: FresnelParameters;
  38669. private _opacityFresnelParameters;
  38670. /**
  38671. * Define the opacity fresnel parameters of the material.
  38672. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38673. */
  38674. opacityFresnelParameters: FresnelParameters;
  38675. private _reflectionFresnelParameters;
  38676. /**
  38677. * Define the reflection fresnel parameters of the material.
  38678. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38679. */
  38680. reflectionFresnelParameters: FresnelParameters;
  38681. private _refractionFresnelParameters;
  38682. /**
  38683. * Define the refraction fresnel parameters of the material.
  38684. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38685. */
  38686. refractionFresnelParameters: FresnelParameters;
  38687. private _emissiveFresnelParameters;
  38688. /**
  38689. * Define the emissive fresnel parameters of the material.
  38690. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38691. */
  38692. emissiveFresnelParameters: FresnelParameters;
  38693. private _useReflectionFresnelFromSpecular;
  38694. /**
  38695. * If true automatically deducts the fresnels values from the material specularity.
  38696. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38697. */
  38698. useReflectionFresnelFromSpecular: boolean;
  38699. private _useGlossinessFromSpecularMapAlpha;
  38700. /**
  38701. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38702. */
  38703. useGlossinessFromSpecularMapAlpha: boolean;
  38704. private _maxSimultaneousLights;
  38705. /**
  38706. * Defines the maximum number of lights that can be used in the material
  38707. */
  38708. maxSimultaneousLights: number;
  38709. private _invertNormalMapX;
  38710. /**
  38711. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38712. */
  38713. invertNormalMapX: boolean;
  38714. private _invertNormalMapY;
  38715. /**
  38716. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38717. */
  38718. invertNormalMapY: boolean;
  38719. private _twoSidedLighting;
  38720. /**
  38721. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38722. */
  38723. twoSidedLighting: boolean;
  38724. /**
  38725. * Default configuration related to image processing available in the standard Material.
  38726. */
  38727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38728. /**
  38729. * Gets the image processing configuration used either in this material.
  38730. */
  38731. /**
  38732. * Sets the Default image processing configuration used either in the this material.
  38733. *
  38734. * If sets to null, the scene one is in use.
  38735. */
  38736. imageProcessingConfiguration: ImageProcessingConfiguration;
  38737. /**
  38738. * Keep track of the image processing observer to allow dispose and replace.
  38739. */
  38740. private _imageProcessingObserver;
  38741. /**
  38742. * Attaches a new image processing configuration to the Standard Material.
  38743. * @param configuration
  38744. */
  38745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38746. /**
  38747. * Gets wether the color curves effect is enabled.
  38748. */
  38749. /**
  38750. * Sets wether the color curves effect is enabled.
  38751. */
  38752. cameraColorCurvesEnabled: boolean;
  38753. /**
  38754. * Gets wether the color grading effect is enabled.
  38755. */
  38756. /**
  38757. * Gets wether the color grading effect is enabled.
  38758. */
  38759. cameraColorGradingEnabled: boolean;
  38760. /**
  38761. * Gets wether tonemapping is enabled or not.
  38762. */
  38763. /**
  38764. * Sets wether tonemapping is enabled or not
  38765. */
  38766. cameraToneMappingEnabled: boolean;
  38767. /**
  38768. * The camera exposure used on this material.
  38769. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38770. * This corresponds to a photographic exposure.
  38771. */
  38772. /**
  38773. * The camera exposure used on this material.
  38774. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38775. * This corresponds to a photographic exposure.
  38776. */
  38777. cameraExposure: number;
  38778. /**
  38779. * Gets The camera contrast used on this material.
  38780. */
  38781. /**
  38782. * Sets The camera contrast used on this material.
  38783. */
  38784. cameraContrast: number;
  38785. /**
  38786. * Gets the Color Grading 2D Lookup Texture.
  38787. */
  38788. /**
  38789. * Sets the Color Grading 2D Lookup Texture.
  38790. */
  38791. cameraColorGradingTexture: Nullable<BaseTexture>;
  38792. /**
  38793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38795. * 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;
  38796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38797. */
  38798. /**
  38799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38801. * 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;
  38802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38803. */
  38804. cameraColorCurves: Nullable<ColorCurves>;
  38805. /**
  38806. * Custom callback helping to override the default shader used in the material.
  38807. */
  38808. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38809. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38810. protected _worldViewProjectionMatrix: Matrix;
  38811. protected _globalAmbientColor: Color3;
  38812. protected _useLogarithmicDepth: boolean;
  38813. /**
  38814. * Instantiates a new standard material.
  38815. * This is the default material used in Babylon. It is the best trade off between quality
  38816. * and performances.
  38817. * @see http://doc.babylonjs.com/babylon101/materials
  38818. * @param name Define the name of the material in the scene
  38819. * @param scene Define the scene the material belong to
  38820. */
  38821. constructor(name: string, scene: Scene);
  38822. /**
  38823. * Gets a boolean indicating that current material needs to register RTT
  38824. */
  38825. readonly hasRenderTargetTextures: boolean;
  38826. /**
  38827. * Gets the current class name of the material e.g. "StandardMaterial"
  38828. * Mainly use in serialization.
  38829. * @returns the class name
  38830. */
  38831. getClassName(): string;
  38832. /**
  38833. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38834. * You can try switching to logarithmic depth.
  38835. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38836. */
  38837. useLogarithmicDepth: boolean;
  38838. /**
  38839. * Specifies if the material will require alpha blending
  38840. * @returns a boolean specifying if alpha blending is needed
  38841. */
  38842. needAlphaBlending(): boolean;
  38843. /**
  38844. * Specifies if this material should be rendered in alpha test mode
  38845. * @returns a boolean specifying if an alpha test is needed.
  38846. */
  38847. needAlphaTesting(): boolean;
  38848. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38849. /**
  38850. * Get the texture used for alpha test purpose.
  38851. * @returns the diffuse texture in case of the standard material.
  38852. */
  38853. getAlphaTestTexture(): Nullable<BaseTexture>;
  38854. /**
  38855. * Get if the submesh is ready to be used and all its information available.
  38856. * Child classes can use it to update shaders
  38857. * @param mesh defines the mesh to check
  38858. * @param subMesh defines which submesh to check
  38859. * @param useInstances specifies that instances should be used
  38860. * @returns a boolean indicating that the submesh is ready or not
  38861. */
  38862. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38863. /**
  38864. * Builds the material UBO layouts.
  38865. * Used internally during the effect preparation.
  38866. */
  38867. buildUniformLayout(): void;
  38868. /**
  38869. * Unbinds the material from the mesh
  38870. */
  38871. unbind(): void;
  38872. /**
  38873. * Binds the submesh to this material by preparing the effect and shader to draw
  38874. * @param world defines the world transformation matrix
  38875. * @param mesh defines the mesh containing the submesh
  38876. * @param subMesh defines the submesh to bind the material to
  38877. */
  38878. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38879. /**
  38880. * Get the list of animatables in the material.
  38881. * @returns the list of animatables object used in the material
  38882. */
  38883. getAnimatables(): IAnimatable[];
  38884. /**
  38885. * Gets the active textures from the material
  38886. * @returns an array of textures
  38887. */
  38888. getActiveTextures(): BaseTexture[];
  38889. /**
  38890. * Specifies if the material uses a texture
  38891. * @param texture defines the texture to check against the material
  38892. * @returns a boolean specifying if the material uses the texture
  38893. */
  38894. hasTexture(texture: BaseTexture): boolean;
  38895. /**
  38896. * Disposes the material
  38897. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38898. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38899. */
  38900. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38901. /**
  38902. * Makes a duplicate of the material, and gives it a new name
  38903. * @param name defines the new name for the duplicated material
  38904. * @returns the cloned material
  38905. */
  38906. clone(name: string): StandardMaterial;
  38907. /**
  38908. * Serializes this material in a JSON representation
  38909. * @returns the serialized material object
  38910. */
  38911. serialize(): any;
  38912. /**
  38913. * Creates a standard material from parsed material data
  38914. * @param source defines the JSON representation of the material
  38915. * @param scene defines the hosting scene
  38916. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38917. * @returns a new standard material
  38918. */
  38919. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38920. /**
  38921. * Are diffuse textures enabled in the application.
  38922. */
  38923. static DiffuseTextureEnabled: boolean;
  38924. /**
  38925. * Are ambient textures enabled in the application.
  38926. */
  38927. static AmbientTextureEnabled: boolean;
  38928. /**
  38929. * Are opacity textures enabled in the application.
  38930. */
  38931. static OpacityTextureEnabled: boolean;
  38932. /**
  38933. * Are reflection textures enabled in the application.
  38934. */
  38935. static ReflectionTextureEnabled: boolean;
  38936. /**
  38937. * Are emissive textures enabled in the application.
  38938. */
  38939. static EmissiveTextureEnabled: boolean;
  38940. /**
  38941. * Are specular textures enabled in the application.
  38942. */
  38943. static SpecularTextureEnabled: boolean;
  38944. /**
  38945. * Are bump textures enabled in the application.
  38946. */
  38947. static BumpTextureEnabled: boolean;
  38948. /**
  38949. * Are lightmap textures enabled in the application.
  38950. */
  38951. static LightmapTextureEnabled: boolean;
  38952. /**
  38953. * Are refraction textures enabled in the application.
  38954. */
  38955. static RefractionTextureEnabled: boolean;
  38956. /**
  38957. * Are color grading textures enabled in the application.
  38958. */
  38959. static ColorGradingTextureEnabled: boolean;
  38960. /**
  38961. * Are fresnels enabled in the application.
  38962. */
  38963. static FresnelEnabled: boolean;
  38964. }
  38965. }
  38966. declare module BABYLON {
  38967. /**
  38968. * A class extending Texture allowing drawing on a texture
  38969. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38970. */
  38971. export class DynamicTexture extends Texture {
  38972. private _generateMipMaps;
  38973. private _canvas;
  38974. private _context;
  38975. private _engine;
  38976. /**
  38977. * Creates a DynamicTexture
  38978. * @param name defines the name of the texture
  38979. * @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
  38980. * @param scene defines the scene where you want the texture
  38981. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38982. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38983. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38984. */
  38985. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38986. /**
  38987. * Get the current class name of the texture useful for serialization or dynamic coding.
  38988. * @returns "DynamicTexture"
  38989. */
  38990. getClassName(): string;
  38991. /**
  38992. * Gets the current state of canRescale
  38993. */
  38994. readonly canRescale: boolean;
  38995. private _recreate;
  38996. /**
  38997. * Scales the texture
  38998. * @param ratio the scale factor to apply to both width and height
  38999. */
  39000. scale(ratio: number): void;
  39001. /**
  39002. * Resizes the texture
  39003. * @param width the new width
  39004. * @param height the new height
  39005. */
  39006. scaleTo(width: number, height: number): void;
  39007. /**
  39008. * Gets the context of the canvas used by the texture
  39009. * @returns the canvas context of the dynamic texture
  39010. */
  39011. getContext(): CanvasRenderingContext2D;
  39012. /**
  39013. * Clears the texture
  39014. */
  39015. clear(): void;
  39016. /**
  39017. * Updates the texture
  39018. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39019. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39020. */
  39021. update(invertY?: boolean, premulAlpha?: boolean): void;
  39022. /**
  39023. * Draws text onto the texture
  39024. * @param text defines the text to be drawn
  39025. * @param x defines the placement of the text from the left
  39026. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39027. * @param font defines the font to be used with font-style, font-size, font-name
  39028. * @param color defines the color used for the text
  39029. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39030. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39031. * @param update defines whether texture is immediately update (default is true)
  39032. */
  39033. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39034. /**
  39035. * Clones the texture
  39036. * @returns the clone of the texture.
  39037. */
  39038. clone(): DynamicTexture;
  39039. /**
  39040. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39041. * @returns a serialized dynamic texture object
  39042. */
  39043. serialize(): any;
  39044. /** @hidden */
  39045. _rebuild(): void;
  39046. }
  39047. }
  39048. declare module BABYLON {
  39049. /** @hidden */
  39050. export var imageProcessingPixelShader: {
  39051. name: string;
  39052. shader: string;
  39053. };
  39054. }
  39055. declare module BABYLON {
  39056. /**
  39057. * ImageProcessingPostProcess
  39058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39059. */
  39060. export class ImageProcessingPostProcess extends PostProcess {
  39061. /**
  39062. * Default configuration related to image processing available in the PBR Material.
  39063. */
  39064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39065. /**
  39066. * Gets the image processing configuration used either in this material.
  39067. */
  39068. /**
  39069. * Sets the Default image processing configuration used either in the this material.
  39070. *
  39071. * If sets to null, the scene one is in use.
  39072. */
  39073. imageProcessingConfiguration: ImageProcessingConfiguration;
  39074. /**
  39075. * Keep track of the image processing observer to allow dispose and replace.
  39076. */
  39077. private _imageProcessingObserver;
  39078. /**
  39079. * Attaches a new image processing configuration to the PBR Material.
  39080. * @param configuration
  39081. */
  39082. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39083. /**
  39084. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39085. */
  39086. /**
  39087. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39088. */
  39089. colorCurves: Nullable<ColorCurves>;
  39090. /**
  39091. * Gets wether the color curves effect is enabled.
  39092. */
  39093. /**
  39094. * Sets wether the color curves effect is enabled.
  39095. */
  39096. colorCurvesEnabled: boolean;
  39097. /**
  39098. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39099. */
  39100. /**
  39101. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39102. */
  39103. colorGradingTexture: Nullable<BaseTexture>;
  39104. /**
  39105. * Gets wether the color grading effect is enabled.
  39106. */
  39107. /**
  39108. * Gets wether the color grading effect is enabled.
  39109. */
  39110. colorGradingEnabled: boolean;
  39111. /**
  39112. * Gets exposure used in the effect.
  39113. */
  39114. /**
  39115. * Sets exposure used in the effect.
  39116. */
  39117. exposure: number;
  39118. /**
  39119. * Gets wether tonemapping is enabled or not.
  39120. */
  39121. /**
  39122. * Sets wether tonemapping is enabled or not
  39123. */
  39124. toneMappingEnabled: boolean;
  39125. /**
  39126. * Gets the type of tone mapping effect.
  39127. */
  39128. /**
  39129. * Sets the type of tone mapping effect.
  39130. */
  39131. toneMappingType: number;
  39132. /**
  39133. * Gets contrast used in the effect.
  39134. */
  39135. /**
  39136. * Sets contrast used in the effect.
  39137. */
  39138. contrast: number;
  39139. /**
  39140. * Gets Vignette stretch size.
  39141. */
  39142. /**
  39143. * Sets Vignette stretch size.
  39144. */
  39145. vignetteStretch: number;
  39146. /**
  39147. * Gets Vignette centre X Offset.
  39148. */
  39149. /**
  39150. * Sets Vignette centre X Offset.
  39151. */
  39152. vignetteCentreX: number;
  39153. /**
  39154. * Gets Vignette centre Y Offset.
  39155. */
  39156. /**
  39157. * Sets Vignette centre Y Offset.
  39158. */
  39159. vignetteCentreY: number;
  39160. /**
  39161. * Gets Vignette weight or intensity of the vignette effect.
  39162. */
  39163. /**
  39164. * Sets Vignette weight or intensity of the vignette effect.
  39165. */
  39166. vignetteWeight: number;
  39167. /**
  39168. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39169. * if vignetteEnabled is set to true.
  39170. */
  39171. /**
  39172. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39173. * if vignetteEnabled is set to true.
  39174. */
  39175. vignetteColor: Color4;
  39176. /**
  39177. * Gets Camera field of view used by the Vignette effect.
  39178. */
  39179. /**
  39180. * Sets Camera field of view used by the Vignette effect.
  39181. */
  39182. vignetteCameraFov: number;
  39183. /**
  39184. * Gets the vignette blend mode allowing different kind of effect.
  39185. */
  39186. /**
  39187. * Sets the vignette blend mode allowing different kind of effect.
  39188. */
  39189. vignetteBlendMode: number;
  39190. /**
  39191. * Gets wether the vignette effect is enabled.
  39192. */
  39193. /**
  39194. * Sets wether the vignette effect is enabled.
  39195. */
  39196. vignetteEnabled: boolean;
  39197. private _fromLinearSpace;
  39198. /**
  39199. * Gets wether the input of the processing is in Gamma or Linear Space.
  39200. */
  39201. /**
  39202. * Sets wether the input of the processing is in Gamma or Linear Space.
  39203. */
  39204. fromLinearSpace: boolean;
  39205. /**
  39206. * Defines cache preventing GC.
  39207. */
  39208. private _defines;
  39209. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39210. /**
  39211. * "ImageProcessingPostProcess"
  39212. * @returns "ImageProcessingPostProcess"
  39213. */
  39214. getClassName(): string;
  39215. protected _updateParameters(): void;
  39216. dispose(camera?: Camera): void;
  39217. }
  39218. }
  39219. declare module BABYLON {
  39220. /**
  39221. * Class containing static functions to help procedurally build meshes
  39222. */
  39223. export class GroundBuilder {
  39224. /**
  39225. * Creates a ground mesh
  39226. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39227. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39229. * @param name defines the name of the mesh
  39230. * @param options defines the options used to create the mesh
  39231. * @param scene defines the hosting scene
  39232. * @returns the ground mesh
  39233. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39234. */
  39235. static CreateGround(name: string, options: {
  39236. width?: number;
  39237. height?: number;
  39238. subdivisions?: number;
  39239. subdivisionsX?: number;
  39240. subdivisionsY?: number;
  39241. updatable?: boolean;
  39242. }, scene: any): Mesh;
  39243. /**
  39244. * Creates a tiled ground mesh
  39245. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39246. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39247. * * 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
  39248. * * 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
  39249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39250. * @param name defines the name of the mesh
  39251. * @param options defines the options used to create the mesh
  39252. * @param scene defines the hosting scene
  39253. * @returns the tiled ground mesh
  39254. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39255. */
  39256. static CreateTiledGround(name: string, options: {
  39257. xmin: number;
  39258. zmin: number;
  39259. xmax: number;
  39260. zmax: number;
  39261. subdivisions?: {
  39262. w: number;
  39263. h: number;
  39264. };
  39265. precision?: {
  39266. w: number;
  39267. h: number;
  39268. };
  39269. updatable?: boolean;
  39270. }, scene?: Nullable<Scene>): Mesh;
  39271. /**
  39272. * Creates a ground mesh from a height map
  39273. * * The parameter `url` sets the URL of the height map image resource.
  39274. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39275. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39276. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39277. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39278. * * 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.
  39279. * * 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).
  39280. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39282. * @param name defines the name of the mesh
  39283. * @param url defines the url to the height map
  39284. * @param options defines the options used to create the mesh
  39285. * @param scene defines the hosting scene
  39286. * @returns the ground mesh
  39287. * @see https://doc.babylonjs.com/babylon101/height_map
  39288. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39289. */
  39290. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39291. width?: number;
  39292. height?: number;
  39293. subdivisions?: number;
  39294. minHeight?: number;
  39295. maxHeight?: number;
  39296. colorFilter?: Color3;
  39297. alphaFilter?: number;
  39298. updatable?: boolean;
  39299. onReady?: (mesh: GroundMesh) => void;
  39300. }, scene?: Nullable<Scene>): GroundMesh;
  39301. }
  39302. }
  39303. declare module BABYLON {
  39304. /**
  39305. * Class containing static functions to help procedurally build meshes
  39306. */
  39307. export class TorusBuilder {
  39308. /**
  39309. * Creates a torus mesh
  39310. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39311. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39312. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39314. * * 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
  39315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39316. * @param name defines the name of the mesh
  39317. * @param options defines the options used to create the mesh
  39318. * @param scene defines the hosting scene
  39319. * @returns the torus mesh
  39320. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39321. */
  39322. static CreateTorus(name: string, options: {
  39323. diameter?: number;
  39324. thickness?: number;
  39325. tessellation?: number;
  39326. updatable?: boolean;
  39327. sideOrientation?: number;
  39328. frontUVs?: Vector4;
  39329. backUVs?: Vector4;
  39330. }, scene: any): Mesh;
  39331. }
  39332. }
  39333. declare module BABYLON {
  39334. /**
  39335. * Class containing static functions to help procedurally build meshes
  39336. */
  39337. export class CylinderBuilder {
  39338. /**
  39339. * Creates a cylinder or a cone mesh
  39340. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39341. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39342. * * 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.
  39343. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39344. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39345. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39346. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39347. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39348. * * 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).
  39349. * * 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
  39350. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39351. * * 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
  39352. * * 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.
  39353. * * If `enclose` is false, a ring surface is one element.
  39354. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39355. * * 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
  39356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39357. * * 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
  39358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39359. * @param name defines the name of the mesh
  39360. * @param options defines the options used to create the mesh
  39361. * @param scene defines the hosting scene
  39362. * @returns the cylinder mesh
  39363. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39364. */
  39365. static CreateCylinder(name: string, options: {
  39366. height?: number;
  39367. diameterTop?: number;
  39368. diameterBottom?: number;
  39369. diameter?: number;
  39370. tessellation?: number;
  39371. subdivisions?: number;
  39372. arc?: number;
  39373. faceColors?: Color4[];
  39374. faceUV?: Vector4[];
  39375. updatable?: boolean;
  39376. hasRings?: boolean;
  39377. enclose?: boolean;
  39378. sideOrientation?: number;
  39379. frontUVs?: Vector4;
  39380. backUVs?: Vector4;
  39381. }, scene: any): Mesh;
  39382. }
  39383. }
  39384. declare module BABYLON {
  39385. /**
  39386. * Manager for handling gamepads
  39387. */
  39388. export class GamepadManager {
  39389. private _scene?;
  39390. private _babylonGamepads;
  39391. private _oneGamepadConnected;
  39392. /** @hidden */
  39393. _isMonitoring: boolean;
  39394. private _gamepadEventSupported;
  39395. private _gamepadSupport;
  39396. /**
  39397. * observable to be triggered when the gamepad controller has been connected
  39398. */
  39399. onGamepadConnectedObservable: Observable<Gamepad>;
  39400. /**
  39401. * observable to be triggered when the gamepad controller has been disconnected
  39402. */
  39403. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39404. private _onGamepadConnectedEvent;
  39405. private _onGamepadDisconnectedEvent;
  39406. /**
  39407. * Initializes the gamepad manager
  39408. * @param _scene BabylonJS scene
  39409. */
  39410. constructor(_scene?: Scene | undefined);
  39411. /**
  39412. * The gamepads in the game pad manager
  39413. */
  39414. readonly gamepads: Gamepad[];
  39415. /**
  39416. * Get the gamepad controllers based on type
  39417. * @param type The type of gamepad controller
  39418. * @returns Nullable gamepad
  39419. */
  39420. getGamepadByType(type?: number): Nullable<Gamepad>;
  39421. /**
  39422. * Disposes the gamepad manager
  39423. */
  39424. dispose(): void;
  39425. private _addNewGamepad;
  39426. private _startMonitoringGamepads;
  39427. private _stopMonitoringGamepads;
  39428. /** @hidden */
  39429. _checkGamepadsStatus(): void;
  39430. private _updateGamepadObjects;
  39431. }
  39432. }
  39433. declare module BABYLON {
  39434. interface Scene {
  39435. /** @hidden */
  39436. _gamepadManager: Nullable<GamepadManager>;
  39437. /**
  39438. * Gets the gamepad manager associated with the scene
  39439. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39440. */
  39441. gamepadManager: GamepadManager;
  39442. }
  39443. /**
  39444. * Interface representing a free camera inputs manager
  39445. */
  39446. interface FreeCameraInputsManager {
  39447. /**
  39448. * Adds gamepad input support to the FreeCameraInputsManager.
  39449. * @returns the FreeCameraInputsManager
  39450. */
  39451. addGamepad(): FreeCameraInputsManager;
  39452. }
  39453. /**
  39454. * Interface representing an arc rotate camera inputs manager
  39455. */
  39456. interface ArcRotateCameraInputsManager {
  39457. /**
  39458. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39459. * @returns the camera inputs manager
  39460. */
  39461. addGamepad(): ArcRotateCameraInputsManager;
  39462. }
  39463. /**
  39464. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39465. */
  39466. export class GamepadSystemSceneComponent implements ISceneComponent {
  39467. /**
  39468. * The component name helpfull to identify the component in the list of scene components.
  39469. */
  39470. readonly name: string;
  39471. /**
  39472. * The scene the component belongs to.
  39473. */
  39474. scene: Scene;
  39475. /**
  39476. * Creates a new instance of the component for the given scene
  39477. * @param scene Defines the scene to register the component in
  39478. */
  39479. constructor(scene: Scene);
  39480. /**
  39481. * Registers the component in a given scene
  39482. */
  39483. register(): void;
  39484. /**
  39485. * Rebuilds the elements related to this component in case of
  39486. * context lost for instance.
  39487. */
  39488. rebuild(): void;
  39489. /**
  39490. * Disposes the component and the associated ressources
  39491. */
  39492. dispose(): void;
  39493. private _beforeCameraUpdate;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Options to modify the vr teleportation behavior.
  39499. */
  39500. export interface VRTeleportationOptions {
  39501. /**
  39502. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39503. */
  39504. floorMeshName?: string;
  39505. /**
  39506. * A list of meshes to be used as the teleportation floor. (default: empty)
  39507. */
  39508. floorMeshes?: Mesh[];
  39509. }
  39510. /**
  39511. * Options to modify the vr experience helper's behavior.
  39512. */
  39513. export interface VRExperienceHelperOptions extends WebVROptions {
  39514. /**
  39515. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39516. */
  39517. createDeviceOrientationCamera?: boolean;
  39518. /**
  39519. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39520. */
  39521. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39522. /**
  39523. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39524. */
  39525. laserToggle?: boolean;
  39526. /**
  39527. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39528. */
  39529. floorMeshes?: Mesh[];
  39530. /**
  39531. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39532. */
  39533. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39534. }
  39535. /**
  39536. * Event containing information after VR has been entered
  39537. */
  39538. export class OnAfterEnteringVRObservableEvent {
  39539. /**
  39540. * If entering vr was successful
  39541. */
  39542. success: boolean;
  39543. }
  39544. /**
  39545. * Helps to quickly add VR support to an existing scene.
  39546. * See http://doc.babylonjs.com/how_to/webvr_helper
  39547. */
  39548. export class VRExperienceHelper {
  39549. /** Options to modify the vr experience helper's behavior. */
  39550. webVROptions: VRExperienceHelperOptions;
  39551. private _scene;
  39552. private _position;
  39553. private _btnVR;
  39554. private _btnVRDisplayed;
  39555. private _webVRsupported;
  39556. private _webVRready;
  39557. private _webVRrequesting;
  39558. private _webVRpresenting;
  39559. private _hasEnteredVR;
  39560. private _fullscreenVRpresenting;
  39561. private _canvas;
  39562. private _webVRCamera;
  39563. private _vrDeviceOrientationCamera;
  39564. private _deviceOrientationCamera;
  39565. private _existingCamera;
  39566. private _onKeyDown;
  39567. private _onVrDisplayPresentChange;
  39568. private _onVRDisplayChanged;
  39569. private _onVRRequestPresentStart;
  39570. private _onVRRequestPresentComplete;
  39571. /**
  39572. * Observable raised right before entering VR.
  39573. */
  39574. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39575. /**
  39576. * Observable raised when entering VR has completed.
  39577. */
  39578. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39579. /**
  39580. * Observable raised when exiting VR.
  39581. */
  39582. onExitingVRObservable: Observable<VRExperienceHelper>;
  39583. /**
  39584. * Observable raised when controller mesh is loaded.
  39585. */
  39586. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39587. /** Return this.onEnteringVRObservable
  39588. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39589. */
  39590. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39591. /** Return this.onExitingVRObservable
  39592. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39593. */
  39594. readonly onExitingVR: Observable<VRExperienceHelper>;
  39595. /** Return this.onControllerMeshLoadedObservable
  39596. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39597. */
  39598. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39599. private _rayLength;
  39600. private _useCustomVRButton;
  39601. private _teleportationRequested;
  39602. private _teleportActive;
  39603. private _floorMeshName;
  39604. private _floorMeshesCollection;
  39605. private _rotationAllowed;
  39606. private _teleportBackwardsVector;
  39607. private _teleportationTarget;
  39608. private _isDefaultTeleportationTarget;
  39609. private _postProcessMove;
  39610. private _teleportationFillColor;
  39611. private _teleportationBorderColor;
  39612. private _rotationAngle;
  39613. private _haloCenter;
  39614. private _cameraGazer;
  39615. private _padSensibilityUp;
  39616. private _padSensibilityDown;
  39617. private _leftController;
  39618. private _rightController;
  39619. /**
  39620. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39621. */
  39622. onNewMeshSelected: Observable<AbstractMesh>;
  39623. /**
  39624. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39625. */
  39626. onNewMeshPicked: Observable<PickingInfo>;
  39627. private _circleEase;
  39628. /**
  39629. * Observable raised before camera teleportation
  39630. */
  39631. onBeforeCameraTeleport: Observable<Vector3>;
  39632. /**
  39633. * Observable raised after camera teleportation
  39634. */
  39635. onAfterCameraTeleport: Observable<Vector3>;
  39636. /**
  39637. * Observable raised when current selected mesh gets unselected
  39638. */
  39639. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39640. private _raySelectionPredicate;
  39641. /**
  39642. * To be optionaly changed by user to define custom ray selection
  39643. */
  39644. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39645. /**
  39646. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39647. */
  39648. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39649. /**
  39650. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39651. */
  39652. teleportationEnabled: boolean;
  39653. private _defaultHeight;
  39654. private _teleportationInitialized;
  39655. private _interactionsEnabled;
  39656. private _interactionsRequested;
  39657. private _displayGaze;
  39658. private _displayLaserPointer;
  39659. /**
  39660. * The mesh used to display where the user is going to teleport.
  39661. */
  39662. /**
  39663. * Sets the mesh to be used to display where the user is going to teleport.
  39664. */
  39665. teleportationTarget: Mesh;
  39666. /**
  39667. * 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
  39668. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39669. * See http://doc.babylonjs.com/resources/baking_transformations
  39670. */
  39671. gazeTrackerMesh: Mesh;
  39672. /**
  39673. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39674. */
  39675. updateGazeTrackerScale: boolean;
  39676. /**
  39677. * If the gaze trackers color should be updated when selecting meshes
  39678. */
  39679. updateGazeTrackerColor: boolean;
  39680. /**
  39681. * The gaze tracking mesh corresponding to the left controller
  39682. */
  39683. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39684. /**
  39685. * The gaze tracking mesh corresponding to the right controller
  39686. */
  39687. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39688. /**
  39689. * If the ray of the gaze should be displayed.
  39690. */
  39691. /**
  39692. * Sets if the ray of the gaze should be displayed.
  39693. */
  39694. displayGaze: boolean;
  39695. /**
  39696. * If the ray of the LaserPointer should be displayed.
  39697. */
  39698. /**
  39699. * Sets if the ray of the LaserPointer should be displayed.
  39700. */
  39701. displayLaserPointer: boolean;
  39702. /**
  39703. * The deviceOrientationCamera used as the camera when not in VR.
  39704. */
  39705. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39706. /**
  39707. * Based on the current WebVR support, returns the current VR camera used.
  39708. */
  39709. readonly currentVRCamera: Nullable<Camera>;
  39710. /**
  39711. * The webVRCamera which is used when in VR.
  39712. */
  39713. readonly webVRCamera: WebVRFreeCamera;
  39714. /**
  39715. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39716. */
  39717. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39718. private readonly _teleportationRequestInitiated;
  39719. /**
  39720. * Defines wether or not Pointer lock should be requested when switching to
  39721. * full screen.
  39722. */
  39723. requestPointerLockOnFullScreen: boolean;
  39724. /**
  39725. * Instantiates a VRExperienceHelper.
  39726. * Helps to quickly add VR support to an existing scene.
  39727. * @param scene The scene the VRExperienceHelper belongs to.
  39728. * @param webVROptions Options to modify the vr experience helper's behavior.
  39729. */
  39730. constructor(scene: Scene,
  39731. /** Options to modify the vr experience helper's behavior. */
  39732. webVROptions?: VRExperienceHelperOptions);
  39733. private _onDefaultMeshLoaded;
  39734. private _onResize;
  39735. private _onFullscreenChange;
  39736. /**
  39737. * Gets a value indicating if we are currently in VR mode.
  39738. */
  39739. readonly isInVRMode: boolean;
  39740. private onVrDisplayPresentChange;
  39741. private onVRDisplayChanged;
  39742. private moveButtonToBottomRight;
  39743. private displayVRButton;
  39744. private updateButtonVisibility;
  39745. private _cachedAngularSensibility;
  39746. /**
  39747. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39748. * Otherwise, will use the fullscreen API.
  39749. */
  39750. enterVR(): void;
  39751. /**
  39752. * Attempt to exit VR, or fullscreen.
  39753. */
  39754. exitVR(): void;
  39755. /**
  39756. * The position of the vr experience helper.
  39757. */
  39758. /**
  39759. * Sets the position of the vr experience helper.
  39760. */
  39761. position: Vector3;
  39762. /**
  39763. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39764. */
  39765. enableInteractions(): void;
  39766. private readonly _noControllerIsActive;
  39767. private beforeRender;
  39768. private _isTeleportationFloor;
  39769. /**
  39770. * Adds a floor mesh to be used for teleportation.
  39771. * @param floorMesh the mesh to be used for teleportation.
  39772. */
  39773. addFloorMesh(floorMesh: Mesh): void;
  39774. /**
  39775. * Removes a floor mesh from being used for teleportation.
  39776. * @param floorMesh the mesh to be removed.
  39777. */
  39778. removeFloorMesh(floorMesh: Mesh): void;
  39779. /**
  39780. * Enables interactions and teleportation using the VR controllers and gaze.
  39781. * @param vrTeleportationOptions options to modify teleportation behavior.
  39782. */
  39783. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39784. private _onNewGamepadConnected;
  39785. private _tryEnableInteractionOnController;
  39786. private _onNewGamepadDisconnected;
  39787. private _enableInteractionOnController;
  39788. private _checkTeleportWithRay;
  39789. private _checkRotate;
  39790. private _checkTeleportBackwards;
  39791. private _enableTeleportationOnController;
  39792. private _createTeleportationCircles;
  39793. private _displayTeleportationTarget;
  39794. private _hideTeleportationTarget;
  39795. private _rotateCamera;
  39796. private _moveTeleportationSelectorTo;
  39797. private _workingVector;
  39798. private _workingQuaternion;
  39799. private _workingMatrix;
  39800. /**
  39801. * Teleports the users feet to the desired location
  39802. * @param location The location where the user's feet should be placed
  39803. */
  39804. teleportCamera(location: Vector3): void;
  39805. private _convertNormalToDirectionOfRay;
  39806. private _castRayAndSelectObject;
  39807. private _notifySelectedMeshUnselected;
  39808. /**
  39809. * Sets the color of the laser ray from the vr controllers.
  39810. * @param color new color for the ray.
  39811. */
  39812. changeLaserColor(color: Color3): void;
  39813. /**
  39814. * Sets the color of the ray from the vr headsets gaze.
  39815. * @param color new color for the ray.
  39816. */
  39817. changeGazeColor(color: Color3): void;
  39818. /**
  39819. * Exits VR and disposes of the vr experience helper
  39820. */
  39821. dispose(): void;
  39822. /**
  39823. * Gets the name of the VRExperienceHelper class
  39824. * @returns "VRExperienceHelper"
  39825. */
  39826. getClassName(): string;
  39827. }
  39828. }
  39829. declare module BABYLON {
  39830. /**
  39831. * Manages an XRSession
  39832. * @see https://doc.babylonjs.com/how_to/webxr
  39833. */
  39834. export class WebXRSessionManager implements IDisposable {
  39835. private scene;
  39836. /**
  39837. * Fires every time a new xrFrame arrives which can be used to update the camera
  39838. */
  39839. onXRFrameObservable: Observable<any>;
  39840. /**
  39841. * Fires when the xr session is ended either by the device or manually done
  39842. */
  39843. onXRSessionEnded: Observable<any>;
  39844. /** @hidden */
  39845. _xrSession: XRSession;
  39846. /** @hidden */
  39847. _frameOfReference: XRFrameOfReference;
  39848. /** @hidden */
  39849. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39850. /** @hidden */
  39851. _currentXRFrame: Nullable<XRFrame>;
  39852. private _xrNavigator;
  39853. private _xrDevice;
  39854. private _tmpMatrix;
  39855. /**
  39856. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39857. * @param scene The scene which the session should be created for
  39858. */
  39859. constructor(scene: Scene);
  39860. /**
  39861. * Initializes the manager
  39862. * After initialization enterXR can be called to start an XR session
  39863. * @returns Promise which resolves after it is initialized
  39864. */
  39865. initializeAsync(): Promise<void>;
  39866. /**
  39867. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39868. * @param sessionCreationOptions xr options to create the session with
  39869. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39870. * @returns Promise which resolves after it enters XR
  39871. */
  39872. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39873. /**
  39874. * Stops the xrSession and restores the renderloop
  39875. * @returns Promise which resolves after it exits XR
  39876. */
  39877. exitXRAsync(): Promise<void>;
  39878. /**
  39879. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39880. * @param ray ray to cast into the environment
  39881. * @returns Promise which resolves with a collision point in the environment if it exists
  39882. */
  39883. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39884. /**
  39885. * Checks if a session would be supported for the creation options specified
  39886. * @param options creation options to check if they are supported
  39887. * @returns true if supported
  39888. */
  39889. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39890. /**
  39891. * @hidden
  39892. * Converts the render layer of xrSession to a render target
  39893. * @param session session to create render target for
  39894. * @param scene scene the new render target should be created for
  39895. */
  39896. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39897. /**
  39898. * Disposes of the session manager
  39899. */
  39900. dispose(): void;
  39901. }
  39902. }
  39903. declare module BABYLON {
  39904. /**
  39905. * WebXR Camera which holds the views for the xrSession
  39906. * @see https://doc.babylonjs.com/how_to/webxr
  39907. */
  39908. export class WebXRCamera extends FreeCamera {
  39909. private static _TmpMatrix;
  39910. /**
  39911. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39912. * @param name the name of the camera
  39913. * @param scene the scene to add the camera to
  39914. */
  39915. constructor(name: string, scene: Scene);
  39916. private _updateNumberOfRigCameras;
  39917. /** @hidden */
  39918. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39919. /**
  39920. * Updates the cameras position from the current pose information of the XR session
  39921. * @param xrSessionManager the session containing pose information
  39922. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39923. */
  39924. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39925. }
  39926. }
  39927. declare module BABYLON {
  39928. /**
  39929. * States of the webXR experience
  39930. */
  39931. export enum WebXRState {
  39932. /**
  39933. * Transitioning to being in XR mode
  39934. */
  39935. ENTERING_XR = 0,
  39936. /**
  39937. * Transitioning to non XR mode
  39938. */
  39939. EXITING_XR = 1,
  39940. /**
  39941. * In XR mode and presenting
  39942. */
  39943. IN_XR = 2,
  39944. /**
  39945. * Not entered XR mode
  39946. */
  39947. NOT_IN_XR = 3
  39948. }
  39949. /**
  39950. * Helper class used to enable XR
  39951. * @see https://doc.babylonjs.com/how_to/webxr
  39952. */
  39953. export class WebXRExperienceHelper implements IDisposable {
  39954. private scene;
  39955. /**
  39956. * 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
  39957. */
  39958. container: AbstractMesh;
  39959. /**
  39960. * Camera used to render xr content
  39961. */
  39962. camera: WebXRCamera;
  39963. /**
  39964. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39965. */
  39966. state: WebXRState;
  39967. private _setState;
  39968. private static _TmpVector;
  39969. /**
  39970. * Fires when the state of the experience helper has changed
  39971. */
  39972. onStateChangedObservable: Observable<WebXRState>;
  39973. /** @hidden */
  39974. _sessionManager: WebXRSessionManager;
  39975. private _nonVRCamera;
  39976. private _originalSceneAutoClear;
  39977. private _supported;
  39978. /**
  39979. * Creates the experience helper
  39980. * @param scene the scene to attach the experience helper to
  39981. * @returns a promise for the experience helper
  39982. */
  39983. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39984. /**
  39985. * Creates a WebXRExperienceHelper
  39986. * @param scene The scene the helper should be created in
  39987. */
  39988. private constructor();
  39989. /**
  39990. * Exits XR mode and returns the scene to its original state
  39991. * @returns promise that resolves after xr mode has exited
  39992. */
  39993. exitXRAsync(): Promise<void>;
  39994. /**
  39995. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39996. * @param sessionCreationOptions options for the XR session
  39997. * @param frameOfReference frame of reference of the XR session
  39998. * @returns promise that resolves after xr mode has entered
  39999. */
  40000. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40001. /**
  40002. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40003. * @param ray ray to cast into the environment
  40004. * @returns Promise which resolves with a collision point in the environment if it exists
  40005. */
  40006. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40007. /**
  40008. * Updates the global position of the camera by moving the camera's container
  40009. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40010. * @param position The desired global position of the camera
  40011. */
  40012. setPositionOfCameraUsingContainer(position: Vector3): void;
  40013. /**
  40014. * Rotates the xr camera by rotating the camera's container around the camera's position
  40015. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40016. * @param rotation the desired quaternion rotation to apply to the camera
  40017. */
  40018. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40019. /**
  40020. * Checks if the creation options are supported by the xr session
  40021. * @param options creation options
  40022. * @returns true if supported
  40023. */
  40024. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40025. /**
  40026. * Disposes of the experience helper
  40027. */
  40028. dispose(): void;
  40029. }
  40030. }
  40031. declare module BABYLON {
  40032. /**
  40033. * Button which can be used to enter a different mode of XR
  40034. */
  40035. export class WebXREnterExitUIButton {
  40036. /** button element */
  40037. element: HTMLElement;
  40038. /** XR initialization options for the button */
  40039. initializationOptions: XRSessionCreationOptions;
  40040. /**
  40041. * Creates a WebXREnterExitUIButton
  40042. * @param element button element
  40043. * @param initializationOptions XR initialization options for the button
  40044. */
  40045. constructor(
  40046. /** button element */
  40047. element: HTMLElement,
  40048. /** XR initialization options for the button */
  40049. initializationOptions: XRSessionCreationOptions);
  40050. /**
  40051. * Overwritable function which can be used to update the button's visuals when the state changes
  40052. * @param activeButton the current active button in the UI
  40053. */
  40054. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40055. }
  40056. /**
  40057. * Options to create the webXR UI
  40058. */
  40059. export class WebXREnterExitUIOptions {
  40060. /**
  40061. * Context to enter xr with
  40062. */
  40063. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40064. /**
  40065. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40066. */
  40067. customButtons?: Array<WebXREnterExitUIButton>;
  40068. }
  40069. /**
  40070. * UI to allow the user to enter/exit XR mode
  40071. */
  40072. export class WebXREnterExitUI implements IDisposable {
  40073. private scene;
  40074. private _overlay;
  40075. private _buttons;
  40076. private _activeButton;
  40077. /**
  40078. * Fired every time the active button is changed.
  40079. *
  40080. * When xr is entered via a button that launches xr that button will be the callback parameter
  40081. *
  40082. * When exiting xr the callback parameter will be null)
  40083. */
  40084. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40085. /**
  40086. * Creates UI to allow the user to enter/exit XR mode
  40087. * @param scene the scene to add the ui to
  40088. * @param helper the xr experience helper to enter/exit xr with
  40089. * @param options options to configure the UI
  40090. * @returns the created ui
  40091. */
  40092. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40093. private constructor();
  40094. private _updateButtons;
  40095. /**
  40096. * Disposes of the object
  40097. */
  40098. dispose(): void;
  40099. }
  40100. }
  40101. declare module BABYLON {
  40102. /**
  40103. * Represents an XR input
  40104. */
  40105. export class WebXRController {
  40106. /**
  40107. * 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
  40108. */
  40109. grip?: AbstractMesh;
  40110. /**
  40111. * Pointer which can be used to select objects or attach a visible laser to
  40112. */
  40113. pointer: AbstractMesh;
  40114. /**
  40115. * Creates the controller
  40116. * @see https://doc.babylonjs.com/how_to/webxr
  40117. * @param scene the scene which the controller should be associated to
  40118. */
  40119. constructor(scene: Scene);
  40120. /**
  40121. * Disposes of the object
  40122. */
  40123. dispose(): void;
  40124. }
  40125. /**
  40126. * XR input used to track XR inputs such as controllers/rays
  40127. */
  40128. export class WebXRInput implements IDisposable {
  40129. private helper;
  40130. /**
  40131. * XR controllers being tracked
  40132. */
  40133. controllers: Array<WebXRController>;
  40134. private _tmpMatrix;
  40135. private _frameObserver;
  40136. /**
  40137. * Initializes the WebXRInput
  40138. * @param helper experience helper which the input should be created for
  40139. */
  40140. constructor(helper: WebXRExperienceHelper);
  40141. /**
  40142. * Disposes of the object
  40143. */
  40144. dispose(): void;
  40145. }
  40146. }
  40147. declare module BABYLON {
  40148. /**
  40149. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40150. */
  40151. export class WebXRManagedOutputCanvas implements IDisposable {
  40152. private _canvas;
  40153. /**
  40154. * xrpresent context of the canvas which can be used to display/mirror xr content
  40155. */
  40156. canvasContext: Nullable<WebGLRenderingContext>;
  40157. /**
  40158. * Initializes the canvas to be added/removed upon entering/exiting xr
  40159. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40160. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40161. */
  40162. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40163. /**
  40164. * Disposes of the object
  40165. */
  40166. dispose(): void;
  40167. private _setManagedOutputCanvas;
  40168. private _addCanvas;
  40169. private _removeCanvas;
  40170. }
  40171. }
  40172. declare module BABYLON {
  40173. /**
  40174. * Contains an array of blocks representing the octree
  40175. */
  40176. export interface IOctreeContainer<T> {
  40177. /**
  40178. * Blocks within the octree
  40179. */
  40180. blocks: Array<OctreeBlock<T>>;
  40181. }
  40182. /**
  40183. * Class used to store a cell in an octree
  40184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40185. */
  40186. export class OctreeBlock<T> {
  40187. /**
  40188. * Gets the content of the current block
  40189. */
  40190. entries: T[];
  40191. /**
  40192. * Gets the list of block children
  40193. */
  40194. blocks: Array<OctreeBlock<T>>;
  40195. private _depth;
  40196. private _maxDepth;
  40197. private _capacity;
  40198. private _minPoint;
  40199. private _maxPoint;
  40200. private _boundingVectors;
  40201. private _creationFunc;
  40202. /**
  40203. * Creates a new block
  40204. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40205. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40206. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40207. * @param depth defines the current depth of this block in the octree
  40208. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40209. * @param creationFunc defines a callback to call when an element is added to the block
  40210. */
  40211. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40212. /**
  40213. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40214. */
  40215. readonly capacity: number;
  40216. /**
  40217. * Gets the minimum vector (in world space) of the block's bounding box
  40218. */
  40219. readonly minPoint: Vector3;
  40220. /**
  40221. * Gets the maximum vector (in world space) of the block's bounding box
  40222. */
  40223. readonly maxPoint: Vector3;
  40224. /**
  40225. * Add a new element to this block
  40226. * @param entry defines the element to add
  40227. */
  40228. addEntry(entry: T): void;
  40229. /**
  40230. * Remove an element from this block
  40231. * @param entry defines the element to remove
  40232. */
  40233. removeEntry(entry: T): void;
  40234. /**
  40235. * Add an array of elements to this block
  40236. * @param entries defines the array of elements to add
  40237. */
  40238. addEntries(entries: T[]): void;
  40239. /**
  40240. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40241. * @param frustumPlanes defines the frustum planes to test
  40242. * @param selection defines the array to store current content if selection is positive
  40243. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40244. */
  40245. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40246. /**
  40247. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40248. * @param sphereCenter defines the bounding sphere center
  40249. * @param sphereRadius defines the bounding sphere radius
  40250. * @param selection defines the array to store current content if selection is positive
  40251. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40252. */
  40253. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40254. /**
  40255. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40256. * @param ray defines the ray to test with
  40257. * @param selection defines the array to store current content if selection is positive
  40258. */
  40259. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40260. /**
  40261. * Subdivide the content into child blocks (this block will then be empty)
  40262. */
  40263. createInnerBlocks(): void;
  40264. /**
  40265. * @hidden
  40266. */
  40267. 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;
  40268. }
  40269. }
  40270. declare module BABYLON {
  40271. /**
  40272. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40274. */
  40275. export class Octree<T> {
  40276. /** 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.) */
  40277. maxDepth: number;
  40278. /**
  40279. * Blocks within the octree containing objects
  40280. */
  40281. blocks: Array<OctreeBlock<T>>;
  40282. /**
  40283. * Content stored in the octree
  40284. */
  40285. dynamicContent: T[];
  40286. private _maxBlockCapacity;
  40287. private _selectionContent;
  40288. private _creationFunc;
  40289. /**
  40290. * Creates a octree
  40291. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40292. * @param creationFunc function to be used to instatiate the octree
  40293. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40294. * @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.)
  40295. */
  40296. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40297. /** 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.) */
  40298. maxDepth?: number);
  40299. /**
  40300. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40301. * @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);
  40302. * @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);
  40303. * @param entries meshes to be added to the octree blocks
  40304. */
  40305. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40306. /**
  40307. * Adds a mesh to the octree
  40308. * @param entry Mesh to add to the octree
  40309. */
  40310. addMesh(entry: T): void;
  40311. /**
  40312. * Remove an element from the octree
  40313. * @param entry defines the element to remove
  40314. */
  40315. removeMesh(entry: T): void;
  40316. /**
  40317. * Selects an array of meshes within the frustum
  40318. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40319. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40320. * @returns array of meshes within the frustum
  40321. */
  40322. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40323. /**
  40324. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40325. * @param sphereCenter defines the bounding sphere center
  40326. * @param sphereRadius defines the bounding sphere radius
  40327. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40328. * @returns an array of objects that intersect the sphere
  40329. */
  40330. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40331. /**
  40332. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40333. * @param ray defines the ray to test with
  40334. * @returns array of intersected objects
  40335. */
  40336. intersectsRay(ray: Ray): SmartArray<T>;
  40337. /**
  40338. * Adds a mesh into the octree block if it intersects the block
  40339. */
  40340. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40341. /**
  40342. * Adds a submesh into the octree block if it intersects the block
  40343. */
  40344. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40345. }
  40346. }
  40347. declare module BABYLON {
  40348. interface Scene {
  40349. /**
  40350. * @hidden
  40351. * Backing Filed
  40352. */
  40353. _selectionOctree: Octree<AbstractMesh>;
  40354. /**
  40355. * Gets the octree used to boost mesh selection (picking)
  40356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40357. */
  40358. selectionOctree: Octree<AbstractMesh>;
  40359. /**
  40360. * Creates or updates the octree used to boost selection (picking)
  40361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40362. * @param maxCapacity defines the maximum capacity per leaf
  40363. * @param maxDepth defines the maximum depth of the octree
  40364. * @returns an octree of AbstractMesh
  40365. */
  40366. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40367. }
  40368. interface AbstractMesh {
  40369. /**
  40370. * @hidden
  40371. * Backing Field
  40372. */
  40373. _submeshesOctree: Octree<SubMesh>;
  40374. /**
  40375. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40376. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40377. * @param maxCapacity defines the maximum size of each block (64 by default)
  40378. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40379. * @returns the new octree
  40380. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40382. */
  40383. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40384. }
  40385. /**
  40386. * Defines the octree scene component responsible to manage any octrees
  40387. * in a given scene.
  40388. */
  40389. export class OctreeSceneComponent {
  40390. /**
  40391. * The component name helpfull to identify the component in the list of scene components.
  40392. */
  40393. readonly name: string;
  40394. /**
  40395. * The scene the component belongs to.
  40396. */
  40397. scene: Scene;
  40398. /**
  40399. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40400. */
  40401. readonly checksIsEnabled: boolean;
  40402. /**
  40403. * Creates a new instance of the component for the given scene
  40404. * @param scene Defines the scene to register the component in
  40405. */
  40406. constructor(scene: Scene);
  40407. /**
  40408. * Registers the component in a given scene
  40409. */
  40410. register(): void;
  40411. /**
  40412. * Return the list of active meshes
  40413. * @returns the list of active meshes
  40414. */
  40415. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40416. /**
  40417. * Return the list of active sub meshes
  40418. * @param mesh The mesh to get the candidates sub meshes from
  40419. * @returns the list of active sub meshes
  40420. */
  40421. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40422. private _tempRay;
  40423. /**
  40424. * Return the list of sub meshes intersecting with a given local ray
  40425. * @param mesh defines the mesh to find the submesh for
  40426. * @param localRay defines the ray in local space
  40427. * @returns the list of intersecting sub meshes
  40428. */
  40429. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40430. /**
  40431. * Return the list of sub meshes colliding with a collider
  40432. * @param mesh defines the mesh to find the submesh for
  40433. * @param collider defines the collider to evaluate the collision against
  40434. * @returns the list of colliding sub meshes
  40435. */
  40436. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40437. /**
  40438. * Rebuilds the elements related to this component in case of
  40439. * context lost for instance.
  40440. */
  40441. rebuild(): void;
  40442. /**
  40443. * Disposes the component and the associated ressources.
  40444. */
  40445. dispose(): void;
  40446. }
  40447. }
  40448. declare module BABYLON {
  40449. /**
  40450. * Renders a layer on top of an existing scene
  40451. */
  40452. export class UtilityLayerRenderer implements IDisposable {
  40453. /** the original scene that will be rendered on top of */
  40454. originalScene: Scene;
  40455. private _pointerCaptures;
  40456. private _lastPointerEvents;
  40457. private static _DefaultUtilityLayer;
  40458. private static _DefaultKeepDepthUtilityLayer;
  40459. private _sharedGizmoLight;
  40460. /**
  40461. * @hidden
  40462. * Light which used by gizmos to get light shading
  40463. */
  40464. _getSharedGizmoLight(): HemisphericLight;
  40465. /**
  40466. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40467. */
  40468. pickUtilitySceneFirst: boolean;
  40469. /**
  40470. * 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)
  40471. */
  40472. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40473. /**
  40474. * 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)
  40475. */
  40476. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40477. /**
  40478. * The scene that is rendered on top of the original scene
  40479. */
  40480. utilityLayerScene: Scene;
  40481. /**
  40482. * If the utility layer should automatically be rendered on top of existing scene
  40483. */
  40484. shouldRender: boolean;
  40485. /**
  40486. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40487. */
  40488. onlyCheckPointerDownEvents: boolean;
  40489. /**
  40490. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40491. */
  40492. processAllEvents: boolean;
  40493. /**
  40494. * Observable raised when the pointer move from the utility layer scene to the main scene
  40495. */
  40496. onPointerOutObservable: Observable<number>;
  40497. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40498. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40499. private _afterRenderObserver;
  40500. private _sceneDisposeObserver;
  40501. private _originalPointerObserver;
  40502. /**
  40503. * Instantiates a UtilityLayerRenderer
  40504. * @param originalScene the original scene that will be rendered on top of
  40505. * @param handleEvents boolean indicating if the utility layer should handle events
  40506. */
  40507. constructor(
  40508. /** the original scene that will be rendered on top of */
  40509. originalScene: Scene, handleEvents?: boolean);
  40510. private _notifyObservers;
  40511. /**
  40512. * Renders the utility layers scene on top of the original scene
  40513. */
  40514. render(): void;
  40515. /**
  40516. * Disposes of the renderer
  40517. */
  40518. dispose(): void;
  40519. private _updateCamera;
  40520. }
  40521. }
  40522. declare module BABYLON {
  40523. /**
  40524. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40525. */
  40526. export class Gizmo implements IDisposable {
  40527. /** The utility layer the gizmo will be added to */
  40528. gizmoLayer: UtilityLayerRenderer;
  40529. /**
  40530. * The root mesh of the gizmo
  40531. */
  40532. _rootMesh: Mesh;
  40533. private _attachedMesh;
  40534. /**
  40535. * Ratio for the scale of the gizmo (Default: 1)
  40536. */
  40537. scaleRatio: number;
  40538. /**
  40539. * If a custom mesh has been set (Default: false)
  40540. */
  40541. protected _customMeshSet: boolean;
  40542. /**
  40543. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40544. * * When set, interactions will be enabled
  40545. */
  40546. attachedMesh: Nullable<AbstractMesh>;
  40547. /**
  40548. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40549. * @param mesh The mesh to replace the default mesh of the gizmo
  40550. */
  40551. setCustomMesh(mesh: Mesh): void;
  40552. /**
  40553. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40554. */
  40555. updateGizmoRotationToMatchAttachedMesh: boolean;
  40556. /**
  40557. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40558. */
  40559. updateGizmoPositionToMatchAttachedMesh: boolean;
  40560. /**
  40561. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40562. */
  40563. protected _updateScale: boolean;
  40564. protected _interactionsEnabled: boolean;
  40565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40566. private _beforeRenderObserver;
  40567. private _tempVector;
  40568. /**
  40569. * Creates a gizmo
  40570. * @param gizmoLayer The utility layer the gizmo will be added to
  40571. */
  40572. constructor(
  40573. /** The utility layer the gizmo will be added to */
  40574. gizmoLayer?: UtilityLayerRenderer);
  40575. /**
  40576. * Updates the gizmo to match the attached mesh's position/rotation
  40577. */
  40578. protected _update(): void;
  40579. /**
  40580. * Disposes of the gizmo
  40581. */
  40582. dispose(): void;
  40583. }
  40584. }
  40585. declare module BABYLON {
  40586. /**
  40587. * Single axis drag gizmo
  40588. */
  40589. export class AxisDragGizmo extends Gizmo {
  40590. /**
  40591. * Drag behavior responsible for the gizmos dragging interactions
  40592. */
  40593. dragBehavior: PointerDragBehavior;
  40594. private _pointerObserver;
  40595. /**
  40596. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40597. */
  40598. snapDistance: number;
  40599. /**
  40600. * Event that fires each time the gizmo snaps to a new location.
  40601. * * snapDistance is the the change in distance
  40602. */
  40603. onSnapObservable: Observable<{
  40604. snapDistance: number;
  40605. }>;
  40606. /** @hidden */
  40607. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40608. /** @hidden */
  40609. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40610. /**
  40611. * Creates an AxisDragGizmo
  40612. * @param gizmoLayer The utility layer the gizmo will be added to
  40613. * @param dragAxis The axis which the gizmo will be able to drag on
  40614. * @param color The color of the gizmo
  40615. */
  40616. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40617. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40618. /**
  40619. * Disposes of the gizmo
  40620. */
  40621. dispose(): void;
  40622. }
  40623. }
  40624. declare module BABYLON.Debug {
  40625. /**
  40626. * The Axes viewer will show 3 axes in a specific point in space
  40627. */
  40628. export class AxesViewer {
  40629. private _xAxis;
  40630. private _yAxis;
  40631. private _zAxis;
  40632. private _scaleLinesFactor;
  40633. private _instanced;
  40634. /**
  40635. * Gets the hosting scene
  40636. */
  40637. scene: Scene;
  40638. /**
  40639. * Gets or sets a number used to scale line length
  40640. */
  40641. scaleLines: number;
  40642. /** Gets the node hierarchy used to render x-axis */
  40643. readonly xAxis: TransformNode;
  40644. /** Gets the node hierarchy used to render y-axis */
  40645. readonly yAxis: TransformNode;
  40646. /** Gets the node hierarchy used to render z-axis */
  40647. readonly zAxis: TransformNode;
  40648. /**
  40649. * Creates a new AxesViewer
  40650. * @param scene defines the hosting scene
  40651. * @param scaleLines defines a number used to scale line length (1 by default)
  40652. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40653. * @param xAxis defines the node hierarchy used to render the x-axis
  40654. * @param yAxis defines the node hierarchy used to render the y-axis
  40655. * @param zAxis defines the node hierarchy used to render the z-axis
  40656. */
  40657. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40658. /**
  40659. * Force the viewer to update
  40660. * @param position defines the position of the viewer
  40661. * @param xaxis defines the x axis of the viewer
  40662. * @param yaxis defines the y axis of the viewer
  40663. * @param zaxis defines the z axis of the viewer
  40664. */
  40665. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40666. /**
  40667. * Creates an instance of this axes viewer.
  40668. * @returns a new axes viewer with instanced meshes
  40669. */
  40670. createInstance(): AxesViewer;
  40671. /** Releases resources */
  40672. dispose(): void;
  40673. private static _SetRenderingGroupId;
  40674. }
  40675. }
  40676. declare module BABYLON.Debug {
  40677. /**
  40678. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40679. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40680. */
  40681. export class BoneAxesViewer extends AxesViewer {
  40682. /**
  40683. * Gets or sets the target mesh where to display the axes viewer
  40684. */
  40685. mesh: Nullable<Mesh>;
  40686. /**
  40687. * Gets or sets the target bone where to display the axes viewer
  40688. */
  40689. bone: Nullable<Bone>;
  40690. /** Gets current position */
  40691. pos: Vector3;
  40692. /** Gets direction of X axis */
  40693. xaxis: Vector3;
  40694. /** Gets direction of Y axis */
  40695. yaxis: Vector3;
  40696. /** Gets direction of Z axis */
  40697. zaxis: Vector3;
  40698. /**
  40699. * Creates a new BoneAxesViewer
  40700. * @param scene defines the hosting scene
  40701. * @param bone defines the target bone
  40702. * @param mesh defines the target mesh
  40703. * @param scaleLines defines a scaling factor for line length (1 by default)
  40704. */
  40705. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40706. /**
  40707. * Force the viewer to update
  40708. */
  40709. update(): void;
  40710. /** Releases resources */
  40711. dispose(): void;
  40712. }
  40713. }
  40714. declare module BABYLON {
  40715. /**
  40716. * Interface used to define scene explorer extensibility option
  40717. */
  40718. export interface IExplorerExtensibilityOption {
  40719. /**
  40720. * Define the option label
  40721. */
  40722. label: string;
  40723. /**
  40724. * Defines the action to execute on click
  40725. */
  40726. action: (entity: any) => void;
  40727. }
  40728. /**
  40729. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40730. */
  40731. export interface IExplorerExtensibilityGroup {
  40732. /**
  40733. * Defines a predicate to test if a given type mut be extended
  40734. */
  40735. predicate: (entity: any) => boolean;
  40736. /**
  40737. * Gets the list of options added to a type
  40738. */
  40739. entries: IExplorerExtensibilityOption[];
  40740. }
  40741. /**
  40742. * Interface used to define the options to use to create the Inspector
  40743. */
  40744. export interface IInspectorOptions {
  40745. /**
  40746. * Display in overlay mode (default: false)
  40747. */
  40748. overlay?: boolean;
  40749. /**
  40750. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40751. */
  40752. globalRoot?: HTMLElement;
  40753. /**
  40754. * Display the Scene explorer
  40755. */
  40756. showExplorer?: boolean;
  40757. /**
  40758. * Display the property inspector
  40759. */
  40760. showInspector?: boolean;
  40761. /**
  40762. * Display in embed mode (both panes on the right)
  40763. */
  40764. embedMode?: boolean;
  40765. /**
  40766. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40767. */
  40768. handleResize?: boolean;
  40769. /**
  40770. * Allow the panes to popup (default: true)
  40771. */
  40772. enablePopup?: boolean;
  40773. /**
  40774. * Allow the panes to be closed by users (default: true)
  40775. */
  40776. enableClose?: boolean;
  40777. /**
  40778. * Optional list of extensibility entries
  40779. */
  40780. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40781. /**
  40782. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40783. */
  40784. inspectorURL?: string;
  40785. }
  40786. interface Scene {
  40787. /**
  40788. * @hidden
  40789. * Backing field
  40790. */
  40791. _debugLayer: DebugLayer;
  40792. /**
  40793. * Gets the debug layer (aka Inspector) associated with the scene
  40794. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40795. */
  40796. debugLayer: DebugLayer;
  40797. }
  40798. /**
  40799. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40800. * what is happening in your scene
  40801. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40802. */
  40803. export class DebugLayer {
  40804. /**
  40805. * Define the url to get the inspector script from.
  40806. * By default it uses the babylonjs CDN.
  40807. * @ignoreNaming
  40808. */
  40809. static InspectorURL: string;
  40810. private _scene;
  40811. private BJSINSPECTOR;
  40812. /**
  40813. * Observable triggered when a property is changed through the inspector.
  40814. */
  40815. onPropertyChangedObservable: Observable<{
  40816. object: any;
  40817. property: string;
  40818. value: any;
  40819. initialValue: any;
  40820. }>;
  40821. /**
  40822. * Instantiates a new debug layer.
  40823. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40824. * what is happening in your scene
  40825. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40826. * @param scene Defines the scene to inspect
  40827. */
  40828. constructor(scene: Scene);
  40829. /** Creates the inspector window. */
  40830. private _createInspector;
  40831. /**
  40832. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40833. * @param entity defines the entity to select
  40834. * @param lineContainerTitle defines the specific block to highlight
  40835. */
  40836. select(entity: any, lineContainerTitle?: string): void;
  40837. /** Get the inspector from bundle or global */
  40838. private _getGlobalInspector;
  40839. /**
  40840. * Get if the inspector is visible or not.
  40841. * @returns true if visible otherwise, false
  40842. */
  40843. isVisible(): boolean;
  40844. /**
  40845. * Hide the inspector and close its window.
  40846. */
  40847. hide(): void;
  40848. /**
  40849. * Launch the debugLayer.
  40850. * @param config Define the configuration of the inspector
  40851. * @return a promise fulfilled when the debug layer is visible
  40852. */
  40853. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40854. }
  40855. }
  40856. declare module BABYLON {
  40857. /**
  40858. * Class containing static functions to help procedurally build meshes
  40859. */
  40860. export class BoxBuilder {
  40861. /**
  40862. * Creates a box mesh
  40863. * * The parameter `size` sets the size (float) of each box side (default 1)
  40864. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40865. * * 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)
  40866. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40868. * * 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
  40869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40870. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40871. * @param name defines the name of the mesh
  40872. * @param options defines the options used to create the mesh
  40873. * @param scene defines the hosting scene
  40874. * @returns the box mesh
  40875. */
  40876. static CreateBox(name: string, options: {
  40877. size?: number;
  40878. width?: number;
  40879. height?: number;
  40880. depth?: number;
  40881. faceUV?: Vector4[];
  40882. faceColors?: Color4[];
  40883. sideOrientation?: number;
  40884. frontUVs?: Vector4;
  40885. backUVs?: Vector4;
  40886. wrap?: boolean;
  40887. topBaseAt?: number;
  40888. bottomBaseAt?: number;
  40889. updatable?: boolean;
  40890. }, scene?: Nullable<Scene>): Mesh;
  40891. }
  40892. }
  40893. declare module BABYLON {
  40894. /**
  40895. * Class containing static functions to help procedurally build meshes
  40896. */
  40897. export class SphereBuilder {
  40898. /**
  40899. * Creates a sphere mesh
  40900. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40901. * * 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`)
  40902. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40903. * * 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
  40904. * * 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)
  40905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40906. * * 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
  40907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40908. * @param name defines the name of the mesh
  40909. * @param options defines the options used to create the mesh
  40910. * @param scene defines the hosting scene
  40911. * @returns the sphere mesh
  40912. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40913. */
  40914. static CreateSphere(name: string, options: {
  40915. segments?: number;
  40916. diameter?: number;
  40917. diameterX?: number;
  40918. diameterY?: number;
  40919. diameterZ?: number;
  40920. arc?: number;
  40921. slice?: number;
  40922. sideOrientation?: number;
  40923. frontUVs?: Vector4;
  40924. backUVs?: Vector4;
  40925. updatable?: boolean;
  40926. }, scene: any): Mesh;
  40927. }
  40928. }
  40929. declare module BABYLON.Debug {
  40930. /**
  40931. * Used to show the physics impostor around the specific mesh
  40932. */
  40933. export class PhysicsViewer {
  40934. /** @hidden */
  40935. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40936. /** @hidden */
  40937. protected _meshes: Array<Nullable<AbstractMesh>>;
  40938. /** @hidden */
  40939. protected _scene: Nullable<Scene>;
  40940. /** @hidden */
  40941. protected _numMeshes: number;
  40942. /** @hidden */
  40943. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40944. private _renderFunction;
  40945. private _utilityLayer;
  40946. private _debugBoxMesh;
  40947. private _debugSphereMesh;
  40948. private _debugCylinderMesh;
  40949. private _debugMaterial;
  40950. private _debugMeshMeshes;
  40951. /**
  40952. * Creates a new PhysicsViewer
  40953. * @param scene defines the hosting scene
  40954. */
  40955. constructor(scene: Scene);
  40956. /** @hidden */
  40957. protected _updateDebugMeshes(): void;
  40958. /**
  40959. * Renders a specified physic impostor
  40960. * @param impostor defines the impostor to render
  40961. * @param targetMesh defines the mesh represented by the impostor
  40962. * @returns the new debug mesh used to render the impostor
  40963. */
  40964. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40965. /**
  40966. * Hides a specified physic impostor
  40967. * @param impostor defines the impostor to hide
  40968. */
  40969. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40970. private _getDebugMaterial;
  40971. private _getDebugBoxMesh;
  40972. private _getDebugSphereMesh;
  40973. private _getDebugCylinderMesh;
  40974. private _getDebugMeshMesh;
  40975. private _getDebugMesh;
  40976. /** Releases all resources */
  40977. dispose(): void;
  40978. }
  40979. }
  40980. declare module BABYLON {
  40981. /**
  40982. * Class containing static functions to help procedurally build meshes
  40983. */
  40984. export class LinesBuilder {
  40985. /**
  40986. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40987. * * 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
  40988. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40989. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40990. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40991. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40992. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40993. * * 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
  40994. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40997. * @param name defines the name of the new line system
  40998. * @param options defines the options used to create the line system
  40999. * @param scene defines the hosting scene
  41000. * @returns a new line system mesh
  41001. */
  41002. static CreateLineSystem(name: string, options: {
  41003. lines: Vector3[][];
  41004. updatable?: boolean;
  41005. instance?: Nullable<LinesMesh>;
  41006. colors?: Nullable<Color4[][]>;
  41007. useVertexAlpha?: boolean;
  41008. }, scene: Nullable<Scene>): LinesMesh;
  41009. /**
  41010. * Creates a line mesh
  41011. * 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
  41012. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41013. * * The parameter `points` is an array successive Vector3
  41014. * * 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
  41015. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41016. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41017. * * When updating an instance, remember that only point positions can change, not the number of points
  41018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41020. * @param name defines the name of the new line system
  41021. * @param options defines the options used to create the line system
  41022. * @param scene defines the hosting scene
  41023. * @returns a new line mesh
  41024. */
  41025. static CreateLines(name: string, options: {
  41026. points: Vector3[];
  41027. updatable?: boolean;
  41028. instance?: Nullable<LinesMesh>;
  41029. colors?: Color4[];
  41030. useVertexAlpha?: boolean;
  41031. }, scene?: Nullable<Scene>): LinesMesh;
  41032. /**
  41033. * Creates a dashed line mesh
  41034. * * 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
  41035. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41036. * * The parameter `points` is an array successive Vector3
  41037. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41038. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41039. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41040. * * 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
  41041. * * When updating an instance, remember that only point positions can change, not the number of points
  41042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41043. * @param name defines the name of the mesh
  41044. * @param options defines the options used to create the mesh
  41045. * @param scene defines the hosting scene
  41046. * @returns the dashed line mesh
  41047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41048. */
  41049. static CreateDashedLines(name: string, options: {
  41050. points: Vector3[];
  41051. dashSize?: number;
  41052. gapSize?: number;
  41053. dashNb?: number;
  41054. updatable?: boolean;
  41055. instance?: LinesMesh;
  41056. }, scene?: Nullable<Scene>): LinesMesh;
  41057. }
  41058. }
  41059. declare module BABYLON {
  41060. /**
  41061. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41062. * in order to better appreciate the issue one might have.
  41063. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41064. */
  41065. export class RayHelper {
  41066. /**
  41067. * Defines the ray we are currently tryin to visualize.
  41068. */
  41069. ray: Nullable<Ray>;
  41070. private _renderPoints;
  41071. private _renderLine;
  41072. private _renderFunction;
  41073. private _scene;
  41074. private _updateToMeshFunction;
  41075. private _attachedToMesh;
  41076. private _meshSpaceDirection;
  41077. private _meshSpaceOrigin;
  41078. /**
  41079. * Helper function to create a colored helper in a scene in one line.
  41080. * @param ray Defines the ray we are currently tryin to visualize
  41081. * @param scene Defines the scene the ray is used in
  41082. * @param color Defines the color we want to see the ray in
  41083. * @returns The newly created ray helper.
  41084. */
  41085. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41086. /**
  41087. * Instantiate a new ray helper.
  41088. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41089. * in order to better appreciate the issue one might have.
  41090. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41091. * @param ray Defines the ray we are currently tryin to visualize
  41092. */
  41093. constructor(ray: Ray);
  41094. /**
  41095. * Shows the ray we are willing to debug.
  41096. * @param scene Defines the scene the ray needs to be rendered in
  41097. * @param color Defines the color the ray needs to be rendered in
  41098. */
  41099. show(scene: Scene, color?: Color3): void;
  41100. /**
  41101. * Hides the ray we are debugging.
  41102. */
  41103. hide(): void;
  41104. private _render;
  41105. /**
  41106. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41107. * @param mesh Defines the mesh we want the helper attached to
  41108. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41109. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41110. * @param length Defines the length of the ray
  41111. */
  41112. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41113. /**
  41114. * Detach the ray helper from the mesh it has previously been attached to.
  41115. */
  41116. detachFromMesh(): void;
  41117. private _updateToMesh;
  41118. /**
  41119. * Dispose the helper and release its associated resources.
  41120. */
  41121. dispose(): void;
  41122. }
  41123. }
  41124. declare module BABYLON.Debug {
  41125. /**
  41126. * Class used to render a debug view of a given skeleton
  41127. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41128. */
  41129. export class SkeletonViewer {
  41130. /** defines the skeleton to render */
  41131. skeleton: Skeleton;
  41132. /** defines the mesh attached to the skeleton */
  41133. mesh: AbstractMesh;
  41134. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41135. autoUpdateBonesMatrices: boolean;
  41136. /** defines the rendering group id to use with the viewer */
  41137. renderingGroupId: number;
  41138. /** Gets or sets the color used to render the skeleton */
  41139. color: Color3;
  41140. private _scene;
  41141. private _debugLines;
  41142. private _debugMesh;
  41143. private _isEnabled;
  41144. private _renderFunction;
  41145. private _utilityLayer;
  41146. /**
  41147. * Returns the mesh used to render the bones
  41148. */
  41149. readonly debugMesh: Nullable<LinesMesh>;
  41150. /**
  41151. * Creates a new SkeletonViewer
  41152. * @param skeleton defines the skeleton to render
  41153. * @param mesh defines the mesh attached to the skeleton
  41154. * @param scene defines the hosting scene
  41155. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41156. * @param renderingGroupId defines the rendering group id to use with the viewer
  41157. */
  41158. constructor(
  41159. /** defines the skeleton to render */
  41160. skeleton: Skeleton,
  41161. /** defines the mesh attached to the skeleton */
  41162. mesh: AbstractMesh, scene: Scene,
  41163. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41164. autoUpdateBonesMatrices?: boolean,
  41165. /** defines the rendering group id to use with the viewer */
  41166. renderingGroupId?: number);
  41167. /** Gets or sets a boolean indicating if the viewer is enabled */
  41168. isEnabled: boolean;
  41169. private _getBonePosition;
  41170. private _getLinesForBonesWithLength;
  41171. private _getLinesForBonesNoLength;
  41172. /** Update the viewer to sync with current skeleton state */
  41173. update(): void;
  41174. /** Release associated resources */
  41175. dispose(): void;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * Options to create the null engine
  41181. */
  41182. export class NullEngineOptions {
  41183. /**
  41184. * Render width (Default: 512)
  41185. */
  41186. renderWidth: number;
  41187. /**
  41188. * Render height (Default: 256)
  41189. */
  41190. renderHeight: number;
  41191. /**
  41192. * Texture size (Default: 512)
  41193. */
  41194. textureSize: number;
  41195. /**
  41196. * If delta time between frames should be constant
  41197. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41198. */
  41199. deterministicLockstep: boolean;
  41200. /**
  41201. * Maximum about of steps between frames (Default: 4)
  41202. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41203. */
  41204. lockstepMaxSteps: number;
  41205. }
  41206. /**
  41207. * The null engine class provides support for headless version of babylon.js.
  41208. * This can be used in server side scenario or for testing purposes
  41209. */
  41210. export class NullEngine extends Engine {
  41211. private _options;
  41212. /**
  41213. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41214. */
  41215. isDeterministicLockStep(): boolean;
  41216. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41217. getLockstepMaxSteps(): number;
  41218. /**
  41219. * Sets hardware scaling, used to save performance if needed
  41220. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41221. */
  41222. getHardwareScalingLevel(): number;
  41223. constructor(options?: NullEngineOptions);
  41224. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41225. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41226. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41227. getRenderWidth(useScreen?: boolean): number;
  41228. getRenderHeight(useScreen?: boolean): number;
  41229. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41230. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41231. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41232. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41233. bindSamplers(effect: Effect): void;
  41234. enableEffect(effect: Effect): void;
  41235. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41237. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41238. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41239. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41240. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41241. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41242. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41243. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41244. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41245. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41246. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41247. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41248. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41249. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41250. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41251. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41252. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41253. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41254. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41255. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41256. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41257. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41258. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41259. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41260. bindBuffers(vertexBuffers: {
  41261. [key: string]: VertexBuffer;
  41262. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41263. wipeCaches(bruteForce?: boolean): void;
  41264. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41265. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41267. /** @hidden */
  41268. _createTexture(): WebGLTexture;
  41269. /** @hidden */
  41270. _releaseTexture(texture: InternalTexture): void;
  41271. 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;
  41272. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41273. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41274. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41275. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41276. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41278. areAllEffectsReady(): boolean;
  41279. /**
  41280. * @hidden
  41281. * Get the current error code of the webGL context
  41282. * @returns the error code
  41283. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41284. */
  41285. getError(): number;
  41286. /** @hidden */
  41287. _getUnpackAlignement(): number;
  41288. /** @hidden */
  41289. _unpackFlipY(value: boolean): void;
  41290. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41291. /**
  41292. * Updates a dynamic vertex buffer.
  41293. * @param vertexBuffer the vertex buffer to update
  41294. * @param data the data used to update the vertex buffer
  41295. * @param byteOffset the byte offset of the data (optional)
  41296. * @param byteLength the byte length of the data (optional)
  41297. */
  41298. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41299. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41300. /** @hidden */
  41301. _bindTexture(channel: number, texture: InternalTexture): void;
  41302. /** @hidden */
  41303. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41304. releaseEffects(): void;
  41305. displayLoadingUI(): void;
  41306. hideLoadingUI(): void;
  41307. /** @hidden */
  41308. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41309. /** @hidden */
  41310. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41311. /** @hidden */
  41312. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41313. /** @hidden */
  41314. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41315. }
  41316. }
  41317. declare module BABYLON {
  41318. /** @hidden */
  41319. export class _OcclusionDataStorage {
  41320. /** @hidden */
  41321. occlusionInternalRetryCounter: number;
  41322. /** @hidden */
  41323. isOcclusionQueryInProgress: boolean;
  41324. /** @hidden */
  41325. isOccluded: boolean;
  41326. /** @hidden */
  41327. occlusionRetryCount: number;
  41328. /** @hidden */
  41329. occlusionType: number;
  41330. /** @hidden */
  41331. occlusionQueryAlgorithmType: number;
  41332. }
  41333. interface Engine {
  41334. /**
  41335. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41336. * @return the new query
  41337. */
  41338. createQuery(): WebGLQuery;
  41339. /**
  41340. * Delete and release a webGL query
  41341. * @param query defines the query to delete
  41342. * @return the current engine
  41343. */
  41344. deleteQuery(query: WebGLQuery): Engine;
  41345. /**
  41346. * Check if a given query has resolved and got its value
  41347. * @param query defines the query to check
  41348. * @returns true if the query got its value
  41349. */
  41350. isQueryResultAvailable(query: WebGLQuery): boolean;
  41351. /**
  41352. * Gets the value of a given query
  41353. * @param query defines the query to check
  41354. * @returns the value of the query
  41355. */
  41356. getQueryResult(query: WebGLQuery): number;
  41357. /**
  41358. * Initiates an occlusion query
  41359. * @param algorithmType defines the algorithm to use
  41360. * @param query defines the query to use
  41361. * @returns the current engine
  41362. * @see http://doc.babylonjs.com/features/occlusionquery
  41363. */
  41364. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41365. /**
  41366. * Ends an occlusion query
  41367. * @see http://doc.babylonjs.com/features/occlusionquery
  41368. * @param algorithmType defines the algorithm to use
  41369. * @returns the current engine
  41370. */
  41371. endOcclusionQuery(algorithmType: number): Engine;
  41372. /**
  41373. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41374. * Please note that only one query can be issued at a time
  41375. * @returns a time token used to track the time span
  41376. */
  41377. startTimeQuery(): Nullable<_TimeToken>;
  41378. /**
  41379. * Ends a time query
  41380. * @param token defines the token used to measure the time span
  41381. * @returns the time spent (in ns)
  41382. */
  41383. endTimeQuery(token: _TimeToken): int;
  41384. /** @hidden */
  41385. _currentNonTimestampToken: Nullable<_TimeToken>;
  41386. /** @hidden */
  41387. _createTimeQuery(): WebGLQuery;
  41388. /** @hidden */
  41389. _deleteTimeQuery(query: WebGLQuery): void;
  41390. /** @hidden */
  41391. _getGlAlgorithmType(algorithmType: number): number;
  41392. /** @hidden */
  41393. _getTimeQueryResult(query: WebGLQuery): any;
  41394. /** @hidden */
  41395. _getTimeQueryAvailability(query: WebGLQuery): any;
  41396. }
  41397. interface AbstractMesh {
  41398. /**
  41399. * Backing filed
  41400. * @hidden
  41401. */
  41402. __occlusionDataStorage: _OcclusionDataStorage;
  41403. /**
  41404. * Access property
  41405. * @hidden
  41406. */
  41407. _occlusionDataStorage: _OcclusionDataStorage;
  41408. /**
  41409. * 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.
  41410. * The default value is -1 which means don't break the query and wait till the result
  41411. * @see http://doc.babylonjs.com/features/occlusionquery
  41412. */
  41413. occlusionRetryCount: number;
  41414. /**
  41415. * 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:
  41416. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41417. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41418. * * 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.
  41419. * @see http://doc.babylonjs.com/features/occlusionquery
  41420. */
  41421. occlusionType: number;
  41422. /**
  41423. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41424. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41425. * * 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.
  41426. * @see http://doc.babylonjs.com/features/occlusionquery
  41427. */
  41428. occlusionQueryAlgorithmType: number;
  41429. /**
  41430. * 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
  41431. * @see http://doc.babylonjs.com/features/occlusionquery
  41432. */
  41433. isOccluded: boolean;
  41434. /**
  41435. * Flag to check the progress status of the query
  41436. * @see http://doc.babylonjs.com/features/occlusionquery
  41437. */
  41438. isOcclusionQueryInProgress: boolean;
  41439. }
  41440. }
  41441. declare module BABYLON {
  41442. /** @hidden */
  41443. export var _forceTransformFeedbackToBundle: boolean;
  41444. interface Engine {
  41445. /**
  41446. * Creates a webGL transform feedback object
  41447. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41448. * @returns the webGL transform feedback object
  41449. */
  41450. createTransformFeedback(): WebGLTransformFeedback;
  41451. /**
  41452. * Delete a webGL transform feedback object
  41453. * @param value defines the webGL transform feedback object to delete
  41454. */
  41455. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41456. /**
  41457. * Bind a webGL transform feedback object to the webgl context
  41458. * @param value defines the webGL transform feedback object to bind
  41459. */
  41460. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41461. /**
  41462. * Begins a transform feedback operation
  41463. * @param usePoints defines if points or triangles must be used
  41464. */
  41465. beginTransformFeedback(usePoints: boolean): void;
  41466. /**
  41467. * Ends a transform feedback operation
  41468. */
  41469. endTransformFeedback(): void;
  41470. /**
  41471. * Specify the varyings to use with transform feedback
  41472. * @param program defines the associated webGL program
  41473. * @param value defines the list of strings representing the varying names
  41474. */
  41475. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41476. /**
  41477. * Bind a webGL buffer for a transform feedback operation
  41478. * @param value defines the webGL buffer to bind
  41479. */
  41480. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41481. }
  41482. }
  41483. declare module BABYLON {
  41484. /**
  41485. * Gather the list of clipboard event types as constants.
  41486. */
  41487. export class ClipboardEventTypes {
  41488. /**
  41489. * The clipboard event is fired when a copy command is active (pressed).
  41490. */
  41491. static readonly COPY: number;
  41492. /**
  41493. * The clipboard event is fired when a cut command is active (pressed).
  41494. */
  41495. static readonly CUT: number;
  41496. /**
  41497. * The clipboard event is fired when a paste command is active (pressed).
  41498. */
  41499. static readonly PASTE: number;
  41500. }
  41501. /**
  41502. * This class is used to store clipboard related info for the onClipboardObservable event.
  41503. */
  41504. export class ClipboardInfo {
  41505. /**
  41506. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41507. */
  41508. type: number;
  41509. /**
  41510. * Defines the related dom event
  41511. */
  41512. event: ClipboardEvent;
  41513. /**
  41514. *Creates an instance of ClipboardInfo.
  41515. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41516. * @param event Defines the related dom event
  41517. */
  41518. constructor(
  41519. /**
  41520. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41521. */
  41522. type: number,
  41523. /**
  41524. * Defines the related dom event
  41525. */
  41526. event: ClipboardEvent);
  41527. /**
  41528. * Get the clipboard event's type from the keycode.
  41529. * @param keyCode Defines the keyCode for the current keyboard event.
  41530. * @return {number}
  41531. */
  41532. static GetTypeFromCharacter(keyCode: number): number;
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /**
  41537. * Class used to represent data loading progression
  41538. */
  41539. export class SceneLoaderProgressEvent {
  41540. /** defines if data length to load can be evaluated */
  41541. readonly lengthComputable: boolean;
  41542. /** defines the loaded data length */
  41543. readonly loaded: number;
  41544. /** defines the data length to load */
  41545. readonly total: number;
  41546. /**
  41547. * Create a new progress event
  41548. * @param lengthComputable defines if data length to load can be evaluated
  41549. * @param loaded defines the loaded data length
  41550. * @param total defines the data length to load
  41551. */
  41552. constructor(
  41553. /** defines if data length to load can be evaluated */
  41554. lengthComputable: boolean,
  41555. /** defines the loaded data length */
  41556. loaded: number,
  41557. /** defines the data length to load */
  41558. total: number);
  41559. /**
  41560. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41561. * @param event defines the source event
  41562. * @returns a new SceneLoaderProgressEvent
  41563. */
  41564. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41565. }
  41566. /**
  41567. * Interface used by SceneLoader plugins to define supported file extensions
  41568. */
  41569. export interface ISceneLoaderPluginExtensions {
  41570. /**
  41571. * Defines the list of supported extensions
  41572. */
  41573. [extension: string]: {
  41574. isBinary: boolean;
  41575. };
  41576. }
  41577. /**
  41578. * Interface used by SceneLoader plugin factory
  41579. */
  41580. export interface ISceneLoaderPluginFactory {
  41581. /**
  41582. * Defines the name of the factory
  41583. */
  41584. name: string;
  41585. /**
  41586. * Function called to create a new plugin
  41587. * @return the new plugin
  41588. */
  41589. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41590. /**
  41591. * Boolean indicating if the plugin can direct load specific data
  41592. */
  41593. canDirectLoad?: (data: string) => boolean;
  41594. }
  41595. /**
  41596. * Interface used to define a SceneLoader plugin
  41597. */
  41598. export interface ISceneLoaderPlugin {
  41599. /**
  41600. * The friendly name of this plugin.
  41601. */
  41602. name: string;
  41603. /**
  41604. * The file extensions supported by this plugin.
  41605. */
  41606. extensions: string | ISceneLoaderPluginExtensions;
  41607. /**
  41608. * Import meshes into a scene.
  41609. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41610. * @param scene The scene to import into
  41611. * @param data The data to import
  41612. * @param rootUrl The root url for scene and resources
  41613. * @param meshes The meshes array to import into
  41614. * @param particleSystems The particle systems array to import into
  41615. * @param skeletons The skeletons array to import into
  41616. * @param onError The callback when import fails
  41617. * @returns True if successful or false otherwise
  41618. */
  41619. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41620. /**
  41621. * Load into a scene.
  41622. * @param scene The scene to load into
  41623. * @param data The data to import
  41624. * @param rootUrl The root url for scene and resources
  41625. * @param onError The callback when import fails
  41626. * @returns true if successful or false otherwise
  41627. */
  41628. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41629. /**
  41630. * The callback that returns true if the data can be directly loaded.
  41631. */
  41632. canDirectLoad?: (data: string) => boolean;
  41633. /**
  41634. * The callback that allows custom handling of the root url based on the response url.
  41635. */
  41636. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41637. /**
  41638. * Load into an asset container.
  41639. * @param scene The scene to load into
  41640. * @param data The data to import
  41641. * @param rootUrl The root url for scene and resources
  41642. * @param onError The callback when import fails
  41643. * @returns The loaded asset container
  41644. */
  41645. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41646. }
  41647. /**
  41648. * Interface used to define an async SceneLoader plugin
  41649. */
  41650. export interface ISceneLoaderPluginAsync {
  41651. /**
  41652. * The friendly name of this plugin.
  41653. */
  41654. name: string;
  41655. /**
  41656. * The file extensions supported by this plugin.
  41657. */
  41658. extensions: string | ISceneLoaderPluginExtensions;
  41659. /**
  41660. * Import meshes into a scene.
  41661. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41662. * @param scene The scene to import into
  41663. * @param data The data to import
  41664. * @param rootUrl The root url for scene and resources
  41665. * @param onProgress The callback when the load progresses
  41666. * @param fileName Defines the name of the file to load
  41667. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41668. */
  41669. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41670. meshes: AbstractMesh[];
  41671. particleSystems: IParticleSystem[];
  41672. skeletons: Skeleton[];
  41673. animationGroups: AnimationGroup[];
  41674. }>;
  41675. /**
  41676. * Load into a scene.
  41677. * @param scene The scene to load into
  41678. * @param data The data to import
  41679. * @param rootUrl The root url for scene and resources
  41680. * @param onProgress The callback when the load progresses
  41681. * @param fileName Defines the name of the file to load
  41682. * @returns Nothing
  41683. */
  41684. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41685. /**
  41686. * The callback that returns true if the data can be directly loaded.
  41687. */
  41688. canDirectLoad?: (data: string) => boolean;
  41689. /**
  41690. * The callback that allows custom handling of the root url based on the response url.
  41691. */
  41692. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41693. /**
  41694. * Load into an asset container.
  41695. * @param scene The scene to load into
  41696. * @param data The data to import
  41697. * @param rootUrl The root url for scene and resources
  41698. * @param onProgress The callback when the load progresses
  41699. * @param fileName Defines the name of the file to load
  41700. * @returns The loaded asset container
  41701. */
  41702. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41703. }
  41704. /**
  41705. * Class used to load scene from various file formats using registered plugins
  41706. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41707. */
  41708. export class SceneLoader {
  41709. /**
  41710. * No logging while loading
  41711. */
  41712. static readonly NO_LOGGING: number;
  41713. /**
  41714. * Minimal logging while loading
  41715. */
  41716. static readonly MINIMAL_LOGGING: number;
  41717. /**
  41718. * Summary logging while loading
  41719. */
  41720. static readonly SUMMARY_LOGGING: number;
  41721. /**
  41722. * Detailled logging while loading
  41723. */
  41724. static readonly DETAILED_LOGGING: number;
  41725. /**
  41726. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41727. */
  41728. static ForceFullSceneLoadingForIncremental: boolean;
  41729. /**
  41730. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41731. */
  41732. static ShowLoadingScreen: boolean;
  41733. /**
  41734. * Defines the current logging level (while loading the scene)
  41735. * @ignorenaming
  41736. */
  41737. static loggingLevel: number;
  41738. /**
  41739. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41740. */
  41741. static CleanBoneMatrixWeights: boolean;
  41742. /**
  41743. * Event raised when a plugin is used to load a scene
  41744. */
  41745. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41746. private static _registeredPlugins;
  41747. private static _getDefaultPlugin;
  41748. private static _getPluginForExtension;
  41749. private static _getPluginForDirectLoad;
  41750. private static _getPluginForFilename;
  41751. private static _getDirectLoad;
  41752. private static _loadData;
  41753. private static _getFileInfo;
  41754. /**
  41755. * Gets a plugin that can load the given extension
  41756. * @param extension defines the extension to load
  41757. * @returns a plugin or null if none works
  41758. */
  41759. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41760. /**
  41761. * Gets a boolean indicating that the given extension can be loaded
  41762. * @param extension defines the extension to load
  41763. * @returns true if the extension is supported
  41764. */
  41765. static IsPluginForExtensionAvailable(extension: string): boolean;
  41766. /**
  41767. * Adds a new plugin to the list of registered plugins
  41768. * @param plugin defines the plugin to add
  41769. */
  41770. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41771. /**
  41772. * Import meshes into a scene
  41773. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41774. * @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)
  41775. * @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)
  41776. * @param scene the instance of BABYLON.Scene to append to
  41777. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41778. * @param onProgress a callback with a progress event for each file being loaded
  41779. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41780. * @param pluginExtension the extension used to determine the plugin
  41781. * @returns The loaded plugin
  41782. */
  41783. 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>;
  41784. /**
  41785. * Import meshes into a scene
  41786. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41787. * @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)
  41788. * @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)
  41789. * @param scene the instance of BABYLON.Scene to append to
  41790. * @param onProgress a callback with a progress event for each file being loaded
  41791. * @param pluginExtension the extension used to determine the plugin
  41792. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41793. */
  41794. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41795. meshes: AbstractMesh[];
  41796. particleSystems: IParticleSystem[];
  41797. skeletons: Skeleton[];
  41798. animationGroups: AnimationGroup[];
  41799. }>;
  41800. /**
  41801. * Load a scene
  41802. * @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)
  41803. * @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)
  41804. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41805. * @param onSuccess a callback with the scene when import succeeds
  41806. * @param onProgress a callback with a progress event for each file being loaded
  41807. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41808. * @param pluginExtension the extension used to determine the plugin
  41809. * @returns The loaded plugin
  41810. */
  41811. 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>;
  41812. /**
  41813. * Load a scene
  41814. * @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)
  41815. * @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)
  41816. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41817. * @param onProgress a callback with a progress event for each file being loaded
  41818. * @param pluginExtension the extension used to determine the plugin
  41819. * @returns The loaded scene
  41820. */
  41821. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41822. /**
  41823. * Append a scene
  41824. * @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)
  41825. * @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)
  41826. * @param scene is the instance of BABYLON.Scene to append to
  41827. * @param onSuccess a callback with the scene when import succeeds
  41828. * @param onProgress a callback with a progress event for each file being loaded
  41829. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41830. * @param pluginExtension the extension used to determine the plugin
  41831. * @returns The loaded plugin
  41832. */
  41833. 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>;
  41834. /**
  41835. * Append a scene
  41836. * @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)
  41837. * @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)
  41838. * @param scene is the instance of BABYLON.Scene to append to
  41839. * @param onProgress a callback with a progress event for each file being loaded
  41840. * @param pluginExtension the extension used to determine the plugin
  41841. * @returns The given scene
  41842. */
  41843. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41844. /**
  41845. * Load a scene into an asset container
  41846. * @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)
  41847. * @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)
  41848. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41849. * @param onSuccess a callback with the scene when import succeeds
  41850. * @param onProgress a callback with a progress event for each file being loaded
  41851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41852. * @param pluginExtension the extension used to determine the plugin
  41853. * @returns The loaded plugin
  41854. */
  41855. 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>;
  41856. /**
  41857. * Load a scene into an asset container
  41858. * @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)
  41859. * @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)
  41860. * @param scene is the instance of Scene to append to
  41861. * @param onProgress a callback with a progress event for each file being loaded
  41862. * @param pluginExtension the extension used to determine the plugin
  41863. * @returns The loaded asset container
  41864. */
  41865. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41866. }
  41867. }
  41868. declare module BABYLON {
  41869. /**
  41870. * Google Daydream controller
  41871. */
  41872. export class DaydreamController extends WebVRController {
  41873. /**
  41874. * Base Url for the controller model.
  41875. */
  41876. static MODEL_BASE_URL: string;
  41877. /**
  41878. * File name for the controller model.
  41879. */
  41880. static MODEL_FILENAME: string;
  41881. /**
  41882. * Gamepad Id prefix used to identify Daydream Controller.
  41883. */
  41884. static readonly GAMEPAD_ID_PREFIX: string;
  41885. /**
  41886. * Creates a new DaydreamController from a gamepad
  41887. * @param vrGamepad the gamepad that the controller should be created from
  41888. */
  41889. constructor(vrGamepad: any);
  41890. /**
  41891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41892. * @param scene scene in which to add meshes
  41893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41894. */
  41895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41896. /**
  41897. * Called once for each button that changed state since the last frame
  41898. * @param buttonIdx Which button index changed
  41899. * @param state New state of the button
  41900. * @param changes Which properties on the state changed since last frame
  41901. */
  41902. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41903. }
  41904. }
  41905. declare module BABYLON {
  41906. /**
  41907. * Gear VR Controller
  41908. */
  41909. export class GearVRController extends WebVRController {
  41910. /**
  41911. * Base Url for the controller model.
  41912. */
  41913. static MODEL_BASE_URL: string;
  41914. /**
  41915. * File name for the controller model.
  41916. */
  41917. static MODEL_FILENAME: string;
  41918. /**
  41919. * Gamepad Id prefix used to identify this controller.
  41920. */
  41921. static readonly GAMEPAD_ID_PREFIX: string;
  41922. private readonly _buttonIndexToObservableNameMap;
  41923. /**
  41924. * Creates a new GearVRController from a gamepad
  41925. * @param vrGamepad the gamepad that the controller should be created from
  41926. */
  41927. constructor(vrGamepad: any);
  41928. /**
  41929. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41930. * @param scene scene in which to add meshes
  41931. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41932. */
  41933. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41934. /**
  41935. * Called once for each button that changed state since the last frame
  41936. * @param buttonIdx Which button index changed
  41937. * @param state New state of the button
  41938. * @param changes Which properties on the state changed since last frame
  41939. */
  41940. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41941. }
  41942. }
  41943. declare module BABYLON {
  41944. /**
  41945. * Generic Controller
  41946. */
  41947. export class GenericController extends WebVRController {
  41948. /**
  41949. * Base Url for the controller model.
  41950. */
  41951. static readonly MODEL_BASE_URL: string;
  41952. /**
  41953. * File name for the controller model.
  41954. */
  41955. static readonly MODEL_FILENAME: string;
  41956. /**
  41957. * Creates a new GenericController from a gamepad
  41958. * @param vrGamepad the gamepad that the controller should be created from
  41959. */
  41960. constructor(vrGamepad: any);
  41961. /**
  41962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41963. * @param scene scene in which to add meshes
  41964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41965. */
  41966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41967. /**
  41968. * Called once for each button that changed state since the last frame
  41969. * @param buttonIdx Which button index changed
  41970. * @param state New state of the button
  41971. * @param changes Which properties on the state changed since last frame
  41972. */
  41973. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41974. }
  41975. }
  41976. declare module BABYLON {
  41977. /**
  41978. * Oculus Touch Controller
  41979. */
  41980. export class OculusTouchController extends WebVRController {
  41981. /**
  41982. * Base Url for the controller model.
  41983. */
  41984. static MODEL_BASE_URL: string;
  41985. /**
  41986. * File name for the left controller model.
  41987. */
  41988. static MODEL_LEFT_FILENAME: string;
  41989. /**
  41990. * File name for the right controller model.
  41991. */
  41992. static MODEL_RIGHT_FILENAME: string;
  41993. /**
  41994. * Fired when the secondary trigger on this controller is modified
  41995. */
  41996. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41997. /**
  41998. * Fired when the thumb rest on this controller is modified
  41999. */
  42000. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42001. /**
  42002. * Creates a new OculusTouchController from a gamepad
  42003. * @param vrGamepad the gamepad that the controller should be created from
  42004. */
  42005. constructor(vrGamepad: any);
  42006. /**
  42007. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42008. * @param scene scene in which to add meshes
  42009. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42010. */
  42011. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42012. /**
  42013. * Fired when the A button on this controller is modified
  42014. */
  42015. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42016. /**
  42017. * Fired when the B button on this controller is modified
  42018. */
  42019. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42020. /**
  42021. * Fired when the X button on this controller is modified
  42022. */
  42023. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42024. /**
  42025. * Fired when the Y button on this controller is modified
  42026. */
  42027. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42028. /**
  42029. * Called once for each button that changed state since the last frame
  42030. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42031. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42032. * 2) secondary trigger (same)
  42033. * 3) A (right) X (left), touch, pressed = value
  42034. * 4) B / Y
  42035. * 5) thumb rest
  42036. * @param buttonIdx Which button index changed
  42037. * @param state New state of the button
  42038. * @param changes Which properties on the state changed since last frame
  42039. */
  42040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42041. }
  42042. }
  42043. declare module BABYLON {
  42044. /**
  42045. * Vive Controller
  42046. */
  42047. export class ViveController extends WebVRController {
  42048. /**
  42049. * Base Url for the controller model.
  42050. */
  42051. static MODEL_BASE_URL: string;
  42052. /**
  42053. * File name for the controller model.
  42054. */
  42055. static MODEL_FILENAME: string;
  42056. /**
  42057. * Creates a new ViveController from a gamepad
  42058. * @param vrGamepad the gamepad that the controller should be created from
  42059. */
  42060. constructor(vrGamepad: any);
  42061. /**
  42062. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42063. * @param scene scene in which to add meshes
  42064. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42065. */
  42066. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42067. /**
  42068. * Fired when the left button on this controller is modified
  42069. */
  42070. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42071. /**
  42072. * Fired when the right button on this controller is modified
  42073. */
  42074. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42075. /**
  42076. * Fired when the menu button on this controller is modified
  42077. */
  42078. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42079. /**
  42080. * Called once for each button that changed state since the last frame
  42081. * Vive mapping:
  42082. * 0: touchpad
  42083. * 1: trigger
  42084. * 2: left AND right buttons
  42085. * 3: menu button
  42086. * @param buttonIdx Which button index changed
  42087. * @param state New state of the button
  42088. * @param changes Which properties on the state changed since last frame
  42089. */
  42090. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Defines the WindowsMotionController object that the state of the windows motion controller
  42096. */
  42097. export class WindowsMotionController extends WebVRController {
  42098. /**
  42099. * The base url used to load the left and right controller models
  42100. */
  42101. static MODEL_BASE_URL: string;
  42102. /**
  42103. * The name of the left controller model file
  42104. */
  42105. static MODEL_LEFT_FILENAME: string;
  42106. /**
  42107. * The name of the right controller model file
  42108. */
  42109. static MODEL_RIGHT_FILENAME: string;
  42110. /**
  42111. * The controller name prefix for this controller type
  42112. */
  42113. static readonly GAMEPAD_ID_PREFIX: string;
  42114. /**
  42115. * The controller id pattern for this controller type
  42116. */
  42117. private static readonly GAMEPAD_ID_PATTERN;
  42118. private _loadedMeshInfo;
  42119. private readonly _mapping;
  42120. /**
  42121. * Fired when the trackpad on this controller is clicked
  42122. */
  42123. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42124. /**
  42125. * Fired when the trackpad on this controller is modified
  42126. */
  42127. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42128. /**
  42129. * The current x and y values of this controller's trackpad
  42130. */
  42131. trackpad: StickValues;
  42132. /**
  42133. * Creates a new WindowsMotionController from a gamepad
  42134. * @param vrGamepad the gamepad that the controller should be created from
  42135. */
  42136. constructor(vrGamepad: any);
  42137. /**
  42138. * Fired when the trigger on this controller is modified
  42139. */
  42140. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42141. /**
  42142. * Fired when the menu button on this controller is modified
  42143. */
  42144. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42145. /**
  42146. * Fired when the grip button on this controller is modified
  42147. */
  42148. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42149. /**
  42150. * Fired when the thumbstick button on this controller is modified
  42151. */
  42152. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42153. /**
  42154. * Fired when the touchpad button on this controller is modified
  42155. */
  42156. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42157. /**
  42158. * Fired when the touchpad values on this controller are modified
  42159. */
  42160. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42161. private _updateTrackpad;
  42162. /**
  42163. * Called once per frame by the engine.
  42164. */
  42165. update(): void;
  42166. /**
  42167. * Called once for each button that changed state since the last frame
  42168. * @param buttonIdx Which button index changed
  42169. * @param state New state of the button
  42170. * @param changes Which properties on the state changed since last frame
  42171. */
  42172. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42173. /**
  42174. * Moves the buttons on the controller mesh based on their current state
  42175. * @param buttonName the name of the button to move
  42176. * @param buttonValue the value of the button which determines the buttons new position
  42177. */
  42178. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42179. /**
  42180. * Moves the axis on the controller mesh based on its current state
  42181. * @param axis the index of the axis
  42182. * @param axisValue the value of the axis which determines the meshes new position
  42183. * @hidden
  42184. */
  42185. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42186. /**
  42187. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42188. * @param scene scene in which to add meshes
  42189. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42190. */
  42191. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42192. /**
  42193. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42194. * can be transformed by button presses and axes values, based on this._mapping.
  42195. *
  42196. * @param scene scene in which the meshes exist
  42197. * @param meshes list of meshes that make up the controller model to process
  42198. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42199. */
  42200. private processModel;
  42201. private createMeshInfo;
  42202. /**
  42203. * Gets the ray of the controller in the direction the controller is pointing
  42204. * @param length the length the resulting ray should be
  42205. * @returns a ray in the direction the controller is pointing
  42206. */
  42207. getForwardRay(length?: number): Ray;
  42208. /**
  42209. * Disposes of the controller
  42210. */
  42211. dispose(): void;
  42212. }
  42213. }
  42214. declare module BABYLON {
  42215. /**
  42216. * Single axis scale gizmo
  42217. */
  42218. export class AxisScaleGizmo extends Gizmo {
  42219. private _coloredMaterial;
  42220. /**
  42221. * Drag behavior responsible for the gizmos dragging interactions
  42222. */
  42223. dragBehavior: PointerDragBehavior;
  42224. private _pointerObserver;
  42225. /**
  42226. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42227. */
  42228. snapDistance: number;
  42229. /**
  42230. * Event that fires each time the gizmo snaps to a new location.
  42231. * * snapDistance is the the change in distance
  42232. */
  42233. onSnapObservable: Observable<{
  42234. snapDistance: number;
  42235. }>;
  42236. /**
  42237. * If the scaling operation should be done on all axis (default: false)
  42238. */
  42239. uniformScaling: boolean;
  42240. /**
  42241. * Creates an AxisScaleGizmo
  42242. * @param gizmoLayer The utility layer the gizmo will be added to
  42243. * @param dragAxis The axis which the gizmo will be able to scale on
  42244. * @param color The color of the gizmo
  42245. */
  42246. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42247. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42248. /**
  42249. * Disposes of the gizmo
  42250. */
  42251. dispose(): void;
  42252. /**
  42253. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42254. * @param mesh The mesh to replace the default mesh of the gizmo
  42255. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42256. */
  42257. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * Bounding box gizmo
  42263. */
  42264. export class BoundingBoxGizmo extends Gizmo {
  42265. private _lineBoundingBox;
  42266. private _rotateSpheresParent;
  42267. private _scaleBoxesParent;
  42268. private _boundingDimensions;
  42269. private _renderObserver;
  42270. private _pointerObserver;
  42271. private _scaleDragSpeed;
  42272. private _tmpQuaternion;
  42273. private _tmpVector;
  42274. private _tmpRotationMatrix;
  42275. /**
  42276. * 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)
  42277. */
  42278. ignoreChildren: boolean;
  42279. /**
  42280. * 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)
  42281. */
  42282. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42283. /**
  42284. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42285. */
  42286. rotationSphereSize: number;
  42287. /**
  42288. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42289. */
  42290. scaleBoxSize: number;
  42291. /**
  42292. * 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)
  42293. */
  42294. fixedDragMeshScreenSize: boolean;
  42295. /**
  42296. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42297. */
  42298. fixedDragMeshScreenSizeDistanceFactor: number;
  42299. /**
  42300. * Fired when a rotation sphere or scale box is dragged
  42301. */
  42302. onDragStartObservable: Observable<{}>;
  42303. /**
  42304. * Fired when a scale box is dragged
  42305. */
  42306. onScaleBoxDragObservable: Observable<{}>;
  42307. /**
  42308. * Fired when a scale box drag is ended
  42309. */
  42310. onScaleBoxDragEndObservable: Observable<{}>;
  42311. /**
  42312. * Fired when a rotation sphere is dragged
  42313. */
  42314. onRotationSphereDragObservable: Observable<{}>;
  42315. /**
  42316. * Fired when a rotation sphere drag is ended
  42317. */
  42318. onRotationSphereDragEndObservable: Observable<{}>;
  42319. /**
  42320. * 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)
  42321. */
  42322. scalePivot: Nullable<Vector3>;
  42323. /**
  42324. * Mesh used as a pivot to rotate the attached mesh
  42325. */
  42326. private _anchorMesh;
  42327. private _existingMeshScale;
  42328. private _dragMesh;
  42329. private pointerDragBehavior;
  42330. private coloredMaterial;
  42331. private hoverColoredMaterial;
  42332. /**
  42333. * Sets the color of the bounding box gizmo
  42334. * @param color the color to set
  42335. */
  42336. setColor(color: Color3): void;
  42337. /**
  42338. * Creates an BoundingBoxGizmo
  42339. * @param gizmoLayer The utility layer the gizmo will be added to
  42340. * @param color The color of the gizmo
  42341. */
  42342. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42344. private _selectNode;
  42345. /**
  42346. * Updates the bounding box information for the Gizmo
  42347. */
  42348. updateBoundingBox(): void;
  42349. private _updateRotationSpheres;
  42350. private _updateScaleBoxes;
  42351. /**
  42352. * Enables rotation on the specified axis and disables rotation on the others
  42353. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42354. */
  42355. setEnabledRotationAxis(axis: string): void;
  42356. /**
  42357. * Enables/disables scaling
  42358. * @param enable if scaling should be enabled
  42359. */
  42360. setEnabledScaling(enable: boolean): void;
  42361. private _updateDummy;
  42362. /**
  42363. * Enables a pointer drag behavior on the bounding box of the gizmo
  42364. */
  42365. enableDragBehavior(): void;
  42366. /**
  42367. * Disposes of the gizmo
  42368. */
  42369. dispose(): void;
  42370. /**
  42371. * 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)
  42372. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42373. * @returns the bounding box mesh with the passed in mesh as a child
  42374. */
  42375. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42376. /**
  42377. * CustomMeshes are not supported by this gizmo
  42378. * @param mesh The mesh to replace the default mesh of the gizmo
  42379. */
  42380. setCustomMesh(mesh: Mesh): void;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Single plane rotation gizmo
  42386. */
  42387. export class PlaneRotationGizmo extends Gizmo {
  42388. /**
  42389. * Drag behavior responsible for the gizmos dragging interactions
  42390. */
  42391. dragBehavior: PointerDragBehavior;
  42392. private _pointerObserver;
  42393. /**
  42394. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42395. */
  42396. snapDistance: number;
  42397. /**
  42398. * Event that fires each time the gizmo snaps to a new location.
  42399. * * snapDistance is the the change in distance
  42400. */
  42401. onSnapObservable: Observable<{
  42402. snapDistance: number;
  42403. }>;
  42404. /**
  42405. * Creates a PlaneRotationGizmo
  42406. * @param gizmoLayer The utility layer the gizmo will be added to
  42407. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42408. * @param color The color of the gizmo
  42409. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42410. */
  42411. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42412. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42413. /**
  42414. * Disposes of the gizmo
  42415. */
  42416. dispose(): void;
  42417. }
  42418. }
  42419. declare module BABYLON {
  42420. /**
  42421. * Gizmo that enables rotating a mesh along 3 axis
  42422. */
  42423. export class RotationGizmo extends Gizmo {
  42424. /**
  42425. * Internal gizmo used for interactions on the x axis
  42426. */
  42427. xGizmo: PlaneRotationGizmo;
  42428. /**
  42429. * Internal gizmo used for interactions on the y axis
  42430. */
  42431. yGizmo: PlaneRotationGizmo;
  42432. /**
  42433. * Internal gizmo used for interactions on the z axis
  42434. */
  42435. zGizmo: PlaneRotationGizmo;
  42436. /** Fires an event when any of it's sub gizmos are dragged */
  42437. onDragStartObservable: Observable<{}>;
  42438. /** Fires an event when any of it's sub gizmos are released from dragging */
  42439. onDragEndObservable: Observable<{}>;
  42440. attachedMesh: Nullable<AbstractMesh>;
  42441. /**
  42442. * Creates a RotationGizmo
  42443. * @param gizmoLayer The utility layer the gizmo will be added to
  42444. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42445. */
  42446. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42447. updateGizmoRotationToMatchAttachedMesh: boolean;
  42448. /**
  42449. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42450. */
  42451. snapDistance: number;
  42452. /**
  42453. * Ratio for the scale of the gizmo (Default: 1)
  42454. */
  42455. scaleRatio: number;
  42456. /**
  42457. * Disposes of the gizmo
  42458. */
  42459. dispose(): void;
  42460. /**
  42461. * CustomMeshes are not supported by this gizmo
  42462. * @param mesh The mesh to replace the default mesh of the gizmo
  42463. */
  42464. setCustomMesh(mesh: Mesh): void;
  42465. }
  42466. }
  42467. declare module BABYLON {
  42468. /**
  42469. * Gizmo that enables dragging a mesh along 3 axis
  42470. */
  42471. export class PositionGizmo extends Gizmo {
  42472. /**
  42473. * Internal gizmo used for interactions on the x axis
  42474. */
  42475. xGizmo: AxisDragGizmo;
  42476. /**
  42477. * Internal gizmo used for interactions on the y axis
  42478. */
  42479. yGizmo: AxisDragGizmo;
  42480. /**
  42481. * Internal gizmo used for interactions on the z axis
  42482. */
  42483. zGizmo: AxisDragGizmo;
  42484. /** Fires an event when any of it's sub gizmos are dragged */
  42485. onDragStartObservable: Observable<{}>;
  42486. /** Fires an event when any of it's sub gizmos are released from dragging */
  42487. onDragEndObservable: Observable<{}>;
  42488. attachedMesh: Nullable<AbstractMesh>;
  42489. /**
  42490. * Creates a PositionGizmo
  42491. * @param gizmoLayer The utility layer the gizmo will be added to
  42492. */
  42493. constructor(gizmoLayer?: UtilityLayerRenderer);
  42494. updateGizmoRotationToMatchAttachedMesh: boolean;
  42495. /**
  42496. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42497. */
  42498. snapDistance: number;
  42499. /**
  42500. * Ratio for the scale of the gizmo (Default: 1)
  42501. */
  42502. scaleRatio: number;
  42503. /**
  42504. * Disposes of the gizmo
  42505. */
  42506. dispose(): void;
  42507. /**
  42508. * CustomMeshes are not supported by this gizmo
  42509. * @param mesh The mesh to replace the default mesh of the gizmo
  42510. */
  42511. setCustomMesh(mesh: Mesh): void;
  42512. }
  42513. }
  42514. declare module BABYLON {
  42515. /**
  42516. * Class containing static functions to help procedurally build meshes
  42517. */
  42518. export class PolyhedronBuilder {
  42519. /**
  42520. * Creates a polyhedron mesh
  42521. * * 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
  42522. * * The parameter `size` (positive float, default 1) sets the polygon size
  42523. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42524. * * 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`
  42525. * * 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
  42526. * * 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)`)
  42527. * * 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
  42528. * * 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
  42529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42530. * * 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
  42531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42532. * @param name defines the name of the mesh
  42533. * @param options defines the options used to create the mesh
  42534. * @param scene defines the hosting scene
  42535. * @returns the polyhedron mesh
  42536. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42537. */
  42538. static CreatePolyhedron(name: string, options: {
  42539. type?: number;
  42540. size?: number;
  42541. sizeX?: number;
  42542. sizeY?: number;
  42543. sizeZ?: number;
  42544. custom?: any;
  42545. faceUV?: Vector4[];
  42546. faceColors?: Color4[];
  42547. flat?: boolean;
  42548. updatable?: boolean;
  42549. sideOrientation?: number;
  42550. frontUVs?: Vector4;
  42551. backUVs?: Vector4;
  42552. }, scene?: Nullable<Scene>): Mesh;
  42553. }
  42554. }
  42555. declare module BABYLON {
  42556. /**
  42557. * Gizmo that enables scaling a mesh along 3 axis
  42558. */
  42559. export class ScaleGizmo extends Gizmo {
  42560. /**
  42561. * Internal gizmo used for interactions on the x axis
  42562. */
  42563. xGizmo: AxisScaleGizmo;
  42564. /**
  42565. * Internal gizmo used for interactions on the y axis
  42566. */
  42567. yGizmo: AxisScaleGizmo;
  42568. /**
  42569. * Internal gizmo used for interactions on the z axis
  42570. */
  42571. zGizmo: AxisScaleGizmo;
  42572. /**
  42573. * Internal gizmo used to scale all axis equally
  42574. */
  42575. uniformScaleGizmo: AxisScaleGizmo;
  42576. /** Fires an event when any of it's sub gizmos are dragged */
  42577. onDragStartObservable: Observable<{}>;
  42578. /** Fires an event when any of it's sub gizmos are released from dragging */
  42579. onDragEndObservable: Observable<{}>;
  42580. attachedMesh: Nullable<AbstractMesh>;
  42581. /**
  42582. * Creates a ScaleGizmo
  42583. * @param gizmoLayer The utility layer the gizmo will be added to
  42584. */
  42585. constructor(gizmoLayer?: UtilityLayerRenderer);
  42586. updateGizmoRotationToMatchAttachedMesh: boolean;
  42587. /**
  42588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42589. */
  42590. snapDistance: number;
  42591. /**
  42592. * Ratio for the scale of the gizmo (Default: 1)
  42593. */
  42594. scaleRatio: number;
  42595. /**
  42596. * Disposes of the gizmo
  42597. */
  42598. dispose(): void;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42604. */
  42605. export class GizmoManager implements IDisposable {
  42606. private scene;
  42607. /**
  42608. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42609. */
  42610. gizmos: {
  42611. positionGizmo: Nullable<PositionGizmo>;
  42612. rotationGizmo: Nullable<RotationGizmo>;
  42613. scaleGizmo: Nullable<ScaleGizmo>;
  42614. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42615. };
  42616. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42617. clearGizmoOnEmptyPointerEvent: boolean;
  42618. /** Fires an event when the manager is attached to a mesh */
  42619. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42620. private _gizmosEnabled;
  42621. private _pointerObserver;
  42622. private _attachedMesh;
  42623. private _boundingBoxColor;
  42624. private _defaultUtilityLayer;
  42625. private _defaultKeepDepthUtilityLayer;
  42626. /**
  42627. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42628. */
  42629. boundingBoxDragBehavior: SixDofDragBehavior;
  42630. /**
  42631. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42632. */
  42633. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42634. /**
  42635. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42636. */
  42637. usePointerToAttachGizmos: boolean;
  42638. /**
  42639. * Instatiates a gizmo manager
  42640. * @param scene the scene to overlay the gizmos on top of
  42641. */
  42642. constructor(scene: Scene);
  42643. /**
  42644. * Attaches a set of gizmos to the specified mesh
  42645. * @param mesh The mesh the gizmo's should be attached to
  42646. */
  42647. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42648. /**
  42649. * If the position gizmo is enabled
  42650. */
  42651. positionGizmoEnabled: boolean;
  42652. /**
  42653. * If the rotation gizmo is enabled
  42654. */
  42655. rotationGizmoEnabled: boolean;
  42656. /**
  42657. * If the scale gizmo is enabled
  42658. */
  42659. scaleGizmoEnabled: boolean;
  42660. /**
  42661. * If the boundingBox gizmo is enabled
  42662. */
  42663. boundingBoxGizmoEnabled: boolean;
  42664. /**
  42665. * Disposes of the gizmo manager
  42666. */
  42667. dispose(): void;
  42668. }
  42669. }
  42670. declare module BABYLON {
  42671. /**
  42672. * A directional light is defined by a direction (what a surprise!).
  42673. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42674. * 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.
  42675. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42676. */
  42677. export class DirectionalLight extends ShadowLight {
  42678. private _shadowFrustumSize;
  42679. /**
  42680. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42681. */
  42682. /**
  42683. * Specifies a fix frustum size for the shadow generation.
  42684. */
  42685. shadowFrustumSize: number;
  42686. private _shadowOrthoScale;
  42687. /**
  42688. * Gets the shadow projection scale against the optimal computed one.
  42689. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42690. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42691. */
  42692. /**
  42693. * Sets the shadow projection scale against the optimal computed one.
  42694. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42695. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42696. */
  42697. shadowOrthoScale: number;
  42698. /**
  42699. * Automatically compute the projection matrix to best fit (including all the casters)
  42700. * on each frame.
  42701. */
  42702. autoUpdateExtends: boolean;
  42703. private _orthoLeft;
  42704. private _orthoRight;
  42705. private _orthoTop;
  42706. private _orthoBottom;
  42707. /**
  42708. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42709. * The directional light is emitted from everywhere in the given direction.
  42710. * It can cast shadows.
  42711. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42712. * @param name The friendly name of the light
  42713. * @param direction The direction of the light
  42714. * @param scene The scene the light belongs to
  42715. */
  42716. constructor(name: string, direction: Vector3, scene: Scene);
  42717. /**
  42718. * Returns the string "DirectionalLight".
  42719. * @return The class name
  42720. */
  42721. getClassName(): string;
  42722. /**
  42723. * Returns the integer 1.
  42724. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42725. */
  42726. getTypeID(): number;
  42727. /**
  42728. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42729. * Returns the DirectionalLight Shadow projection matrix.
  42730. */
  42731. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42732. /**
  42733. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42734. * Returns the DirectionalLight Shadow projection matrix.
  42735. */
  42736. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42737. /**
  42738. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42739. * Returns the DirectionalLight Shadow projection matrix.
  42740. */
  42741. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42742. protected _buildUniformLayout(): void;
  42743. /**
  42744. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42745. * @param effect The effect to update
  42746. * @param lightIndex The index of the light in the effect to update
  42747. * @returns The directional light
  42748. */
  42749. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42750. /**
  42751. * Gets the minZ used for shadow according to both the scene and the light.
  42752. *
  42753. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42754. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42755. * @param activeCamera The camera we are returning the min for
  42756. * @returns the depth min z
  42757. */
  42758. getDepthMinZ(activeCamera: Camera): number;
  42759. /**
  42760. * Gets the maxZ used for shadow according to both the scene and the light.
  42761. *
  42762. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42763. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42764. * @param activeCamera The camera we are returning the max for
  42765. * @returns the depth max z
  42766. */
  42767. getDepthMaxZ(activeCamera: Camera): number;
  42768. /**
  42769. * Prepares the list of defines specific to the light type.
  42770. * @param defines the list of defines
  42771. * @param lightIndex defines the index of the light for the effect
  42772. */
  42773. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42774. }
  42775. }
  42776. declare module BABYLON {
  42777. /**
  42778. * Class containing static functions to help procedurally build meshes
  42779. */
  42780. export class HemisphereBuilder {
  42781. /**
  42782. * Creates a hemisphere mesh
  42783. * @param name defines the name of the mesh
  42784. * @param options defines the options used to create the mesh
  42785. * @param scene defines the hosting scene
  42786. * @returns the hemisphere mesh
  42787. */
  42788. static CreateHemisphere(name: string, options: {
  42789. segments?: number;
  42790. diameter?: number;
  42791. sideOrientation?: number;
  42792. }, scene: any): Mesh;
  42793. }
  42794. }
  42795. declare module BABYLON {
  42796. /**
  42797. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42798. * These values define a cone of light starting from the position, emitting toward the direction.
  42799. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42800. * and the exponent defines the speed of the decay of the light with distance (reach).
  42801. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42802. */
  42803. export class SpotLight extends ShadowLight {
  42804. private _angle;
  42805. private _innerAngle;
  42806. private _cosHalfAngle;
  42807. private _lightAngleScale;
  42808. private _lightAngleOffset;
  42809. /**
  42810. * Gets the cone angle of the spot light in Radians.
  42811. */
  42812. /**
  42813. * Sets the cone angle of the spot light in Radians.
  42814. */
  42815. angle: number;
  42816. /**
  42817. * Only used in gltf falloff mode, this defines the angle where
  42818. * the directional falloff will start before cutting at angle which could be seen
  42819. * as outer angle.
  42820. */
  42821. /**
  42822. * Only used in gltf falloff mode, this defines the angle where
  42823. * the directional falloff will start before cutting at angle which could be seen
  42824. * as outer angle.
  42825. */
  42826. innerAngle: number;
  42827. private _shadowAngleScale;
  42828. /**
  42829. * Allows scaling the angle of the light for shadow generation only.
  42830. */
  42831. /**
  42832. * Allows scaling the angle of the light for shadow generation only.
  42833. */
  42834. shadowAngleScale: number;
  42835. /**
  42836. * The light decay speed with the distance from the emission spot.
  42837. */
  42838. exponent: number;
  42839. private _projectionTextureMatrix;
  42840. /**
  42841. * Allows reading the projecton texture
  42842. */
  42843. readonly projectionTextureMatrix: Matrix;
  42844. protected _projectionTextureLightNear: number;
  42845. /**
  42846. * Gets the near clip of the Spotlight for texture projection.
  42847. */
  42848. /**
  42849. * Sets the near clip of the Spotlight for texture projection.
  42850. */
  42851. projectionTextureLightNear: number;
  42852. protected _projectionTextureLightFar: number;
  42853. /**
  42854. * Gets the far clip of the Spotlight for texture projection.
  42855. */
  42856. /**
  42857. * Sets the far clip of the Spotlight for texture projection.
  42858. */
  42859. projectionTextureLightFar: number;
  42860. protected _projectionTextureUpDirection: Vector3;
  42861. /**
  42862. * Gets the Up vector of the Spotlight for texture projection.
  42863. */
  42864. /**
  42865. * Sets the Up vector of the Spotlight for texture projection.
  42866. */
  42867. projectionTextureUpDirection: Vector3;
  42868. private _projectionTexture;
  42869. /**
  42870. * Gets the projection texture of the light.
  42871. */
  42872. /**
  42873. * Sets the projection texture of the light.
  42874. */
  42875. projectionTexture: Nullable<BaseTexture>;
  42876. private _projectionTextureViewLightDirty;
  42877. private _projectionTextureProjectionLightDirty;
  42878. private _projectionTextureDirty;
  42879. private _projectionTextureViewTargetVector;
  42880. private _projectionTextureViewLightMatrix;
  42881. private _projectionTextureProjectionLightMatrix;
  42882. private _projectionTextureScalingMatrix;
  42883. /**
  42884. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42885. * It can cast shadows.
  42886. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42887. * @param name The light friendly name
  42888. * @param position The position of the spot light in the scene
  42889. * @param direction The direction of the light in the scene
  42890. * @param angle The cone angle of the light in Radians
  42891. * @param exponent The light decay speed with the distance from the emission spot
  42892. * @param scene The scene the lights belongs to
  42893. */
  42894. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42895. /**
  42896. * Returns the string "SpotLight".
  42897. * @returns the class name
  42898. */
  42899. getClassName(): string;
  42900. /**
  42901. * Returns the integer 2.
  42902. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42903. */
  42904. getTypeID(): number;
  42905. /**
  42906. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42907. */
  42908. protected _setDirection(value: Vector3): void;
  42909. /**
  42910. * Overrides the position setter to recompute the projection texture view light Matrix.
  42911. */
  42912. protected _setPosition(value: Vector3): void;
  42913. /**
  42914. * 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.
  42915. * Returns the SpotLight.
  42916. */
  42917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42918. protected _computeProjectionTextureViewLightMatrix(): void;
  42919. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42920. /**
  42921. * Main function for light texture projection matrix computing.
  42922. */
  42923. protected _computeProjectionTextureMatrix(): void;
  42924. protected _buildUniformLayout(): void;
  42925. private _computeAngleValues;
  42926. /**
  42927. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42928. * @param effect The effect to update
  42929. * @param lightIndex The index of the light in the effect to update
  42930. * @returns The spot light
  42931. */
  42932. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42933. /**
  42934. * Disposes the light and the associated resources.
  42935. */
  42936. dispose(): void;
  42937. /**
  42938. * Prepares the list of defines specific to the light type.
  42939. * @param defines the list of defines
  42940. * @param lightIndex defines the index of the light for the effect
  42941. */
  42942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42943. }
  42944. }
  42945. declare module BABYLON {
  42946. /**
  42947. * Gizmo that enables viewing a light
  42948. */
  42949. export class LightGizmo extends Gizmo {
  42950. private _lightMesh;
  42951. private _material;
  42952. /**
  42953. * Creates a LightGizmo
  42954. * @param gizmoLayer The utility layer the gizmo will be added to
  42955. */
  42956. constructor(gizmoLayer?: UtilityLayerRenderer);
  42957. private _light;
  42958. /**
  42959. * The light that the gizmo is attached to
  42960. */
  42961. light: Nullable<Light>;
  42962. /**
  42963. * @hidden
  42964. * Updates the gizmo to match the attached mesh's position/rotation
  42965. */
  42966. protected _update(): void;
  42967. private static _Scale;
  42968. /**
  42969. * Creates the lines for a light mesh
  42970. */
  42971. private static _createLightLines;
  42972. private static _CreateHemisphericLightMesh;
  42973. private static _CreatePointLightMesh;
  42974. private static _CreateSpotLightMesh;
  42975. private static _CreateDirectionalLightMesh;
  42976. }
  42977. }
  42978. declare module BABYLON {
  42979. /** @hidden */
  42980. export var backgroundFragmentDeclaration: {
  42981. name: string;
  42982. shader: string;
  42983. };
  42984. }
  42985. declare module BABYLON {
  42986. /** @hidden */
  42987. export var backgroundUboDeclaration: {
  42988. name: string;
  42989. shader: string;
  42990. };
  42991. }
  42992. declare module BABYLON {
  42993. /** @hidden */
  42994. export var backgroundPixelShader: {
  42995. name: string;
  42996. shader: string;
  42997. };
  42998. }
  42999. declare module BABYLON {
  43000. /** @hidden */
  43001. export var backgroundVertexDeclaration: {
  43002. name: string;
  43003. shader: string;
  43004. };
  43005. }
  43006. declare module BABYLON {
  43007. /** @hidden */
  43008. export var backgroundVertexShader: {
  43009. name: string;
  43010. shader: string;
  43011. };
  43012. }
  43013. declare module BABYLON {
  43014. /**
  43015. * Background material used to create an efficient environement around your scene.
  43016. */
  43017. export class BackgroundMaterial extends PushMaterial {
  43018. /**
  43019. * Standard reflectance value at parallel view angle.
  43020. */
  43021. static StandardReflectance0: number;
  43022. /**
  43023. * Standard reflectance value at grazing angle.
  43024. */
  43025. static StandardReflectance90: number;
  43026. protected _primaryColor: Color3;
  43027. /**
  43028. * Key light Color (multiply against the environement texture)
  43029. */
  43030. primaryColor: Color3;
  43031. protected __perceptualColor: Nullable<Color3>;
  43032. /**
  43033. * Experimental Internal Use Only.
  43034. *
  43035. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43036. * This acts as a helper to set the primary color to a more "human friendly" value.
  43037. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43038. * output color as close as possible from the chosen value.
  43039. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43040. * part of lighting setup.)
  43041. */
  43042. _perceptualColor: Nullable<Color3>;
  43043. protected _primaryColorShadowLevel: float;
  43044. /**
  43045. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43046. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43047. */
  43048. primaryColorShadowLevel: float;
  43049. protected _primaryColorHighlightLevel: float;
  43050. /**
  43051. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43052. * The primary color is used at the level chosen to define what the white area would look.
  43053. */
  43054. primaryColorHighlightLevel: float;
  43055. protected _reflectionTexture: Nullable<BaseTexture>;
  43056. /**
  43057. * Reflection Texture used in the material.
  43058. * Should be author in a specific way for the best result (refer to the documentation).
  43059. */
  43060. reflectionTexture: Nullable<BaseTexture>;
  43061. protected _reflectionBlur: float;
  43062. /**
  43063. * Reflection Texture level of blur.
  43064. *
  43065. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43066. * texture twice.
  43067. */
  43068. reflectionBlur: float;
  43069. protected _diffuseTexture: Nullable<BaseTexture>;
  43070. /**
  43071. * Diffuse Texture used in the material.
  43072. * Should be author in a specific way for the best result (refer to the documentation).
  43073. */
  43074. diffuseTexture: Nullable<BaseTexture>;
  43075. protected _shadowLights: Nullable<IShadowLight[]>;
  43076. /**
  43077. * Specify the list of lights casting shadow on the material.
  43078. * All scene shadow lights will be included if null.
  43079. */
  43080. shadowLights: Nullable<IShadowLight[]>;
  43081. protected _shadowLevel: float;
  43082. /**
  43083. * Helps adjusting the shadow to a softer level if required.
  43084. * 0 means black shadows and 1 means no shadows.
  43085. */
  43086. shadowLevel: float;
  43087. protected _sceneCenter: Vector3;
  43088. /**
  43089. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43090. * It is usually zero but might be interesting to modify according to your setup.
  43091. */
  43092. sceneCenter: Vector3;
  43093. protected _opacityFresnel: boolean;
  43094. /**
  43095. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43096. * This helps ensuring a nice transition when the camera goes under the ground.
  43097. */
  43098. opacityFresnel: boolean;
  43099. protected _reflectionFresnel: boolean;
  43100. /**
  43101. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43102. * This helps adding a mirror texture on the ground.
  43103. */
  43104. reflectionFresnel: boolean;
  43105. protected _reflectionFalloffDistance: number;
  43106. /**
  43107. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43108. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43109. */
  43110. reflectionFalloffDistance: number;
  43111. protected _reflectionAmount: number;
  43112. /**
  43113. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43114. */
  43115. reflectionAmount: number;
  43116. protected _reflectionReflectance0: number;
  43117. /**
  43118. * This specifies the weight of the reflection at grazing angle.
  43119. */
  43120. reflectionReflectance0: number;
  43121. protected _reflectionReflectance90: number;
  43122. /**
  43123. * This specifies the weight of the reflection at a perpendicular point of view.
  43124. */
  43125. reflectionReflectance90: number;
  43126. /**
  43127. * Sets the reflection reflectance fresnel values according to the default standard
  43128. * empirically know to work well :-)
  43129. */
  43130. reflectionStandardFresnelWeight: number;
  43131. protected _useRGBColor: boolean;
  43132. /**
  43133. * Helps to directly use the maps channels instead of their level.
  43134. */
  43135. useRGBColor: boolean;
  43136. protected _enableNoise: boolean;
  43137. /**
  43138. * This helps reducing the banding effect that could occur on the background.
  43139. */
  43140. enableNoise: boolean;
  43141. /**
  43142. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43143. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43144. * Recommended to be keep at 1.0 except for special cases.
  43145. */
  43146. fovMultiplier: number;
  43147. private _fovMultiplier;
  43148. /**
  43149. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43150. */
  43151. useEquirectangularFOV: boolean;
  43152. private _maxSimultaneousLights;
  43153. /**
  43154. * Number of Simultaneous lights allowed on the material.
  43155. */
  43156. maxSimultaneousLights: int;
  43157. /**
  43158. * Default configuration related to image processing available in the Background Material.
  43159. */
  43160. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43161. /**
  43162. * Keep track of the image processing observer to allow dispose and replace.
  43163. */
  43164. private _imageProcessingObserver;
  43165. /**
  43166. * Attaches a new image processing configuration to the PBR Material.
  43167. * @param configuration (if null the scene configuration will be use)
  43168. */
  43169. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43170. /**
  43171. * Gets the image processing configuration used either in this material.
  43172. */
  43173. /**
  43174. * Sets the Default image processing configuration used either in the this material.
  43175. *
  43176. * If sets to null, the scene one is in use.
  43177. */
  43178. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43179. /**
  43180. * Gets wether the color curves effect is enabled.
  43181. */
  43182. /**
  43183. * Sets wether the color curves effect is enabled.
  43184. */
  43185. cameraColorCurvesEnabled: boolean;
  43186. /**
  43187. * Gets wether the color grading effect is enabled.
  43188. */
  43189. /**
  43190. * Gets wether the color grading effect is enabled.
  43191. */
  43192. cameraColorGradingEnabled: boolean;
  43193. /**
  43194. * Gets wether tonemapping is enabled or not.
  43195. */
  43196. /**
  43197. * Sets wether tonemapping is enabled or not
  43198. */
  43199. cameraToneMappingEnabled: boolean;
  43200. /**
  43201. * The camera exposure used on this material.
  43202. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43203. * This corresponds to a photographic exposure.
  43204. */
  43205. /**
  43206. * The camera exposure used on this material.
  43207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43208. * This corresponds to a photographic exposure.
  43209. */
  43210. cameraExposure: float;
  43211. /**
  43212. * Gets The camera contrast used on this material.
  43213. */
  43214. /**
  43215. * Sets The camera contrast used on this material.
  43216. */
  43217. cameraContrast: float;
  43218. /**
  43219. * Gets the Color Grading 2D Lookup Texture.
  43220. */
  43221. /**
  43222. * Sets the Color Grading 2D Lookup Texture.
  43223. */
  43224. cameraColorGradingTexture: Nullable<BaseTexture>;
  43225. /**
  43226. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43227. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43228. * 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;
  43229. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43230. */
  43231. /**
  43232. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43233. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43234. * 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;
  43235. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43236. */
  43237. cameraColorCurves: Nullable<ColorCurves>;
  43238. /**
  43239. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43240. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43241. */
  43242. switchToBGR: boolean;
  43243. private _renderTargets;
  43244. private _reflectionControls;
  43245. private _white;
  43246. private _primaryShadowColor;
  43247. private _primaryHighlightColor;
  43248. /**
  43249. * Instantiates a Background Material in the given scene
  43250. * @param name The friendly name of the material
  43251. * @param scene The scene to add the material to
  43252. */
  43253. constructor(name: string, scene: Scene);
  43254. /**
  43255. * Gets a boolean indicating that current material needs to register RTT
  43256. */
  43257. readonly hasRenderTargetTextures: boolean;
  43258. /**
  43259. * The entire material has been created in order to prevent overdraw.
  43260. * @returns false
  43261. */
  43262. needAlphaTesting(): boolean;
  43263. /**
  43264. * The entire material has been created in order to prevent overdraw.
  43265. * @returns true if blending is enable
  43266. */
  43267. needAlphaBlending(): boolean;
  43268. /**
  43269. * Checks wether the material is ready to be rendered for a given mesh.
  43270. * @param mesh The mesh to render
  43271. * @param subMesh The submesh to check against
  43272. * @param useInstances Specify wether or not the material is used with instances
  43273. * @returns true if all the dependencies are ready (Textures, Effects...)
  43274. */
  43275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43276. /**
  43277. * Compute the primary color according to the chosen perceptual color.
  43278. */
  43279. private _computePrimaryColorFromPerceptualColor;
  43280. /**
  43281. * Compute the highlights and shadow colors according to their chosen levels.
  43282. */
  43283. private _computePrimaryColors;
  43284. /**
  43285. * Build the uniform buffer used in the material.
  43286. */
  43287. buildUniformLayout(): void;
  43288. /**
  43289. * Unbind the material.
  43290. */
  43291. unbind(): void;
  43292. /**
  43293. * Bind only the world matrix to the material.
  43294. * @param world The world matrix to bind.
  43295. */
  43296. bindOnlyWorldMatrix(world: Matrix): void;
  43297. /**
  43298. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43299. * @param world The world matrix to bind.
  43300. * @param subMesh The submesh to bind for.
  43301. */
  43302. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43303. /**
  43304. * Dispose the material.
  43305. * @param forceDisposeEffect Force disposal of the associated effect.
  43306. * @param forceDisposeTextures Force disposal of the associated textures.
  43307. */
  43308. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43309. /**
  43310. * Clones the material.
  43311. * @param name The cloned name.
  43312. * @returns The cloned material.
  43313. */
  43314. clone(name: string): BackgroundMaterial;
  43315. /**
  43316. * Serializes the current material to its JSON representation.
  43317. * @returns The JSON representation.
  43318. */
  43319. serialize(): any;
  43320. /**
  43321. * Gets the class name of the material
  43322. * @returns "BackgroundMaterial"
  43323. */
  43324. getClassName(): string;
  43325. /**
  43326. * Parse a JSON input to create back a background material.
  43327. * @param source The JSON data to parse
  43328. * @param scene The scene to create the parsed material in
  43329. * @param rootUrl The root url of the assets the material depends upon
  43330. * @returns the instantiated BackgroundMaterial.
  43331. */
  43332. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43333. }
  43334. }
  43335. declare module BABYLON {
  43336. /**
  43337. * Represents the different options available during the creation of
  43338. * a Environment helper.
  43339. *
  43340. * This can control the default ground, skybox and image processing setup of your scene.
  43341. */
  43342. export interface IEnvironmentHelperOptions {
  43343. /**
  43344. * Specifies wether or not to create a ground.
  43345. * True by default.
  43346. */
  43347. createGround: boolean;
  43348. /**
  43349. * Specifies the ground size.
  43350. * 15 by default.
  43351. */
  43352. groundSize: number;
  43353. /**
  43354. * The texture used on the ground for the main color.
  43355. * Comes from the BabylonJS CDN by default.
  43356. *
  43357. * Remarks: Can be either a texture or a url.
  43358. */
  43359. groundTexture: string | BaseTexture;
  43360. /**
  43361. * The color mixed in the ground texture by default.
  43362. * BabylonJS clearColor by default.
  43363. */
  43364. groundColor: Color3;
  43365. /**
  43366. * Specifies the ground opacity.
  43367. * 1 by default.
  43368. */
  43369. groundOpacity: number;
  43370. /**
  43371. * Enables the ground to receive shadows.
  43372. * True by default.
  43373. */
  43374. enableGroundShadow: boolean;
  43375. /**
  43376. * Helps preventing the shadow to be fully black on the ground.
  43377. * 0.5 by default.
  43378. */
  43379. groundShadowLevel: number;
  43380. /**
  43381. * Creates a mirror texture attach to the ground.
  43382. * false by default.
  43383. */
  43384. enableGroundMirror: boolean;
  43385. /**
  43386. * Specifies the ground mirror size ratio.
  43387. * 0.3 by default as the default kernel is 64.
  43388. */
  43389. groundMirrorSizeRatio: number;
  43390. /**
  43391. * Specifies the ground mirror blur kernel size.
  43392. * 64 by default.
  43393. */
  43394. groundMirrorBlurKernel: number;
  43395. /**
  43396. * Specifies the ground mirror visibility amount.
  43397. * 1 by default
  43398. */
  43399. groundMirrorAmount: number;
  43400. /**
  43401. * Specifies the ground mirror reflectance weight.
  43402. * This uses the standard weight of the background material to setup the fresnel effect
  43403. * of the mirror.
  43404. * 1 by default.
  43405. */
  43406. groundMirrorFresnelWeight: number;
  43407. /**
  43408. * Specifies the ground mirror Falloff distance.
  43409. * This can helps reducing the size of the reflection.
  43410. * 0 by Default.
  43411. */
  43412. groundMirrorFallOffDistance: number;
  43413. /**
  43414. * Specifies the ground mirror texture type.
  43415. * Unsigned Int by Default.
  43416. */
  43417. groundMirrorTextureType: number;
  43418. /**
  43419. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43420. * the shown objects.
  43421. */
  43422. groundYBias: number;
  43423. /**
  43424. * Specifies wether or not to create a skybox.
  43425. * True by default.
  43426. */
  43427. createSkybox: boolean;
  43428. /**
  43429. * Specifies the skybox size.
  43430. * 20 by default.
  43431. */
  43432. skyboxSize: number;
  43433. /**
  43434. * The texture used on the skybox for the main color.
  43435. * Comes from the BabylonJS CDN by default.
  43436. *
  43437. * Remarks: Can be either a texture or a url.
  43438. */
  43439. skyboxTexture: string | BaseTexture;
  43440. /**
  43441. * The color mixed in the skybox texture by default.
  43442. * BabylonJS clearColor by default.
  43443. */
  43444. skyboxColor: Color3;
  43445. /**
  43446. * The background rotation around the Y axis of the scene.
  43447. * This helps aligning the key lights of your scene with the background.
  43448. * 0 by default.
  43449. */
  43450. backgroundYRotation: number;
  43451. /**
  43452. * Compute automatically the size of the elements to best fit with the scene.
  43453. */
  43454. sizeAuto: boolean;
  43455. /**
  43456. * Default position of the rootMesh if autoSize is not true.
  43457. */
  43458. rootPosition: Vector3;
  43459. /**
  43460. * Sets up the image processing in the scene.
  43461. * true by default.
  43462. */
  43463. setupImageProcessing: boolean;
  43464. /**
  43465. * The texture used as your environment texture in the scene.
  43466. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43467. *
  43468. * Remarks: Can be either a texture or a url.
  43469. */
  43470. environmentTexture: string | BaseTexture;
  43471. /**
  43472. * The value of the exposure to apply to the scene.
  43473. * 0.6 by default if setupImageProcessing is true.
  43474. */
  43475. cameraExposure: number;
  43476. /**
  43477. * The value of the contrast to apply to the scene.
  43478. * 1.6 by default if setupImageProcessing is true.
  43479. */
  43480. cameraContrast: number;
  43481. /**
  43482. * Specifies wether or not tonemapping should be enabled in the scene.
  43483. * true by default if setupImageProcessing is true.
  43484. */
  43485. toneMappingEnabled: boolean;
  43486. }
  43487. /**
  43488. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43489. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43490. * It also helps with the default setup of your imageProcessing configuration.
  43491. */
  43492. export class EnvironmentHelper {
  43493. /**
  43494. * Default ground texture URL.
  43495. */
  43496. private static _groundTextureCDNUrl;
  43497. /**
  43498. * Default skybox texture URL.
  43499. */
  43500. private static _skyboxTextureCDNUrl;
  43501. /**
  43502. * Default environment texture URL.
  43503. */
  43504. private static _environmentTextureCDNUrl;
  43505. /**
  43506. * Creates the default options for the helper.
  43507. */
  43508. private static _getDefaultOptions;
  43509. private _rootMesh;
  43510. /**
  43511. * Gets the root mesh created by the helper.
  43512. */
  43513. readonly rootMesh: Mesh;
  43514. private _skybox;
  43515. /**
  43516. * Gets the skybox created by the helper.
  43517. */
  43518. readonly skybox: Nullable<Mesh>;
  43519. private _skyboxTexture;
  43520. /**
  43521. * Gets the skybox texture created by the helper.
  43522. */
  43523. readonly skyboxTexture: Nullable<BaseTexture>;
  43524. private _skyboxMaterial;
  43525. /**
  43526. * Gets the skybox material created by the helper.
  43527. */
  43528. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43529. private _ground;
  43530. /**
  43531. * Gets the ground mesh created by the helper.
  43532. */
  43533. readonly ground: Nullable<Mesh>;
  43534. private _groundTexture;
  43535. /**
  43536. * Gets the ground texture created by the helper.
  43537. */
  43538. readonly groundTexture: Nullable<BaseTexture>;
  43539. private _groundMirror;
  43540. /**
  43541. * Gets the ground mirror created by the helper.
  43542. */
  43543. readonly groundMirror: Nullable<MirrorTexture>;
  43544. /**
  43545. * Gets the ground mirror render list to helps pushing the meshes
  43546. * you wish in the ground reflection.
  43547. */
  43548. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43549. private _groundMaterial;
  43550. /**
  43551. * Gets the ground material created by the helper.
  43552. */
  43553. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43554. /**
  43555. * Stores the creation options.
  43556. */
  43557. private readonly _scene;
  43558. private _options;
  43559. /**
  43560. * This observable will be notified with any error during the creation of the environment,
  43561. * mainly texture creation errors.
  43562. */
  43563. onErrorObservable: Observable<{
  43564. message?: string;
  43565. exception?: any;
  43566. }>;
  43567. /**
  43568. * constructor
  43569. * @param options Defines the options we want to customize the helper
  43570. * @param scene The scene to add the material to
  43571. */
  43572. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43573. /**
  43574. * Updates the background according to the new options
  43575. * @param options
  43576. */
  43577. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43578. /**
  43579. * Sets the primary color of all the available elements.
  43580. * @param color the main color to affect to the ground and the background
  43581. */
  43582. setMainColor(color: Color3): void;
  43583. /**
  43584. * Setup the image processing according to the specified options.
  43585. */
  43586. private _setupImageProcessing;
  43587. /**
  43588. * Setup the environment texture according to the specified options.
  43589. */
  43590. private _setupEnvironmentTexture;
  43591. /**
  43592. * Setup the background according to the specified options.
  43593. */
  43594. private _setupBackground;
  43595. /**
  43596. * Get the scene sizes according to the setup.
  43597. */
  43598. private _getSceneSize;
  43599. /**
  43600. * Setup the ground according to the specified options.
  43601. */
  43602. private _setupGround;
  43603. /**
  43604. * Setup the ground material according to the specified options.
  43605. */
  43606. private _setupGroundMaterial;
  43607. /**
  43608. * Setup the ground diffuse texture according to the specified options.
  43609. */
  43610. private _setupGroundDiffuseTexture;
  43611. /**
  43612. * Setup the ground mirror texture according to the specified options.
  43613. */
  43614. private _setupGroundMirrorTexture;
  43615. /**
  43616. * Setup the ground to receive the mirror texture.
  43617. */
  43618. private _setupMirrorInGroundMaterial;
  43619. /**
  43620. * Setup the skybox according to the specified options.
  43621. */
  43622. private _setupSkybox;
  43623. /**
  43624. * Setup the skybox material according to the specified options.
  43625. */
  43626. private _setupSkyboxMaterial;
  43627. /**
  43628. * Setup the skybox reflection texture according to the specified options.
  43629. */
  43630. private _setupSkyboxReflectionTexture;
  43631. private _errorHandler;
  43632. /**
  43633. * Dispose all the elements created by the Helper.
  43634. */
  43635. dispose(): void;
  43636. }
  43637. }
  43638. declare module BABYLON {
  43639. /**
  43640. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43641. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43642. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43643. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43644. */
  43645. export class PhotoDome extends TransformNode {
  43646. private _useDirectMapping;
  43647. /**
  43648. * The texture being displayed on the sphere
  43649. */
  43650. protected _photoTexture: Texture;
  43651. /**
  43652. * Gets or sets the texture being displayed on the sphere
  43653. */
  43654. photoTexture: Texture;
  43655. /**
  43656. * Observable raised when an error occured while loading the 360 image
  43657. */
  43658. onLoadErrorObservable: Observable<string>;
  43659. /**
  43660. * The skybox material
  43661. */
  43662. protected _material: BackgroundMaterial;
  43663. /**
  43664. * The surface used for the skybox
  43665. */
  43666. protected _mesh: Mesh;
  43667. /**
  43668. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43669. * Also see the options.resolution property.
  43670. */
  43671. fovMultiplier: number;
  43672. /**
  43673. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43674. * @param name Element's name, child elements will append suffixes for their own names.
  43675. * @param urlsOfPhoto defines the url of the photo to display
  43676. * @param options defines an object containing optional or exposed sub element properties
  43677. * @param onError defines a callback called when an error occured while loading the texture
  43678. */
  43679. constructor(name: string, urlOfPhoto: string, options: {
  43680. resolution?: number;
  43681. size?: number;
  43682. useDirectMapping?: boolean;
  43683. faceForward?: boolean;
  43684. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43685. /**
  43686. * Releases resources associated with this node.
  43687. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43688. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43689. */
  43690. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /** @hidden */
  43695. export var rgbdDecodePixelShader: {
  43696. name: string;
  43697. shader: string;
  43698. };
  43699. }
  43700. declare module BABYLON {
  43701. /**
  43702. * Class used to host texture specific utilities
  43703. */
  43704. export class BRDFTextureTools {
  43705. /**
  43706. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43707. * @param texture the texture to expand.
  43708. */
  43709. private static _ExpandDefaultBRDFTexture;
  43710. /**
  43711. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43712. * @param scene defines the hosting scene
  43713. * @returns the environment BRDF texture
  43714. */
  43715. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43716. private static _environmentBRDFBase64Texture;
  43717. }
  43718. }
  43719. declare module BABYLON {
  43720. /**
  43721. * @hidden
  43722. */
  43723. export interface IMaterialClearCoatDefines {
  43724. CLEARCOAT: boolean;
  43725. CLEARCOAT_DEFAULTIOR: boolean;
  43726. CLEARCOAT_TEXTURE: boolean;
  43727. CLEARCOAT_TEXTUREDIRECTUV: number;
  43728. CLEARCOAT_BUMP: boolean;
  43729. CLEARCOAT_BUMPDIRECTUV: number;
  43730. CLEARCOAT_TINT: boolean;
  43731. CLEARCOAT_TINT_TEXTURE: boolean;
  43732. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43733. /** @hidden */
  43734. _areTexturesDirty: boolean;
  43735. }
  43736. /**
  43737. * Define the code related to the clear coat parameters of the pbr material.
  43738. */
  43739. export class PBRClearCoatConfiguration {
  43740. /**
  43741. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43742. * The default fits with a polyurethane material.
  43743. */
  43744. private static readonly _DefaultIndiceOfRefraction;
  43745. private _isEnabled;
  43746. /**
  43747. * Defines if the clear coat is enabled in the material.
  43748. */
  43749. isEnabled: boolean;
  43750. /**
  43751. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43752. */
  43753. intensity: number;
  43754. /**
  43755. * Defines the clear coat layer roughness.
  43756. */
  43757. roughness: number;
  43758. private _indiceOfRefraction;
  43759. /**
  43760. * Defines the indice of refraction of the clear coat.
  43761. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43762. * The default fits with a polyurethane material.
  43763. * Changing the default value is more performance intensive.
  43764. */
  43765. indiceOfRefraction: number;
  43766. private _texture;
  43767. /**
  43768. * Stores the clear coat values in a texture.
  43769. */
  43770. texture: Nullable<BaseTexture>;
  43771. private _bumpTexture;
  43772. /**
  43773. * Define the clear coat specific bump texture.
  43774. */
  43775. bumpTexture: Nullable<BaseTexture>;
  43776. private _isTintEnabled;
  43777. /**
  43778. * Defines if the clear coat tint is enabled in the material.
  43779. */
  43780. isTintEnabled: boolean;
  43781. /**
  43782. * Defines the clear coat tint of the material.
  43783. * This is only use if tint is enabled
  43784. */
  43785. tintColor: Color3;
  43786. /**
  43787. * Defines the distance at which the tint color should be found in the
  43788. * clear coat media.
  43789. * This is only use if tint is enabled
  43790. */
  43791. tintColorAtDistance: number;
  43792. /**
  43793. * Defines the clear coat layer thickness.
  43794. * This is only use if tint is enabled
  43795. */
  43796. tintThickness: number;
  43797. private _tintTexture;
  43798. /**
  43799. * Stores the clear tint values in a texture.
  43800. * rgb is tint
  43801. * a is a thickness factor
  43802. */
  43803. tintTexture: Nullable<BaseTexture>;
  43804. /** @hidden */
  43805. private _internalMarkAllSubMeshesAsTexturesDirty;
  43806. /** @hidden */
  43807. _markAllSubMeshesAsTexturesDirty(): void;
  43808. /**
  43809. * Instantiate a new istance of clear coat configuration.
  43810. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43811. */
  43812. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43813. /**
  43814. * Gets wehter the submesh is ready to be used or not.
  43815. * @param defines the list of "defines" to update.
  43816. * @param scene defines the scene the material belongs to.
  43817. * @param engine defines the engine the material belongs to.
  43818. * @param disableBumpMap defines wether the material disables bump or not.
  43819. * @returns - boolean indicating that the submesh is ready or not.
  43820. */
  43821. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43822. /**
  43823. * Checks to see if a texture is used in the material.
  43824. * @param defines the list of "defines" to update.
  43825. * @param scene defines the scene to the material belongs to.
  43826. */
  43827. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43828. /**
  43829. * Binds the material data.
  43830. * @param uniformBuffer defines the Uniform buffer to fill in.
  43831. * @param scene defines the scene the material belongs to.
  43832. * @param engine defines the engine the material belongs to.
  43833. * @param disableBumpMap defines wether the material disables bump or not.
  43834. * @param isFrozen defines wether the material is frozen or not.
  43835. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43836. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43837. */
  43838. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43839. /**
  43840. * Checks to see if a texture is used in the material.
  43841. * @param texture - Base texture to use.
  43842. * @returns - Boolean specifying if a texture is used in the material.
  43843. */
  43844. hasTexture(texture: BaseTexture): boolean;
  43845. /**
  43846. * Returns an array of the actively used textures.
  43847. * @param activeTextures Array of BaseTextures
  43848. */
  43849. getActiveTextures(activeTextures: BaseTexture[]): void;
  43850. /**
  43851. * Returns the animatable textures.
  43852. * @param animatables Array of animatable textures.
  43853. */
  43854. getAnimatables(animatables: IAnimatable[]): void;
  43855. /**
  43856. * Disposes the resources of the material.
  43857. * @param forceDisposeTextures - Forces the disposal of all textures.
  43858. */
  43859. dispose(forceDisposeTextures?: boolean): void;
  43860. /**
  43861. * Get the current class name of the texture useful for serialization or dynamic coding.
  43862. * @returns "PBRClearCoatConfiguration"
  43863. */
  43864. getClassName(): string;
  43865. /**
  43866. * Add fallbacks to the effect fallbacks list.
  43867. * @param defines defines the Base texture to use.
  43868. * @param fallbacks defines the current fallback list.
  43869. * @param currentRank defines the current fallback rank.
  43870. * @returns the new fallback rank.
  43871. */
  43872. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43873. /**
  43874. * Add the required uniforms to the current list.
  43875. * @param uniforms defines the current uniform list.
  43876. */
  43877. static AddUniforms(uniforms: string[]): void;
  43878. /**
  43879. * Add the required samplers to the current list.
  43880. * @param samplers defines the current sampler list.
  43881. */
  43882. static AddSamplers(samplers: string[]): void;
  43883. /**
  43884. * Add the required uniforms to the current buffer.
  43885. * @param uniformBuffer defines the current uniform buffer.
  43886. */
  43887. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43888. /**
  43889. * Makes a duplicate of the current configuration into another one.
  43890. * @param clearCoatConfiguration define the config where to copy the info
  43891. */
  43892. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43893. /**
  43894. * Serializes this clear coat configuration.
  43895. * @returns - An object with the serialized config.
  43896. */
  43897. serialize(): any;
  43898. /**
  43899. * Parses a Clear Coat Configuration from a serialized object.
  43900. * @param source - Serialized object.
  43901. */
  43902. parse(source: any): void;
  43903. }
  43904. }
  43905. declare module BABYLON {
  43906. /**
  43907. * @hidden
  43908. */
  43909. export interface IMaterialAnisotropicDefines {
  43910. ANISOTROPIC: boolean;
  43911. ANISOTROPIC_TEXTURE: boolean;
  43912. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43913. MAINUV1: boolean;
  43914. _areTexturesDirty: boolean;
  43915. _needUVs: boolean;
  43916. }
  43917. /**
  43918. * Define the code related to the anisotropic parameters of the pbr material.
  43919. */
  43920. export class PBRAnisotropicConfiguration {
  43921. private _isEnabled;
  43922. /**
  43923. * Defines if the anisotropy is enabled in the material.
  43924. */
  43925. isEnabled: boolean;
  43926. /**
  43927. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43928. */
  43929. intensity: number;
  43930. /**
  43931. * Defines if the effect is along the tangents, bitangents or in between.
  43932. * By default, the effect is "strectching" the highlights along the tangents.
  43933. */
  43934. direction: Vector2;
  43935. private _texture;
  43936. /**
  43937. * Stores the anisotropy values in a texture.
  43938. * rg is direction (like normal from -1 to 1)
  43939. * b is a intensity
  43940. */
  43941. texture: Nullable<BaseTexture>;
  43942. /** @hidden */
  43943. private _internalMarkAllSubMeshesAsTexturesDirty;
  43944. /** @hidden */
  43945. _markAllSubMeshesAsTexturesDirty(): void;
  43946. /**
  43947. * Instantiate a new istance of anisotropy configuration.
  43948. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43949. */
  43950. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43951. /**
  43952. * Specifies that the submesh is ready to be used.
  43953. * @param defines the list of "defines" to update.
  43954. * @param scene defines the scene the material belongs to.
  43955. * @returns - boolean indicating that the submesh is ready or not.
  43956. */
  43957. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43958. /**
  43959. * Checks to see if a texture is used in the material.
  43960. * @param defines the list of "defines" to update.
  43961. * @param mesh the mesh we are preparing the defines for.
  43962. * @param scene defines the scene the material belongs to.
  43963. */
  43964. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43965. /**
  43966. * Binds the material data.
  43967. * @param uniformBuffer defines the Uniform buffer to fill in.
  43968. * @param scene defines the scene the material belongs to.
  43969. * @param isFrozen defines wether the material is frozen or not.
  43970. */
  43971. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43972. /**
  43973. * Checks to see if a texture is used in the material.
  43974. * @param texture - Base texture to use.
  43975. * @returns - Boolean specifying if a texture is used in the material.
  43976. */
  43977. hasTexture(texture: BaseTexture): boolean;
  43978. /**
  43979. * Returns an array of the actively used textures.
  43980. * @param activeTextures Array of BaseTextures
  43981. */
  43982. getActiveTextures(activeTextures: BaseTexture[]): void;
  43983. /**
  43984. * Returns the animatable textures.
  43985. * @param animatables Array of animatable textures.
  43986. */
  43987. getAnimatables(animatables: IAnimatable[]): void;
  43988. /**
  43989. * Disposes the resources of the material.
  43990. * @param forceDisposeTextures - Forces the disposal of all textures.
  43991. */
  43992. dispose(forceDisposeTextures?: boolean): void;
  43993. /**
  43994. * Get the current class name of the texture useful for serialization or dynamic coding.
  43995. * @returns "PBRAnisotropicConfiguration"
  43996. */
  43997. getClassName(): string;
  43998. /**
  43999. * Add fallbacks to the effect fallbacks list.
  44000. * @param defines defines the Base texture to use.
  44001. * @param fallbacks defines the current fallback list.
  44002. * @param currentRank defines the current fallback rank.
  44003. * @returns the new fallback rank.
  44004. */
  44005. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44006. /**
  44007. * Add the required uniforms to the current list.
  44008. * @param uniforms defines the current uniform list.
  44009. */
  44010. static AddUniforms(uniforms: string[]): void;
  44011. /**
  44012. * Add the required uniforms to the current buffer.
  44013. * @param uniformBuffer defines the current uniform buffer.
  44014. */
  44015. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44016. /**
  44017. * Add the required samplers to the current list.
  44018. * @param samplers defines the current sampler list.
  44019. */
  44020. static AddSamplers(samplers: string[]): void;
  44021. /**
  44022. * Makes a duplicate of the current configuration into another one.
  44023. * @param anisotropicConfiguration define the config where to copy the info
  44024. */
  44025. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44026. /**
  44027. * Serializes this anisotropy configuration.
  44028. * @returns - An object with the serialized config.
  44029. */
  44030. serialize(): any;
  44031. /**
  44032. * Parses a anisotropy Configuration from a serialized object.
  44033. * @param source - Serialized object.
  44034. */
  44035. parse(source: any): void;
  44036. }
  44037. }
  44038. declare module BABYLON {
  44039. /**
  44040. * @hidden
  44041. */
  44042. export interface IMaterialBRDFDefines {
  44043. BRDF_V_HEIGHT_CORRELATED: boolean;
  44044. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44045. /** @hidden */
  44046. _areMiscDirty: boolean;
  44047. }
  44048. /**
  44049. * Define the code related to the BRDF parameters of the pbr material.
  44050. */
  44051. export class PBRBRDFConfiguration {
  44052. /**
  44053. * Default value used for the energy conservation.
  44054. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44055. */
  44056. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44057. /**
  44058. * Default value used for the Smith Visibility Height Correlated mode.
  44059. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44060. */
  44061. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44062. private _useEnergyConservation;
  44063. /**
  44064. * Defines if the material uses energy conservation.
  44065. */
  44066. useEnergyConservation: boolean;
  44067. private _useSmithVisibilityHeightCorrelated;
  44068. /**
  44069. * LEGACY Mode set to false
  44070. * Defines if the material uses height smith correlated visibility term.
  44071. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44072. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44073. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44074. * Not relying on height correlated will also disable energy conservation.
  44075. */
  44076. useSmithVisibilityHeightCorrelated: boolean;
  44077. /** @hidden */
  44078. private _internalMarkAllSubMeshesAsMiscDirty;
  44079. /** @hidden */
  44080. _markAllSubMeshesAsMiscDirty(): void;
  44081. /**
  44082. * Instantiate a new istance of clear coat configuration.
  44083. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44084. */
  44085. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44086. /**
  44087. * Checks to see if a texture is used in the material.
  44088. * @param defines the list of "defines" to update.
  44089. */
  44090. prepareDefines(defines: IMaterialBRDFDefines): void;
  44091. /**
  44092. * Get the current class name of the texture useful for serialization or dynamic coding.
  44093. * @returns "PBRClearCoatConfiguration"
  44094. */
  44095. getClassName(): string;
  44096. /**
  44097. * Makes a duplicate of the current configuration into another one.
  44098. * @param brdfConfiguration define the config where to copy the info
  44099. */
  44100. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44101. /**
  44102. * Serializes this BRDF configuration.
  44103. * @returns - An object with the serialized config.
  44104. */
  44105. serialize(): any;
  44106. /**
  44107. * Parses a BRDF Configuration from a serialized object.
  44108. * @param source - Serialized object.
  44109. */
  44110. parse(source: any): void;
  44111. }
  44112. }
  44113. declare module BABYLON {
  44114. /**
  44115. * @hidden
  44116. */
  44117. export interface IMaterialSheenDefines {
  44118. SHEEN: boolean;
  44119. SHEEN_TEXTURE: boolean;
  44120. SHEEN_TEXTUREDIRECTUV: number;
  44121. SHEEN_LINKWITHALBEDO: boolean;
  44122. /** @hidden */
  44123. _areTexturesDirty: boolean;
  44124. }
  44125. /**
  44126. * Define the code related to the Sheen parameters of the pbr material.
  44127. */
  44128. export class PBRSheenConfiguration {
  44129. private _isEnabled;
  44130. /**
  44131. * Defines if the material uses sheen.
  44132. */
  44133. isEnabled: boolean;
  44134. private _linkSheenWithAlbedo;
  44135. /**
  44136. * Defines if the sheen is linked to the sheen color.
  44137. */
  44138. linkSheenWithAlbedo: boolean;
  44139. /**
  44140. * Defines the sheen intensity.
  44141. */
  44142. intensity: number;
  44143. /**
  44144. * Defines the sheen color.
  44145. */
  44146. color: Color3;
  44147. private _texture;
  44148. /**
  44149. * Stores the sheen tint values in a texture.
  44150. * rgb is tint
  44151. * a is a intensity
  44152. */
  44153. texture: Nullable<BaseTexture>;
  44154. /** @hidden */
  44155. private _internalMarkAllSubMeshesAsTexturesDirty;
  44156. /** @hidden */
  44157. _markAllSubMeshesAsTexturesDirty(): void;
  44158. /**
  44159. * Instantiate a new istance of clear coat configuration.
  44160. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44161. */
  44162. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44163. /**
  44164. * Specifies that the submesh is ready to be used.
  44165. * @param defines the list of "defines" to update.
  44166. * @param scene defines the scene the material belongs to.
  44167. * @returns - boolean indicating that the submesh is ready or not.
  44168. */
  44169. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44170. /**
  44171. * Checks to see if a texture is used in the material.
  44172. * @param defines the list of "defines" to update.
  44173. * @param scene defines the scene the material belongs to.
  44174. */
  44175. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44176. /**
  44177. * Binds the material data.
  44178. * @param uniformBuffer defines the Uniform buffer to fill in.
  44179. * @param scene defines the scene the material belongs to.
  44180. * @param isFrozen defines wether the material is frozen or not.
  44181. */
  44182. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44183. /**
  44184. * Checks to see if a texture is used in the material.
  44185. * @param texture - Base texture to use.
  44186. * @returns - Boolean specifying if a texture is used in the material.
  44187. */
  44188. hasTexture(texture: BaseTexture): boolean;
  44189. /**
  44190. * Returns an array of the actively used textures.
  44191. * @param activeTextures Array of BaseTextures
  44192. */
  44193. getActiveTextures(activeTextures: BaseTexture[]): void;
  44194. /**
  44195. * Returns the animatable textures.
  44196. * @param animatables Array of animatable textures.
  44197. */
  44198. getAnimatables(animatables: IAnimatable[]): void;
  44199. /**
  44200. * Disposes the resources of the material.
  44201. * @param forceDisposeTextures - Forces the disposal of all textures.
  44202. */
  44203. dispose(forceDisposeTextures?: boolean): void;
  44204. /**
  44205. * Get the current class name of the texture useful for serialization or dynamic coding.
  44206. * @returns "PBRSheenConfiguration"
  44207. */
  44208. getClassName(): string;
  44209. /**
  44210. * Add fallbacks to the effect fallbacks list.
  44211. * @param defines defines the Base texture to use.
  44212. * @param fallbacks defines the current fallback list.
  44213. * @param currentRank defines the current fallback rank.
  44214. * @returns the new fallback rank.
  44215. */
  44216. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44217. /**
  44218. * Add the required uniforms to the current list.
  44219. * @param uniforms defines the current uniform list.
  44220. */
  44221. static AddUniforms(uniforms: string[]): void;
  44222. /**
  44223. * Add the required uniforms to the current buffer.
  44224. * @param uniformBuffer defines the current uniform buffer.
  44225. */
  44226. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44227. /**
  44228. * Add the required samplers to the current list.
  44229. * @param samplers defines the current sampler list.
  44230. */
  44231. static AddSamplers(samplers: string[]): void;
  44232. /**
  44233. * Makes a duplicate of the current configuration into another one.
  44234. * @param sheenConfiguration define the config where to copy the info
  44235. */
  44236. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44237. /**
  44238. * Serializes this BRDF configuration.
  44239. * @returns - An object with the serialized config.
  44240. */
  44241. serialize(): any;
  44242. /**
  44243. * Parses a Sheen Configuration from a serialized object.
  44244. * @param source - Serialized object.
  44245. */
  44246. parse(source: any): void;
  44247. }
  44248. }
  44249. declare module BABYLON {
  44250. /**
  44251. * @hidden
  44252. */
  44253. export interface IMaterialSubSurfaceDefines {
  44254. SUBSURFACE: boolean;
  44255. SS_REFRACTION: boolean;
  44256. SS_TRANSLUCENCY: boolean;
  44257. SS_SCATERRING: boolean;
  44258. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44259. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44260. SS_REFRACTIONMAP_3D: boolean;
  44261. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44262. SS_LODINREFRACTIONALPHA: boolean;
  44263. SS_GAMMAREFRACTION: boolean;
  44264. SS_RGBDREFRACTION: boolean;
  44265. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44266. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44267. /** @hidden */
  44268. _areTexturesDirty: boolean;
  44269. }
  44270. /**
  44271. * Define the code related to the sub surface parameters of the pbr material.
  44272. */
  44273. export class PBRSubSurfaceConfiguration {
  44274. private _isRefractionEnabled;
  44275. /**
  44276. * Defines if the refraction is enabled in the material.
  44277. */
  44278. isRefractionEnabled: boolean;
  44279. private _isTranslucencyEnabled;
  44280. /**
  44281. * Defines if the translucency is enabled in the material.
  44282. */
  44283. isTranslucencyEnabled: boolean;
  44284. private _isScatteringEnabled;
  44285. /**
  44286. * Defines the refraction intensity of the material.
  44287. * The refraction when enabled replaces the Diffuse part of the material.
  44288. * The intensity helps transitionning between diffuse and refraction.
  44289. */
  44290. refractionIntensity: number;
  44291. /**
  44292. * Defines the translucency intensity of the material.
  44293. * When translucency has been enabled, this defines how much of the "translucency"
  44294. * is addded to the diffuse part of the material.
  44295. */
  44296. translucencyIntensity: number;
  44297. /**
  44298. * Defines the scattering intensity of the material.
  44299. * When scattering has been enabled, this defines how much of the "scattered light"
  44300. * is addded to the diffuse part of the material.
  44301. */
  44302. scatteringIntensity: number;
  44303. private _thicknessTexture;
  44304. /**
  44305. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44306. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44307. * 0 would mean minimumThickness
  44308. * 1 would mean maximumThickness
  44309. * The other channels might be use as a mask to vary the different effects intensity.
  44310. */
  44311. thicknessTexture: Nullable<BaseTexture>;
  44312. private _refractionTexture;
  44313. /**
  44314. * Defines the texture to use for refraction.
  44315. */
  44316. refractionTexture: Nullable<BaseTexture>;
  44317. private _indexOfRefraction;
  44318. /**
  44319. * Defines the indice of refraction used in the material.
  44320. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44321. */
  44322. indexOfRefraction: number;
  44323. private _invertRefractionY;
  44324. /**
  44325. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44326. */
  44327. invertRefractionY: boolean;
  44328. private _linkRefractionWithTransparency;
  44329. /**
  44330. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44331. * Materials half opaque for instance using refraction could benefit from this control.
  44332. */
  44333. linkRefractionWithTransparency: boolean;
  44334. /**
  44335. * Defines the minimum thickness stored in the thickness map.
  44336. * If no thickness map is defined, this value will be used to simulate thickness.
  44337. */
  44338. minimumThickness: number;
  44339. /**
  44340. * Defines the maximum thickness stored in the thickness map.
  44341. */
  44342. maximumThickness: number;
  44343. /**
  44344. * Defines the volume tint of the material.
  44345. * This is used for both translucency and scattering.
  44346. */
  44347. tintColor: Color3;
  44348. /**
  44349. * Defines the distance at which the tint color should be found in the media.
  44350. * This is used for refraction only.
  44351. */
  44352. tintColorAtDistance: number;
  44353. /**
  44354. * Defines how far each channel transmit through the media.
  44355. * It is defined as a color to simplify it selection.
  44356. */
  44357. diffusionDistance: Color3;
  44358. private _useMaskFromThicknessTexture;
  44359. /**
  44360. * Stores the intensity of the different subsurface effects in the thickness texture.
  44361. * * the green channel is the translucency intensity.
  44362. * * the blue channel is the scattering intensity.
  44363. * * the alpha channel is the refraction intensity.
  44364. */
  44365. useMaskFromThicknessTexture: boolean;
  44366. /** @hidden */
  44367. private _internalMarkAllSubMeshesAsTexturesDirty;
  44368. /** @hidden */
  44369. _markAllSubMeshesAsTexturesDirty(): void;
  44370. /**
  44371. * Instantiate a new istance of sub surface configuration.
  44372. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44373. */
  44374. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44375. /**
  44376. * Gets wehter the submesh is ready to be used or not.
  44377. * @param defines the list of "defines" to update.
  44378. * @param scene defines the scene the material belongs to.
  44379. * @returns - boolean indicating that the submesh is ready or not.
  44380. */
  44381. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44382. /**
  44383. * Checks to see if a texture is used in the material.
  44384. * @param defines the list of "defines" to update.
  44385. * @param scene defines the scene to the material belongs to.
  44386. */
  44387. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44388. /**
  44389. * Binds the material data.
  44390. * @param uniformBuffer defines the Uniform buffer to fill in.
  44391. * @param scene defines the scene the material belongs to.
  44392. * @param engine defines the engine the material belongs to.
  44393. * @param isFrozen defines wether the material is frozen or not.
  44394. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44395. */
  44396. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44397. /**
  44398. * Unbinds the material from the mesh.
  44399. * @param activeEffect defines the effect that should be unbound from.
  44400. * @returns true if unbound, otherwise false
  44401. */
  44402. unbind(activeEffect: Effect): boolean;
  44403. /**
  44404. * Returns the texture used for refraction or null if none is used.
  44405. * @param scene defines the scene the material belongs to.
  44406. * @returns - Refraction texture if present. If no refraction texture and refraction
  44407. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44408. */
  44409. private _getRefractionTexture;
  44410. /**
  44411. * Returns true if alpha blending should be disabled.
  44412. */
  44413. readonly disableAlphaBlending: boolean;
  44414. /**
  44415. * Fills the list of render target textures.
  44416. * @param renderTargets the list of render targets to update
  44417. */
  44418. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44419. /**
  44420. * Checks to see if a texture is used in the material.
  44421. * @param texture - Base texture to use.
  44422. * @returns - Boolean specifying if a texture is used in the material.
  44423. */
  44424. hasTexture(texture: BaseTexture): boolean;
  44425. /**
  44426. * Gets a boolean indicating that current material needs to register RTT
  44427. * @returns true if this uses a render target otherwise false.
  44428. */
  44429. hasRenderTargetTextures(): boolean;
  44430. /**
  44431. * Returns an array of the actively used textures.
  44432. * @param activeTextures Array of BaseTextures
  44433. */
  44434. getActiveTextures(activeTextures: BaseTexture[]): void;
  44435. /**
  44436. * Returns the animatable textures.
  44437. * @param animatables Array of animatable textures.
  44438. */
  44439. getAnimatables(animatables: IAnimatable[]): void;
  44440. /**
  44441. * Disposes the resources of the material.
  44442. * @param forceDisposeTextures - Forces the disposal of all textures.
  44443. */
  44444. dispose(forceDisposeTextures?: boolean): void;
  44445. /**
  44446. * Get the current class name of the texture useful for serialization or dynamic coding.
  44447. * @returns "PBRSubSurfaceConfiguration"
  44448. */
  44449. getClassName(): string;
  44450. /**
  44451. * Add fallbacks to the effect fallbacks list.
  44452. * @param defines defines the Base texture to use.
  44453. * @param fallbacks defines the current fallback list.
  44454. * @param currentRank defines the current fallback rank.
  44455. * @returns the new fallback rank.
  44456. */
  44457. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44458. /**
  44459. * Add the required uniforms to the current list.
  44460. * @param uniforms defines the current uniform list.
  44461. */
  44462. static AddUniforms(uniforms: string[]): void;
  44463. /**
  44464. * Add the required samplers to the current list.
  44465. * @param samplers defines the current sampler list.
  44466. */
  44467. static AddSamplers(samplers: string[]): void;
  44468. /**
  44469. * Add the required uniforms to the current buffer.
  44470. * @param uniformBuffer defines the current uniform buffer.
  44471. */
  44472. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44473. /**
  44474. * Makes a duplicate of the current configuration into another one.
  44475. * @param configuration define the config where to copy the info
  44476. */
  44477. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44478. /**
  44479. * Serializes this Sub Surface configuration.
  44480. * @returns - An object with the serialized config.
  44481. */
  44482. serialize(): any;
  44483. /**
  44484. * Parses a Sub Surface Configuration from a serialized object.
  44485. * @param source - Serialized object.
  44486. */
  44487. parse(source: any): void;
  44488. }
  44489. }
  44490. declare module BABYLON {
  44491. /** @hidden */
  44492. export var pbrFragmentDeclaration: {
  44493. name: string;
  44494. shader: string;
  44495. };
  44496. }
  44497. declare module BABYLON {
  44498. /** @hidden */
  44499. export var pbrUboDeclaration: {
  44500. name: string;
  44501. shader: string;
  44502. };
  44503. }
  44504. declare module BABYLON {
  44505. /** @hidden */
  44506. export var pbrFragmentExtraDeclaration: {
  44507. name: string;
  44508. shader: string;
  44509. };
  44510. }
  44511. declare module BABYLON {
  44512. /** @hidden */
  44513. export var pbrFragmentSamplersDeclaration: {
  44514. name: string;
  44515. shader: string;
  44516. };
  44517. }
  44518. declare module BABYLON {
  44519. /** @hidden */
  44520. export var pbrHelperFunctions: {
  44521. name: string;
  44522. shader: string;
  44523. };
  44524. }
  44525. declare module BABYLON {
  44526. /** @hidden */
  44527. export var harmonicsFunctions: {
  44528. name: string;
  44529. shader: string;
  44530. };
  44531. }
  44532. declare module BABYLON {
  44533. /** @hidden */
  44534. export var pbrDirectLightingSetupFunctions: {
  44535. name: string;
  44536. shader: string;
  44537. };
  44538. }
  44539. declare module BABYLON {
  44540. /** @hidden */
  44541. export var pbrDirectLightingFalloffFunctions: {
  44542. name: string;
  44543. shader: string;
  44544. };
  44545. }
  44546. declare module BABYLON {
  44547. /** @hidden */
  44548. export var pbrBRDFFunctions: {
  44549. name: string;
  44550. shader: string;
  44551. };
  44552. }
  44553. declare module BABYLON {
  44554. /** @hidden */
  44555. export var pbrDirectLightingFunctions: {
  44556. name: string;
  44557. shader: string;
  44558. };
  44559. }
  44560. declare module BABYLON {
  44561. /** @hidden */
  44562. export var pbrIBLFunctions: {
  44563. name: string;
  44564. shader: string;
  44565. };
  44566. }
  44567. declare module BABYLON {
  44568. /** @hidden */
  44569. export var pbrDebug: {
  44570. name: string;
  44571. shader: string;
  44572. };
  44573. }
  44574. declare module BABYLON {
  44575. /** @hidden */
  44576. export var pbrPixelShader: {
  44577. name: string;
  44578. shader: string;
  44579. };
  44580. }
  44581. declare module BABYLON {
  44582. /** @hidden */
  44583. export var pbrVertexDeclaration: {
  44584. name: string;
  44585. shader: string;
  44586. };
  44587. }
  44588. declare module BABYLON {
  44589. /** @hidden */
  44590. export var pbrVertexShader: {
  44591. name: string;
  44592. shader: string;
  44593. };
  44594. }
  44595. declare module BABYLON {
  44596. /**
  44597. * Manages the defines for the PBR Material.
  44598. * @hidden
  44599. */
  44600. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44601. PBR: boolean;
  44602. MAINUV1: boolean;
  44603. MAINUV2: boolean;
  44604. UV1: boolean;
  44605. UV2: boolean;
  44606. ALBEDO: boolean;
  44607. ALBEDODIRECTUV: number;
  44608. VERTEXCOLOR: boolean;
  44609. AMBIENT: boolean;
  44610. AMBIENTDIRECTUV: number;
  44611. AMBIENTINGRAYSCALE: boolean;
  44612. OPACITY: boolean;
  44613. VERTEXALPHA: boolean;
  44614. OPACITYDIRECTUV: number;
  44615. OPACITYRGB: boolean;
  44616. ALPHATEST: boolean;
  44617. DEPTHPREPASS: boolean;
  44618. ALPHABLEND: boolean;
  44619. ALPHAFROMALBEDO: boolean;
  44620. ALPHATESTVALUE: string;
  44621. SPECULAROVERALPHA: boolean;
  44622. RADIANCEOVERALPHA: boolean;
  44623. ALPHAFRESNEL: boolean;
  44624. LINEARALPHAFRESNEL: boolean;
  44625. PREMULTIPLYALPHA: boolean;
  44626. EMISSIVE: boolean;
  44627. EMISSIVEDIRECTUV: number;
  44628. REFLECTIVITY: boolean;
  44629. REFLECTIVITYDIRECTUV: number;
  44630. SPECULARTERM: boolean;
  44631. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44632. MICROSURFACEAUTOMATIC: boolean;
  44633. LODBASEDMICROSFURACE: boolean;
  44634. MICROSURFACEMAP: boolean;
  44635. MICROSURFACEMAPDIRECTUV: number;
  44636. METALLICWORKFLOW: boolean;
  44637. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44638. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44639. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44640. AOSTOREINMETALMAPRED: boolean;
  44641. ENVIRONMENTBRDF: boolean;
  44642. ENVIRONMENTBRDF_RGBD: boolean;
  44643. NORMAL: boolean;
  44644. TANGENT: boolean;
  44645. BUMP: boolean;
  44646. BUMPDIRECTUV: number;
  44647. OBJECTSPACE_NORMALMAP: boolean;
  44648. PARALLAX: boolean;
  44649. PARALLAXOCCLUSION: boolean;
  44650. NORMALXYSCALE: boolean;
  44651. LIGHTMAP: boolean;
  44652. LIGHTMAPDIRECTUV: number;
  44653. USELIGHTMAPASSHADOWMAP: boolean;
  44654. GAMMALIGHTMAP: boolean;
  44655. REFLECTION: boolean;
  44656. REFLECTIONMAP_3D: boolean;
  44657. REFLECTIONMAP_SPHERICAL: boolean;
  44658. REFLECTIONMAP_PLANAR: boolean;
  44659. REFLECTIONMAP_CUBIC: boolean;
  44660. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44661. REFLECTIONMAP_PROJECTION: boolean;
  44662. REFLECTIONMAP_SKYBOX: boolean;
  44663. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44664. REFLECTIONMAP_EXPLICIT: boolean;
  44665. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44666. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44667. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44668. INVERTCUBICMAP: boolean;
  44669. USESPHERICALFROMREFLECTIONMAP: boolean;
  44670. USESPHERICALINVERTEX: boolean;
  44671. REFLECTIONMAP_OPPOSITEZ: boolean;
  44672. LODINREFLECTIONALPHA: boolean;
  44673. GAMMAREFLECTION: boolean;
  44674. RGBDREFLECTION: boolean;
  44675. RADIANCEOCCLUSION: boolean;
  44676. HORIZONOCCLUSION: boolean;
  44677. INSTANCES: boolean;
  44678. NUM_BONE_INFLUENCERS: number;
  44679. BonesPerMesh: number;
  44680. BONETEXTURE: boolean;
  44681. NONUNIFORMSCALING: boolean;
  44682. MORPHTARGETS: boolean;
  44683. MORPHTARGETS_NORMAL: boolean;
  44684. MORPHTARGETS_TANGENT: boolean;
  44685. NUM_MORPH_INFLUENCERS: number;
  44686. IMAGEPROCESSING: boolean;
  44687. VIGNETTE: boolean;
  44688. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44689. VIGNETTEBLENDMODEOPAQUE: boolean;
  44690. TONEMAPPING: boolean;
  44691. TONEMAPPING_ACES: boolean;
  44692. CONTRAST: boolean;
  44693. COLORCURVES: boolean;
  44694. COLORGRADING: boolean;
  44695. COLORGRADING3D: boolean;
  44696. SAMPLER3DGREENDEPTH: boolean;
  44697. SAMPLER3DBGRMAP: boolean;
  44698. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44699. EXPOSURE: boolean;
  44700. MULTIVIEW: boolean;
  44701. USEPHYSICALLIGHTFALLOFF: boolean;
  44702. USEGLTFLIGHTFALLOFF: boolean;
  44703. TWOSIDEDLIGHTING: boolean;
  44704. SHADOWFLOAT: boolean;
  44705. CLIPPLANE: boolean;
  44706. CLIPPLANE2: boolean;
  44707. CLIPPLANE3: boolean;
  44708. CLIPPLANE4: boolean;
  44709. POINTSIZE: boolean;
  44710. FOG: boolean;
  44711. LOGARITHMICDEPTH: boolean;
  44712. FORCENORMALFORWARD: boolean;
  44713. SPECULARAA: boolean;
  44714. CLEARCOAT: boolean;
  44715. CLEARCOAT_DEFAULTIOR: boolean;
  44716. CLEARCOAT_TEXTURE: boolean;
  44717. CLEARCOAT_TEXTUREDIRECTUV: number;
  44718. CLEARCOAT_BUMP: boolean;
  44719. CLEARCOAT_BUMPDIRECTUV: number;
  44720. CLEARCOAT_TINT: boolean;
  44721. CLEARCOAT_TINT_TEXTURE: boolean;
  44722. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44723. ANISOTROPIC: boolean;
  44724. ANISOTROPIC_TEXTURE: boolean;
  44725. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44726. BRDF_V_HEIGHT_CORRELATED: boolean;
  44727. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44728. SHEEN: boolean;
  44729. SHEEN_TEXTURE: boolean;
  44730. SHEEN_TEXTUREDIRECTUV: number;
  44731. SHEEN_LINKWITHALBEDO: boolean;
  44732. SUBSURFACE: boolean;
  44733. SS_REFRACTION: boolean;
  44734. SS_TRANSLUCENCY: boolean;
  44735. SS_SCATERRING: boolean;
  44736. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44737. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44738. SS_REFRACTIONMAP_3D: boolean;
  44739. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44740. SS_LODINREFRACTIONALPHA: boolean;
  44741. SS_GAMMAREFRACTION: boolean;
  44742. SS_RGBDREFRACTION: boolean;
  44743. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44744. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44745. UNLIT: boolean;
  44746. DEBUGMODE: number;
  44747. /**
  44748. * Initializes the PBR Material defines.
  44749. */
  44750. constructor();
  44751. /**
  44752. * Resets the PBR Material defines.
  44753. */
  44754. reset(): void;
  44755. }
  44756. /**
  44757. * The Physically based material base class of BJS.
  44758. *
  44759. * This offers the main features of a standard PBR material.
  44760. * For more information, please refer to the documentation :
  44761. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44762. */
  44763. export abstract class PBRBaseMaterial extends PushMaterial {
  44764. /**
  44765. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44766. */
  44767. static readonly PBRMATERIAL_OPAQUE: number;
  44768. /**
  44769. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44770. */
  44771. static readonly PBRMATERIAL_ALPHATEST: number;
  44772. /**
  44773. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44774. */
  44775. static readonly PBRMATERIAL_ALPHABLEND: number;
  44776. /**
  44777. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44778. * They are also discarded below the alpha cutoff threshold to improve performances.
  44779. */
  44780. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44781. /**
  44782. * Defines the default value of how much AO map is occluding the analytical lights
  44783. * (point spot...).
  44784. */
  44785. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44786. /**
  44787. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44788. */
  44789. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44790. /**
  44791. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44792. * to enhance interoperability with other engines.
  44793. */
  44794. static readonly LIGHTFALLOFF_GLTF: number;
  44795. /**
  44796. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44797. * to enhance interoperability with other materials.
  44798. */
  44799. static readonly LIGHTFALLOFF_STANDARD: number;
  44800. /**
  44801. * Intensity of the direct lights e.g. the four lights available in your scene.
  44802. * This impacts both the direct diffuse and specular highlights.
  44803. */
  44804. protected _directIntensity: number;
  44805. /**
  44806. * Intensity of the emissive part of the material.
  44807. * This helps controlling the emissive effect without modifying the emissive color.
  44808. */
  44809. protected _emissiveIntensity: number;
  44810. /**
  44811. * Intensity of the environment e.g. how much the environment will light the object
  44812. * either through harmonics for rough material or through the refelction for shiny ones.
  44813. */
  44814. protected _environmentIntensity: number;
  44815. /**
  44816. * This is a special control allowing the reduction of the specular highlights coming from the
  44817. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44818. */
  44819. protected _specularIntensity: number;
  44820. /**
  44821. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44822. */
  44823. private _lightingInfos;
  44824. /**
  44825. * Debug Control allowing disabling the bump map on this material.
  44826. */
  44827. protected _disableBumpMap: boolean;
  44828. /**
  44829. * AKA Diffuse Texture in standard nomenclature.
  44830. */
  44831. protected _albedoTexture: Nullable<BaseTexture>;
  44832. /**
  44833. * AKA Occlusion Texture in other nomenclature.
  44834. */
  44835. protected _ambientTexture: Nullable<BaseTexture>;
  44836. /**
  44837. * AKA Occlusion Texture Intensity in other nomenclature.
  44838. */
  44839. protected _ambientTextureStrength: number;
  44840. /**
  44841. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44842. * 1 means it completely occludes it
  44843. * 0 mean it has no impact
  44844. */
  44845. protected _ambientTextureImpactOnAnalyticalLights: number;
  44846. /**
  44847. * Stores the alpha values in a texture.
  44848. */
  44849. protected _opacityTexture: Nullable<BaseTexture>;
  44850. /**
  44851. * Stores the reflection values in a texture.
  44852. */
  44853. protected _reflectionTexture: Nullable<BaseTexture>;
  44854. /**
  44855. * Stores the emissive values in a texture.
  44856. */
  44857. protected _emissiveTexture: Nullable<BaseTexture>;
  44858. /**
  44859. * AKA Specular texture in other nomenclature.
  44860. */
  44861. protected _reflectivityTexture: Nullable<BaseTexture>;
  44862. /**
  44863. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44864. */
  44865. protected _metallicTexture: Nullable<BaseTexture>;
  44866. /**
  44867. * Specifies the metallic scalar of the metallic/roughness workflow.
  44868. * Can also be used to scale the metalness values of the metallic texture.
  44869. */
  44870. protected _metallic: Nullable<number>;
  44871. /**
  44872. * Specifies the roughness scalar of the metallic/roughness workflow.
  44873. * Can also be used to scale the roughness values of the metallic texture.
  44874. */
  44875. protected _roughness: Nullable<number>;
  44876. /**
  44877. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44878. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44879. */
  44880. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44881. /**
  44882. * Stores surface normal data used to displace a mesh in a texture.
  44883. */
  44884. protected _bumpTexture: Nullable<BaseTexture>;
  44885. /**
  44886. * Stores the pre-calculated light information of a mesh in a texture.
  44887. */
  44888. protected _lightmapTexture: Nullable<BaseTexture>;
  44889. /**
  44890. * The color of a material in ambient lighting.
  44891. */
  44892. protected _ambientColor: Color3;
  44893. /**
  44894. * AKA Diffuse Color in other nomenclature.
  44895. */
  44896. protected _albedoColor: Color3;
  44897. /**
  44898. * AKA Specular Color in other nomenclature.
  44899. */
  44900. protected _reflectivityColor: Color3;
  44901. /**
  44902. * The color applied when light is reflected from a material.
  44903. */
  44904. protected _reflectionColor: Color3;
  44905. /**
  44906. * The color applied when light is emitted from a material.
  44907. */
  44908. protected _emissiveColor: Color3;
  44909. /**
  44910. * AKA Glossiness in other nomenclature.
  44911. */
  44912. protected _microSurface: number;
  44913. /**
  44914. * Specifies that the material will use the light map as a show map.
  44915. */
  44916. protected _useLightmapAsShadowmap: boolean;
  44917. /**
  44918. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44919. * makes the reflect vector face the model (under horizon).
  44920. */
  44921. protected _useHorizonOcclusion: boolean;
  44922. /**
  44923. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44924. * too much the area relying on ambient texture to define their ambient occlusion.
  44925. */
  44926. protected _useRadianceOcclusion: boolean;
  44927. /**
  44928. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44929. */
  44930. protected _useAlphaFromAlbedoTexture: boolean;
  44931. /**
  44932. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44933. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44934. */
  44935. protected _useSpecularOverAlpha: boolean;
  44936. /**
  44937. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44938. */
  44939. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44940. /**
  44941. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44942. */
  44943. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44944. /**
  44945. * Specifies if the metallic texture contains the roughness information in its green channel.
  44946. */
  44947. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44948. /**
  44949. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44950. */
  44951. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44952. /**
  44953. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44954. */
  44955. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44956. /**
  44957. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44958. */
  44959. protected _useAmbientInGrayScale: boolean;
  44960. /**
  44961. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44962. * The material will try to infer what glossiness each pixel should be.
  44963. */
  44964. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44965. /**
  44966. * Defines the falloff type used in this material.
  44967. * It by default is Physical.
  44968. */
  44969. protected _lightFalloff: number;
  44970. /**
  44971. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44972. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44973. */
  44974. protected _useRadianceOverAlpha: boolean;
  44975. /**
  44976. * Allows using an object space normal map (instead of tangent space).
  44977. */
  44978. protected _useObjectSpaceNormalMap: boolean;
  44979. /**
  44980. * Allows using the bump map in parallax mode.
  44981. */
  44982. protected _useParallax: boolean;
  44983. /**
  44984. * Allows using the bump map in parallax occlusion mode.
  44985. */
  44986. protected _useParallaxOcclusion: boolean;
  44987. /**
  44988. * Controls the scale bias of the parallax mode.
  44989. */
  44990. protected _parallaxScaleBias: number;
  44991. /**
  44992. * If sets to true, disables all the lights affecting the material.
  44993. */
  44994. protected _disableLighting: boolean;
  44995. /**
  44996. * Number of Simultaneous lights allowed on the material.
  44997. */
  44998. protected _maxSimultaneousLights: number;
  44999. /**
  45000. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45001. */
  45002. protected _invertNormalMapX: boolean;
  45003. /**
  45004. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45005. */
  45006. protected _invertNormalMapY: boolean;
  45007. /**
  45008. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45009. */
  45010. protected _twoSidedLighting: boolean;
  45011. /**
  45012. * Defines the alpha limits in alpha test mode.
  45013. */
  45014. protected _alphaCutOff: number;
  45015. /**
  45016. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45017. */
  45018. protected _forceAlphaTest: boolean;
  45019. /**
  45020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45021. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45022. */
  45023. protected _useAlphaFresnel: boolean;
  45024. /**
  45025. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45026. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45027. */
  45028. protected _useLinearAlphaFresnel: boolean;
  45029. /**
  45030. * The transparency mode of the material.
  45031. */
  45032. protected _transparencyMode: Nullable<number>;
  45033. /**
  45034. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45035. * from cos thetav and roughness:
  45036. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45037. */
  45038. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45039. /**
  45040. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45041. */
  45042. protected _forceIrradianceInFragment: boolean;
  45043. /**
  45044. * Force normal to face away from face.
  45045. */
  45046. protected _forceNormalForward: boolean;
  45047. /**
  45048. * Enables specular anti aliasing in the PBR shader.
  45049. * It will both interacts on the Geometry for analytical and IBL lighting.
  45050. * It also prefilter the roughness map based on the bump values.
  45051. */
  45052. protected _enableSpecularAntiAliasing: boolean;
  45053. /**
  45054. * Default configuration related to image processing available in the PBR Material.
  45055. */
  45056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45057. /**
  45058. * Keep track of the image processing observer to allow dispose and replace.
  45059. */
  45060. private _imageProcessingObserver;
  45061. /**
  45062. * Attaches a new image processing configuration to the PBR Material.
  45063. * @param configuration
  45064. */
  45065. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45066. /**
  45067. * Stores the available render targets.
  45068. */
  45069. private _renderTargets;
  45070. /**
  45071. * Sets the global ambient color for the material used in lighting calculations.
  45072. */
  45073. private _globalAmbientColor;
  45074. /**
  45075. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45076. */
  45077. private _useLogarithmicDepth;
  45078. /**
  45079. * If set to true, no lighting calculations will be applied.
  45080. */
  45081. private _unlit;
  45082. private _debugMode;
  45083. /**
  45084. * @hidden
  45085. * This is reserved for the inspector.
  45086. * Defines the material debug mode.
  45087. * It helps seeing only some components of the material while troubleshooting.
  45088. */
  45089. debugMode: number;
  45090. /**
  45091. * @hidden
  45092. * This is reserved for the inspector.
  45093. * Specify from where on screen the debug mode should start.
  45094. * The value goes from -1 (full screen) to 1 (not visible)
  45095. * It helps with side by side comparison against the final render
  45096. * This defaults to -1
  45097. */
  45098. private debugLimit;
  45099. /**
  45100. * @hidden
  45101. * This is reserved for the inspector.
  45102. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45103. * You can use the factor to better multiply the final value.
  45104. */
  45105. private debugFactor;
  45106. /**
  45107. * Defines the clear coat layer parameters for the material.
  45108. */
  45109. readonly clearCoat: PBRClearCoatConfiguration;
  45110. /**
  45111. * Defines the anisotropic parameters for the material.
  45112. */
  45113. readonly anisotropy: PBRAnisotropicConfiguration;
  45114. /**
  45115. * Defines the BRDF parameters for the material.
  45116. */
  45117. readonly brdf: PBRBRDFConfiguration;
  45118. /**
  45119. * Defines the Sheen parameters for the material.
  45120. */
  45121. readonly sheen: PBRSheenConfiguration;
  45122. /**
  45123. * Defines the SubSurface parameters for the material.
  45124. */
  45125. readonly subSurface: PBRSubSurfaceConfiguration;
  45126. /**
  45127. * Custom callback helping to override the default shader used in the material.
  45128. */
  45129. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45130. /**
  45131. * Instantiates a new PBRMaterial instance.
  45132. *
  45133. * @param name The material name
  45134. * @param scene The scene the material will be use in.
  45135. */
  45136. constructor(name: string, scene: Scene);
  45137. /**
  45138. * Gets a boolean indicating that current material needs to register RTT
  45139. */
  45140. readonly hasRenderTargetTextures: boolean;
  45141. /**
  45142. * Gets the name of the material class.
  45143. */
  45144. getClassName(): string;
  45145. /**
  45146. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45147. */
  45148. /**
  45149. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45150. */
  45151. useLogarithmicDepth: boolean;
  45152. /**
  45153. * Gets the current transparency mode.
  45154. */
  45155. /**
  45156. * Sets the transparency mode of the material.
  45157. *
  45158. * | Value | Type | Description |
  45159. * | ----- | ----------------------------------- | ----------- |
  45160. * | 0 | OPAQUE | |
  45161. * | 1 | ALPHATEST | |
  45162. * | 2 | ALPHABLEND | |
  45163. * | 3 | ALPHATESTANDBLEND | |
  45164. *
  45165. */
  45166. transparencyMode: Nullable<number>;
  45167. /**
  45168. * Returns true if alpha blending should be disabled.
  45169. */
  45170. private readonly _disableAlphaBlending;
  45171. /**
  45172. * Specifies whether or not this material should be rendered in alpha blend mode.
  45173. */
  45174. needAlphaBlending(): boolean;
  45175. /**
  45176. * Specifies if the mesh will require alpha blending.
  45177. * @param mesh - BJS mesh.
  45178. */
  45179. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45180. /**
  45181. * Specifies whether or not this material should be rendered in alpha test mode.
  45182. */
  45183. needAlphaTesting(): boolean;
  45184. /**
  45185. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45186. */
  45187. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45188. /**
  45189. * Gets the texture used for the alpha test.
  45190. */
  45191. getAlphaTestTexture(): Nullable<BaseTexture>;
  45192. /**
  45193. * Specifies that the submesh is ready to be used.
  45194. * @param mesh - BJS mesh.
  45195. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45196. * @param useInstances - Specifies that instances should be used.
  45197. * @returns - boolean indicating that the submesh is ready or not.
  45198. */
  45199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45200. /**
  45201. * Specifies if the material uses metallic roughness workflow.
  45202. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45203. */
  45204. isMetallicWorkflow(): boolean;
  45205. private _prepareEffect;
  45206. private _prepareDefines;
  45207. /**
  45208. * Force shader compilation
  45209. */
  45210. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45211. clipPlane: boolean;
  45212. }>): void;
  45213. /**
  45214. * Initializes the uniform buffer layout for the shader.
  45215. */
  45216. buildUniformLayout(): void;
  45217. /**
  45218. * Unbinds the material from the mesh
  45219. */
  45220. unbind(): void;
  45221. /**
  45222. * Binds the submesh data.
  45223. * @param world - The world matrix.
  45224. * @param mesh - The BJS mesh.
  45225. * @param subMesh - A submesh of the BJS mesh.
  45226. */
  45227. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45228. /**
  45229. * Returns the animatable textures.
  45230. * @returns - Array of animatable textures.
  45231. */
  45232. getAnimatables(): IAnimatable[];
  45233. /**
  45234. * Returns the texture used for reflections.
  45235. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45236. */
  45237. private _getReflectionTexture;
  45238. /**
  45239. * Returns an array of the actively used textures.
  45240. * @returns - Array of BaseTextures
  45241. */
  45242. getActiveTextures(): BaseTexture[];
  45243. /**
  45244. * Checks to see if a texture is used in the material.
  45245. * @param texture - Base texture to use.
  45246. * @returns - Boolean specifying if a texture is used in the material.
  45247. */
  45248. hasTexture(texture: BaseTexture): boolean;
  45249. /**
  45250. * Disposes the resources of the material.
  45251. * @param forceDisposeEffect - Forces the disposal of effects.
  45252. * @param forceDisposeTextures - Forces the disposal of all textures.
  45253. */
  45254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45255. }
  45256. }
  45257. declare module BABYLON {
  45258. /**
  45259. * The Physically based material of BJS.
  45260. *
  45261. * This offers the main features of a standard PBR material.
  45262. * For more information, please refer to the documentation :
  45263. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45264. */
  45265. export class PBRMaterial extends PBRBaseMaterial {
  45266. /**
  45267. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45268. */
  45269. static readonly PBRMATERIAL_OPAQUE: number;
  45270. /**
  45271. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45272. */
  45273. static readonly PBRMATERIAL_ALPHATEST: number;
  45274. /**
  45275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45276. */
  45277. static readonly PBRMATERIAL_ALPHABLEND: number;
  45278. /**
  45279. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45280. * They are also discarded below the alpha cutoff threshold to improve performances.
  45281. */
  45282. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45283. /**
  45284. * Defines the default value of how much AO map is occluding the analytical lights
  45285. * (point spot...).
  45286. */
  45287. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45288. /**
  45289. * Intensity of the direct lights e.g. the four lights available in your scene.
  45290. * This impacts both the direct diffuse and specular highlights.
  45291. */
  45292. directIntensity: number;
  45293. /**
  45294. * Intensity of the emissive part of the material.
  45295. * This helps controlling the emissive effect without modifying the emissive color.
  45296. */
  45297. emissiveIntensity: number;
  45298. /**
  45299. * Intensity of the environment e.g. how much the environment will light the object
  45300. * either through harmonics for rough material or through the refelction for shiny ones.
  45301. */
  45302. environmentIntensity: number;
  45303. /**
  45304. * This is a special control allowing the reduction of the specular highlights coming from the
  45305. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45306. */
  45307. specularIntensity: number;
  45308. /**
  45309. * Debug Control allowing disabling the bump map on this material.
  45310. */
  45311. disableBumpMap: boolean;
  45312. /**
  45313. * AKA Diffuse Texture in standard nomenclature.
  45314. */
  45315. albedoTexture: BaseTexture;
  45316. /**
  45317. * AKA Occlusion Texture in other nomenclature.
  45318. */
  45319. ambientTexture: BaseTexture;
  45320. /**
  45321. * AKA Occlusion Texture Intensity in other nomenclature.
  45322. */
  45323. ambientTextureStrength: number;
  45324. /**
  45325. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45326. * 1 means it completely occludes it
  45327. * 0 mean it has no impact
  45328. */
  45329. ambientTextureImpactOnAnalyticalLights: number;
  45330. /**
  45331. * Stores the alpha values in a texture.
  45332. */
  45333. opacityTexture: BaseTexture;
  45334. /**
  45335. * Stores the reflection values in a texture.
  45336. */
  45337. reflectionTexture: Nullable<BaseTexture>;
  45338. /**
  45339. * Stores the emissive values in a texture.
  45340. */
  45341. emissiveTexture: BaseTexture;
  45342. /**
  45343. * AKA Specular texture in other nomenclature.
  45344. */
  45345. reflectivityTexture: BaseTexture;
  45346. /**
  45347. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45348. */
  45349. metallicTexture: BaseTexture;
  45350. /**
  45351. * Specifies the metallic scalar of the metallic/roughness workflow.
  45352. * Can also be used to scale the metalness values of the metallic texture.
  45353. */
  45354. metallic: Nullable<number>;
  45355. /**
  45356. * Specifies the roughness scalar of the metallic/roughness workflow.
  45357. * Can also be used to scale the roughness values of the metallic texture.
  45358. */
  45359. roughness: Nullable<number>;
  45360. /**
  45361. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45362. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45363. */
  45364. microSurfaceTexture: BaseTexture;
  45365. /**
  45366. * Stores surface normal data used to displace a mesh in a texture.
  45367. */
  45368. bumpTexture: BaseTexture;
  45369. /**
  45370. * Stores the pre-calculated light information of a mesh in a texture.
  45371. */
  45372. lightmapTexture: BaseTexture;
  45373. /**
  45374. * Stores the refracted light information in a texture.
  45375. */
  45376. refractionTexture: Nullable<BaseTexture>;
  45377. /**
  45378. * The color of a material in ambient lighting.
  45379. */
  45380. ambientColor: Color3;
  45381. /**
  45382. * AKA Diffuse Color in other nomenclature.
  45383. */
  45384. albedoColor: Color3;
  45385. /**
  45386. * AKA Specular Color in other nomenclature.
  45387. */
  45388. reflectivityColor: Color3;
  45389. /**
  45390. * The color reflected from the material.
  45391. */
  45392. reflectionColor: Color3;
  45393. /**
  45394. * The color emitted from the material.
  45395. */
  45396. emissiveColor: Color3;
  45397. /**
  45398. * AKA Glossiness in other nomenclature.
  45399. */
  45400. microSurface: number;
  45401. /**
  45402. * source material index of refraction (IOR)' / 'destination material IOR.
  45403. */
  45404. indexOfRefraction: number;
  45405. /**
  45406. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45407. */
  45408. invertRefractionY: boolean;
  45409. /**
  45410. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45411. * Materials half opaque for instance using refraction could benefit from this control.
  45412. */
  45413. linkRefractionWithTransparency: boolean;
  45414. /**
  45415. * If true, the light map contains occlusion information instead of lighting info.
  45416. */
  45417. useLightmapAsShadowmap: boolean;
  45418. /**
  45419. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45420. */
  45421. useAlphaFromAlbedoTexture: boolean;
  45422. /**
  45423. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45424. */
  45425. forceAlphaTest: boolean;
  45426. /**
  45427. * Defines the alpha limits in alpha test mode.
  45428. */
  45429. alphaCutOff: number;
  45430. /**
  45431. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45432. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45433. */
  45434. useSpecularOverAlpha: boolean;
  45435. /**
  45436. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45437. */
  45438. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45439. /**
  45440. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45441. */
  45442. useRoughnessFromMetallicTextureAlpha: boolean;
  45443. /**
  45444. * Specifies if the metallic texture contains the roughness information in its green channel.
  45445. */
  45446. useRoughnessFromMetallicTextureGreen: boolean;
  45447. /**
  45448. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45449. */
  45450. useMetallnessFromMetallicTextureBlue: boolean;
  45451. /**
  45452. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45453. */
  45454. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45455. /**
  45456. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45457. */
  45458. useAmbientInGrayScale: boolean;
  45459. /**
  45460. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45461. * The material will try to infer what glossiness each pixel should be.
  45462. */
  45463. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45464. /**
  45465. * BJS is using an harcoded light falloff based on a manually sets up range.
  45466. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45467. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45468. */
  45469. /**
  45470. * BJS is using an harcoded light falloff based on a manually sets up range.
  45471. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45472. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45473. */
  45474. usePhysicalLightFalloff: boolean;
  45475. /**
  45476. * In order to support the falloff compatibility with gltf, a special mode has been added
  45477. * to reproduce the gltf light falloff.
  45478. */
  45479. /**
  45480. * In order to support the falloff compatibility with gltf, a special mode has been added
  45481. * to reproduce the gltf light falloff.
  45482. */
  45483. useGLTFLightFalloff: boolean;
  45484. /**
  45485. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45486. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45487. */
  45488. useRadianceOverAlpha: boolean;
  45489. /**
  45490. * Allows using an object space normal map (instead of tangent space).
  45491. */
  45492. useObjectSpaceNormalMap: boolean;
  45493. /**
  45494. * Allows using the bump map in parallax mode.
  45495. */
  45496. useParallax: boolean;
  45497. /**
  45498. * Allows using the bump map in parallax occlusion mode.
  45499. */
  45500. useParallaxOcclusion: boolean;
  45501. /**
  45502. * Controls the scale bias of the parallax mode.
  45503. */
  45504. parallaxScaleBias: number;
  45505. /**
  45506. * If sets to true, disables all the lights affecting the material.
  45507. */
  45508. disableLighting: boolean;
  45509. /**
  45510. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45511. */
  45512. forceIrradianceInFragment: boolean;
  45513. /**
  45514. * Number of Simultaneous lights allowed on the material.
  45515. */
  45516. maxSimultaneousLights: number;
  45517. /**
  45518. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45519. */
  45520. invertNormalMapX: boolean;
  45521. /**
  45522. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45523. */
  45524. invertNormalMapY: boolean;
  45525. /**
  45526. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45527. */
  45528. twoSidedLighting: boolean;
  45529. /**
  45530. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45531. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45532. */
  45533. useAlphaFresnel: boolean;
  45534. /**
  45535. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45536. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45537. */
  45538. useLinearAlphaFresnel: boolean;
  45539. /**
  45540. * Let user defines the brdf lookup texture used for IBL.
  45541. * A default 8bit version is embedded but you could point at :
  45542. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45543. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45544. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45545. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45546. */
  45547. environmentBRDFTexture: Nullable<BaseTexture>;
  45548. /**
  45549. * Force normal to face away from face.
  45550. */
  45551. forceNormalForward: boolean;
  45552. /**
  45553. * Enables specular anti aliasing in the PBR shader.
  45554. * It will both interacts on the Geometry for analytical and IBL lighting.
  45555. * It also prefilter the roughness map based on the bump values.
  45556. */
  45557. enableSpecularAntiAliasing: boolean;
  45558. /**
  45559. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45560. * makes the reflect vector face the model (under horizon).
  45561. */
  45562. useHorizonOcclusion: boolean;
  45563. /**
  45564. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45565. * too much the area relying on ambient texture to define their ambient occlusion.
  45566. */
  45567. useRadianceOcclusion: boolean;
  45568. /**
  45569. * If set to true, no lighting calculations will be applied.
  45570. */
  45571. unlit: boolean;
  45572. /**
  45573. * Gets the image processing configuration used either in this material.
  45574. */
  45575. /**
  45576. * Sets the Default image processing configuration used either in the this material.
  45577. *
  45578. * If sets to null, the scene one is in use.
  45579. */
  45580. imageProcessingConfiguration: ImageProcessingConfiguration;
  45581. /**
  45582. * Gets wether the color curves effect is enabled.
  45583. */
  45584. /**
  45585. * Sets wether the color curves effect is enabled.
  45586. */
  45587. cameraColorCurvesEnabled: boolean;
  45588. /**
  45589. * Gets wether the color grading effect is enabled.
  45590. */
  45591. /**
  45592. * Gets wether the color grading effect is enabled.
  45593. */
  45594. cameraColorGradingEnabled: boolean;
  45595. /**
  45596. * Gets wether tonemapping is enabled or not.
  45597. */
  45598. /**
  45599. * Sets wether tonemapping is enabled or not
  45600. */
  45601. cameraToneMappingEnabled: boolean;
  45602. /**
  45603. * The camera exposure used on this material.
  45604. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45605. * This corresponds to a photographic exposure.
  45606. */
  45607. /**
  45608. * The camera exposure used on this material.
  45609. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45610. * This corresponds to a photographic exposure.
  45611. */
  45612. cameraExposure: number;
  45613. /**
  45614. * Gets The camera contrast used on this material.
  45615. */
  45616. /**
  45617. * Sets The camera contrast used on this material.
  45618. */
  45619. cameraContrast: number;
  45620. /**
  45621. * Gets the Color Grading 2D Lookup Texture.
  45622. */
  45623. /**
  45624. * Sets the Color Grading 2D Lookup Texture.
  45625. */
  45626. cameraColorGradingTexture: Nullable<BaseTexture>;
  45627. /**
  45628. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45629. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45630. * 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;
  45631. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45632. */
  45633. /**
  45634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45636. * 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;
  45637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45638. */
  45639. cameraColorCurves: Nullable<ColorCurves>;
  45640. /**
  45641. * Instantiates a new PBRMaterial instance.
  45642. *
  45643. * @param name The material name
  45644. * @param scene The scene the material will be use in.
  45645. */
  45646. constructor(name: string, scene: Scene);
  45647. /**
  45648. * Returns the name of this material class.
  45649. */
  45650. getClassName(): string;
  45651. /**
  45652. * Makes a duplicate of the current material.
  45653. * @param name - name to use for the new material.
  45654. */
  45655. clone(name: string): PBRMaterial;
  45656. /**
  45657. * Serializes this PBR Material.
  45658. * @returns - An object with the serialized material.
  45659. */
  45660. serialize(): any;
  45661. /**
  45662. * Parses a PBR Material from a serialized object.
  45663. * @param source - Serialized object.
  45664. * @param scene - BJS scene instance.
  45665. * @param rootUrl - url for the scene object
  45666. * @returns - PBRMaterial
  45667. */
  45668. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45669. }
  45670. }
  45671. declare module BABYLON {
  45672. /**
  45673. * Direct draw surface info
  45674. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45675. */
  45676. export interface DDSInfo {
  45677. /**
  45678. * Width of the texture
  45679. */
  45680. width: number;
  45681. /**
  45682. * Width of the texture
  45683. */
  45684. height: number;
  45685. /**
  45686. * Number of Mipmaps for the texture
  45687. * @see https://en.wikipedia.org/wiki/Mipmap
  45688. */
  45689. mipmapCount: number;
  45690. /**
  45691. * If the textures format is a known fourCC format
  45692. * @see https://www.fourcc.org/
  45693. */
  45694. isFourCC: boolean;
  45695. /**
  45696. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45697. */
  45698. isRGB: boolean;
  45699. /**
  45700. * If the texture is a lumincance format
  45701. */
  45702. isLuminance: boolean;
  45703. /**
  45704. * If this is a cube texture
  45705. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45706. */
  45707. isCube: boolean;
  45708. /**
  45709. * If the texture is a compressed format eg. FOURCC_DXT1
  45710. */
  45711. isCompressed: boolean;
  45712. /**
  45713. * The dxgiFormat of the texture
  45714. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45715. */
  45716. dxgiFormat: number;
  45717. /**
  45718. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45719. */
  45720. textureType: number;
  45721. /**
  45722. * Sphericle polynomial created for the dds texture
  45723. */
  45724. sphericalPolynomial?: SphericalPolynomial;
  45725. }
  45726. /**
  45727. * Class used to provide DDS decompression tools
  45728. */
  45729. export class DDSTools {
  45730. /**
  45731. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45732. */
  45733. static StoreLODInAlphaChannel: boolean;
  45734. /**
  45735. * Gets DDS information from an array buffer
  45736. * @param arrayBuffer defines the array buffer to read data from
  45737. * @returns the DDS information
  45738. */
  45739. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45740. private static _FloatView;
  45741. private static _Int32View;
  45742. private static _ToHalfFloat;
  45743. private static _FromHalfFloat;
  45744. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45745. private static _GetHalfFloatRGBAArrayBuffer;
  45746. private static _GetFloatRGBAArrayBuffer;
  45747. private static _GetFloatAsUIntRGBAArrayBuffer;
  45748. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45749. private static _GetRGBAArrayBuffer;
  45750. private static _ExtractLongWordOrder;
  45751. private static _GetRGBArrayBuffer;
  45752. private static _GetLuminanceArrayBuffer;
  45753. /**
  45754. * Uploads DDS Levels to a Babylon Texture
  45755. * @hidden
  45756. */
  45757. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45758. }
  45759. interface Engine {
  45760. /**
  45761. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45762. * @param rootUrl defines the url where the file to load is located
  45763. * @param scene defines the current scene
  45764. * @param lodScale defines scale to apply to the mip map selection
  45765. * @param lodOffset defines offset to apply to the mip map selection
  45766. * @param onLoad defines an optional callback raised when the texture is loaded
  45767. * @param onError defines an optional callback raised if there is an issue to load the texture
  45768. * @param format defines the format of the data
  45769. * @param forcedExtension defines the extension to use to pick the right loader
  45770. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45771. * @returns the cube texture as an InternalTexture
  45772. */
  45773. 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;
  45774. }
  45775. }
  45776. declare module BABYLON {
  45777. /**
  45778. * Implementation of the DDS Texture Loader.
  45779. * @hidden
  45780. */
  45781. export class _DDSTextureLoader implements IInternalTextureLoader {
  45782. /**
  45783. * Defines wether the loader supports cascade loading the different faces.
  45784. */
  45785. readonly supportCascades: boolean;
  45786. /**
  45787. * This returns if the loader support the current file information.
  45788. * @param extension defines the file extension of the file being loaded
  45789. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45790. * @param fallback defines the fallback internal texture if any
  45791. * @param isBase64 defines whether the texture is encoded as a base64
  45792. * @param isBuffer defines whether the texture data are stored as a buffer
  45793. * @returns true if the loader can load the specified file
  45794. */
  45795. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45796. /**
  45797. * Transform the url before loading if required.
  45798. * @param rootUrl the url of the texture
  45799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45800. * @returns the transformed texture
  45801. */
  45802. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45803. /**
  45804. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45805. * @param rootUrl the url of the texture
  45806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45807. * @returns the fallback texture
  45808. */
  45809. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45810. /**
  45811. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45812. * @param data contains the texture data
  45813. * @param texture defines the BabylonJS internal texture
  45814. * @param createPolynomials will be true if polynomials have been requested
  45815. * @param onLoad defines the callback to trigger once the texture is ready
  45816. * @param onError defines the callback to trigger in case of error
  45817. */
  45818. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45819. /**
  45820. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45821. * @param data contains the texture data
  45822. * @param texture defines the BabylonJS internal texture
  45823. * @param callback defines the method to call once ready to upload
  45824. */
  45825. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45826. }
  45827. }
  45828. declare module BABYLON {
  45829. /** @hidden */
  45830. export var rgbdEncodePixelShader: {
  45831. name: string;
  45832. shader: string;
  45833. };
  45834. }
  45835. declare module BABYLON {
  45836. /**
  45837. * Raw texture data and descriptor sufficient for WebGL texture upload
  45838. */
  45839. export interface EnvironmentTextureInfo {
  45840. /**
  45841. * Version of the environment map
  45842. */
  45843. version: number;
  45844. /**
  45845. * Width of image
  45846. */
  45847. width: number;
  45848. /**
  45849. * Irradiance information stored in the file.
  45850. */
  45851. irradiance: any;
  45852. /**
  45853. * Specular information stored in the file.
  45854. */
  45855. specular: any;
  45856. }
  45857. /**
  45858. * Sets of helpers addressing the serialization and deserialization of environment texture
  45859. * stored in a BabylonJS env file.
  45860. * Those files are usually stored as .env files.
  45861. */
  45862. export class EnvironmentTextureTools {
  45863. /**
  45864. * Magic number identifying the env file.
  45865. */
  45866. private static _MagicBytes;
  45867. /**
  45868. * Gets the environment info from an env file.
  45869. * @param data The array buffer containing the .env bytes.
  45870. * @returns the environment file info (the json header) if successfully parsed.
  45871. */
  45872. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45873. /**
  45874. * Creates an environment texture from a loaded cube texture.
  45875. * @param texture defines the cube texture to convert in env file
  45876. * @return a promise containing the environment data if succesfull.
  45877. */
  45878. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45879. /**
  45880. * Creates a JSON representation of the spherical data.
  45881. * @param texture defines the texture containing the polynomials
  45882. * @return the JSON representation of the spherical info
  45883. */
  45884. private static _CreateEnvTextureIrradiance;
  45885. /**
  45886. * Uploads the texture info contained in the env file to the GPU.
  45887. * @param texture defines the internal texture to upload to
  45888. * @param arrayBuffer defines the buffer cotaining the data to load
  45889. * @param info defines the texture info retrieved through the GetEnvInfo method
  45890. * @returns a promise
  45891. */
  45892. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45893. /**
  45894. * Uploads the levels of image data to the GPU.
  45895. * @param texture defines the internal texture to upload to
  45896. * @param imageData defines the array buffer views of image data [mipmap][face]
  45897. * @returns a promise
  45898. */
  45899. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45900. /**
  45901. * Uploads spherical polynomials information to the texture.
  45902. * @param texture defines the texture we are trying to upload the information to
  45903. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45904. */
  45905. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45906. /** @hidden */
  45907. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45908. }
  45909. }
  45910. declare module BABYLON {
  45911. /**
  45912. * Implementation of the ENV Texture Loader.
  45913. * @hidden
  45914. */
  45915. export class _ENVTextureLoader implements IInternalTextureLoader {
  45916. /**
  45917. * Defines wether the loader supports cascade loading the different faces.
  45918. */
  45919. readonly supportCascades: boolean;
  45920. /**
  45921. * This returns if the loader support the current file information.
  45922. * @param extension defines the file extension of the file being loaded
  45923. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45924. * @param fallback defines the fallback internal texture if any
  45925. * @param isBase64 defines whether the texture is encoded as a base64
  45926. * @param isBuffer defines whether the texture data are stored as a buffer
  45927. * @returns true if the loader can load the specified file
  45928. */
  45929. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45930. /**
  45931. * Transform the url before loading if required.
  45932. * @param rootUrl the url of the texture
  45933. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45934. * @returns the transformed texture
  45935. */
  45936. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45937. /**
  45938. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45939. * @param rootUrl the url of the texture
  45940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45941. * @returns the fallback texture
  45942. */
  45943. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45944. /**
  45945. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45946. * @param data contains the texture data
  45947. * @param texture defines the BabylonJS internal texture
  45948. * @param createPolynomials will be true if polynomials have been requested
  45949. * @param onLoad defines the callback to trigger once the texture is ready
  45950. * @param onError defines the callback to trigger in case of error
  45951. */
  45952. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45953. /**
  45954. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45955. * @param data contains the texture data
  45956. * @param texture defines the BabylonJS internal texture
  45957. * @param callback defines the method to call once ready to upload
  45958. */
  45959. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45960. }
  45961. }
  45962. declare module BABYLON {
  45963. /**
  45964. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45965. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45966. */
  45967. export class KhronosTextureContainer {
  45968. /** contents of the KTX container file */
  45969. arrayBuffer: any;
  45970. private static HEADER_LEN;
  45971. private static COMPRESSED_2D;
  45972. private static COMPRESSED_3D;
  45973. private static TEX_2D;
  45974. private static TEX_3D;
  45975. /**
  45976. * Gets the openGL type
  45977. */
  45978. glType: number;
  45979. /**
  45980. * Gets the openGL type size
  45981. */
  45982. glTypeSize: number;
  45983. /**
  45984. * Gets the openGL format
  45985. */
  45986. glFormat: number;
  45987. /**
  45988. * Gets the openGL internal format
  45989. */
  45990. glInternalFormat: number;
  45991. /**
  45992. * Gets the base internal format
  45993. */
  45994. glBaseInternalFormat: number;
  45995. /**
  45996. * Gets image width in pixel
  45997. */
  45998. pixelWidth: number;
  45999. /**
  46000. * Gets image height in pixel
  46001. */
  46002. pixelHeight: number;
  46003. /**
  46004. * Gets image depth in pixels
  46005. */
  46006. pixelDepth: number;
  46007. /**
  46008. * Gets the number of array elements
  46009. */
  46010. numberOfArrayElements: number;
  46011. /**
  46012. * Gets the number of faces
  46013. */
  46014. numberOfFaces: number;
  46015. /**
  46016. * Gets the number of mipmap levels
  46017. */
  46018. numberOfMipmapLevels: number;
  46019. /**
  46020. * Gets the bytes of key value data
  46021. */
  46022. bytesOfKeyValueData: number;
  46023. /**
  46024. * Gets the load type
  46025. */
  46026. loadType: number;
  46027. /**
  46028. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46029. */
  46030. isInvalid: boolean;
  46031. /**
  46032. * Creates a new KhronosTextureContainer
  46033. * @param arrayBuffer contents of the KTX container file
  46034. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46035. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46036. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46037. */
  46038. constructor(
  46039. /** contents of the KTX container file */
  46040. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46041. /**
  46042. * Uploads KTX content to a Babylon Texture.
  46043. * It is assumed that the texture has already been created & is currently bound
  46044. * @hidden
  46045. */
  46046. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46047. private _upload2DCompressedLevels;
  46048. }
  46049. }
  46050. declare module BABYLON {
  46051. /**
  46052. * Implementation of the KTX Texture Loader.
  46053. * @hidden
  46054. */
  46055. export class _KTXTextureLoader implements IInternalTextureLoader {
  46056. /**
  46057. * Defines wether the loader supports cascade loading the different faces.
  46058. */
  46059. readonly supportCascades: boolean;
  46060. /**
  46061. * This returns if the loader support the current file information.
  46062. * @param extension defines the file extension of the file being loaded
  46063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46064. * @param fallback defines the fallback internal texture if any
  46065. * @param isBase64 defines whether the texture is encoded as a base64
  46066. * @param isBuffer defines whether the texture data are stored as a buffer
  46067. * @returns true if the loader can load the specified file
  46068. */
  46069. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46070. /**
  46071. * Transform the url before loading if required.
  46072. * @param rootUrl the url of the texture
  46073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46074. * @returns the transformed texture
  46075. */
  46076. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46077. /**
  46078. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46079. * @param rootUrl the url of the texture
  46080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46081. * @returns the fallback texture
  46082. */
  46083. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46084. /**
  46085. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46086. * @param data contains the texture data
  46087. * @param texture defines the BabylonJS internal texture
  46088. * @param createPolynomials will be true if polynomials have been requested
  46089. * @param onLoad defines the callback to trigger once the texture is ready
  46090. * @param onError defines the callback to trigger in case of error
  46091. */
  46092. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46093. /**
  46094. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46095. * @param data contains the texture data
  46096. * @param texture defines the BabylonJS internal texture
  46097. * @param callback defines the method to call once ready to upload
  46098. */
  46099. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46100. }
  46101. }
  46102. declare module BABYLON {
  46103. /** @hidden */
  46104. export var _forceSceneHelpersToBundle: boolean;
  46105. interface Scene {
  46106. /**
  46107. * Creates a default light for the scene.
  46108. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46109. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46110. */
  46111. createDefaultLight(replace?: boolean): void;
  46112. /**
  46113. * Creates a default camera for the scene.
  46114. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46115. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46116. * @param replace has default false, when true replaces the active camera in the scene
  46117. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46118. */
  46119. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46120. /**
  46121. * Creates a default camera and a default light.
  46122. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46123. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46124. * @param replace has the default false, when true replaces the active camera/light in the scene
  46125. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46126. */
  46127. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46128. /**
  46129. * Creates a new sky box
  46130. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46131. * @param environmentTexture defines the texture to use as environment texture
  46132. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46133. * @param scale defines the overall scale of the skybox
  46134. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46135. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46136. * @returns a new mesh holding the sky box
  46137. */
  46138. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46139. /**
  46140. * Creates a new environment
  46141. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46142. * @param options defines the options you can use to configure the environment
  46143. * @returns the new EnvironmentHelper
  46144. */
  46145. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46146. /**
  46147. * Creates a new VREXperienceHelper
  46148. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46149. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46150. * @returns a new VREXperienceHelper
  46151. */
  46152. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46153. /**
  46154. * Creates a new XREXperienceHelper
  46155. * @see http://doc.babylonjs.com/how_to/webxr
  46156. * @returns a promise for a new XREXperienceHelper
  46157. */
  46158. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46159. }
  46160. }
  46161. declare module BABYLON {
  46162. /**
  46163. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46164. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46165. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46166. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46167. */
  46168. export class VideoDome extends TransformNode {
  46169. /**
  46170. * Define the video source as a Monoscopic panoramic 360 video.
  46171. */
  46172. static readonly MODE_MONOSCOPIC: number;
  46173. /**
  46174. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46175. */
  46176. static readonly MODE_TOPBOTTOM: number;
  46177. /**
  46178. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46179. */
  46180. static readonly MODE_SIDEBYSIDE: number;
  46181. private _useDirectMapping;
  46182. /**
  46183. * The video texture being displayed on the sphere
  46184. */
  46185. protected _videoTexture: VideoTexture;
  46186. /**
  46187. * Gets the video texture being displayed on the sphere
  46188. */
  46189. readonly videoTexture: VideoTexture;
  46190. /**
  46191. * The skybox material
  46192. */
  46193. protected _material: BackgroundMaterial;
  46194. /**
  46195. * The surface used for the skybox
  46196. */
  46197. protected _mesh: Mesh;
  46198. /**
  46199. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46200. * Also see the options.resolution property.
  46201. */
  46202. fovMultiplier: number;
  46203. private _videoMode;
  46204. /**
  46205. * Gets or set the current video mode for the video. It can be:
  46206. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46207. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46208. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46209. */
  46210. videoMode: number;
  46211. /**
  46212. * Oberserver used in Stereoscopic VR Mode.
  46213. */
  46214. private _onBeforeCameraRenderObserver;
  46215. /**
  46216. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46217. * @param name Element's name, child elements will append suffixes for their own names.
  46218. * @param urlsOrVideo defines the url(s) or the video element to use
  46219. * @param options An object containing optional or exposed sub element properties
  46220. */
  46221. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46222. resolution?: number;
  46223. clickToPlay?: boolean;
  46224. autoPlay?: boolean;
  46225. loop?: boolean;
  46226. size?: number;
  46227. poster?: string;
  46228. faceForward?: boolean;
  46229. useDirectMapping?: boolean;
  46230. }, scene: Scene);
  46231. private _changeVideoMode;
  46232. /**
  46233. * Releases resources associated with this node.
  46234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46236. */
  46237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46238. }
  46239. }
  46240. declare module BABYLON {
  46241. /**
  46242. * This class can be used to get instrumentation data from a Babylon engine
  46243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46244. */
  46245. export class EngineInstrumentation implements IDisposable {
  46246. /**
  46247. * Define the instrumented engine.
  46248. */
  46249. engine: Engine;
  46250. private _captureGPUFrameTime;
  46251. private _gpuFrameTimeToken;
  46252. private _gpuFrameTime;
  46253. private _captureShaderCompilationTime;
  46254. private _shaderCompilationTime;
  46255. private _onBeginFrameObserver;
  46256. private _onEndFrameObserver;
  46257. private _onBeforeShaderCompilationObserver;
  46258. private _onAfterShaderCompilationObserver;
  46259. /**
  46260. * Gets the perf counter used for GPU frame time
  46261. */
  46262. readonly gpuFrameTimeCounter: PerfCounter;
  46263. /**
  46264. * Gets the GPU frame time capture status
  46265. */
  46266. /**
  46267. * Enable or disable the GPU frame time capture
  46268. */
  46269. captureGPUFrameTime: boolean;
  46270. /**
  46271. * Gets the perf counter used for shader compilation time
  46272. */
  46273. readonly shaderCompilationTimeCounter: PerfCounter;
  46274. /**
  46275. * Gets the shader compilation time capture status
  46276. */
  46277. /**
  46278. * Enable or disable the shader compilation time capture
  46279. */
  46280. captureShaderCompilationTime: boolean;
  46281. /**
  46282. * Instantiates a new engine instrumentation.
  46283. * This class can be used to get instrumentation data from a Babylon engine
  46284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46285. * @param engine Defines the engine to instrument
  46286. */
  46287. constructor(
  46288. /**
  46289. * Define the instrumented engine.
  46290. */
  46291. engine: Engine);
  46292. /**
  46293. * Dispose and release associated resources.
  46294. */
  46295. dispose(): void;
  46296. }
  46297. }
  46298. declare module BABYLON {
  46299. /**
  46300. * This class can be used to get instrumentation data from a Babylon engine
  46301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46302. */
  46303. export class SceneInstrumentation implements IDisposable {
  46304. /**
  46305. * Defines the scene to instrument
  46306. */
  46307. scene: Scene;
  46308. private _captureActiveMeshesEvaluationTime;
  46309. private _activeMeshesEvaluationTime;
  46310. private _captureRenderTargetsRenderTime;
  46311. private _renderTargetsRenderTime;
  46312. private _captureFrameTime;
  46313. private _frameTime;
  46314. private _captureRenderTime;
  46315. private _renderTime;
  46316. private _captureInterFrameTime;
  46317. private _interFrameTime;
  46318. private _captureParticlesRenderTime;
  46319. private _particlesRenderTime;
  46320. private _captureSpritesRenderTime;
  46321. private _spritesRenderTime;
  46322. private _capturePhysicsTime;
  46323. private _physicsTime;
  46324. private _captureAnimationsTime;
  46325. private _animationsTime;
  46326. private _captureCameraRenderTime;
  46327. private _cameraRenderTime;
  46328. private _onBeforeActiveMeshesEvaluationObserver;
  46329. private _onAfterActiveMeshesEvaluationObserver;
  46330. private _onBeforeRenderTargetsRenderObserver;
  46331. private _onAfterRenderTargetsRenderObserver;
  46332. private _onAfterRenderObserver;
  46333. private _onBeforeDrawPhaseObserver;
  46334. private _onAfterDrawPhaseObserver;
  46335. private _onBeforeAnimationsObserver;
  46336. private _onBeforeParticlesRenderingObserver;
  46337. private _onAfterParticlesRenderingObserver;
  46338. private _onBeforeSpritesRenderingObserver;
  46339. private _onAfterSpritesRenderingObserver;
  46340. private _onBeforePhysicsObserver;
  46341. private _onAfterPhysicsObserver;
  46342. private _onAfterAnimationsObserver;
  46343. private _onBeforeCameraRenderObserver;
  46344. private _onAfterCameraRenderObserver;
  46345. /**
  46346. * Gets the perf counter used for active meshes evaluation time
  46347. */
  46348. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46349. /**
  46350. * Gets the active meshes evaluation time capture status
  46351. */
  46352. /**
  46353. * Enable or disable the active meshes evaluation time capture
  46354. */
  46355. captureActiveMeshesEvaluationTime: boolean;
  46356. /**
  46357. * Gets the perf counter used for render targets render time
  46358. */
  46359. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46360. /**
  46361. * Gets the render targets render time capture status
  46362. */
  46363. /**
  46364. * Enable or disable the render targets render time capture
  46365. */
  46366. captureRenderTargetsRenderTime: boolean;
  46367. /**
  46368. * Gets the perf counter used for particles render time
  46369. */
  46370. readonly particlesRenderTimeCounter: PerfCounter;
  46371. /**
  46372. * Gets the particles render time capture status
  46373. */
  46374. /**
  46375. * Enable or disable the particles render time capture
  46376. */
  46377. captureParticlesRenderTime: boolean;
  46378. /**
  46379. * Gets the perf counter used for sprites render time
  46380. */
  46381. readonly spritesRenderTimeCounter: PerfCounter;
  46382. /**
  46383. * Gets the sprites render time capture status
  46384. */
  46385. /**
  46386. * Enable or disable the sprites render time capture
  46387. */
  46388. captureSpritesRenderTime: boolean;
  46389. /**
  46390. * Gets the perf counter used for physics time
  46391. */
  46392. readonly physicsTimeCounter: PerfCounter;
  46393. /**
  46394. * Gets the physics time capture status
  46395. */
  46396. /**
  46397. * Enable or disable the physics time capture
  46398. */
  46399. capturePhysicsTime: boolean;
  46400. /**
  46401. * Gets the perf counter used for animations time
  46402. */
  46403. readonly animationsTimeCounter: PerfCounter;
  46404. /**
  46405. * Gets the animations time capture status
  46406. */
  46407. /**
  46408. * Enable or disable the animations time capture
  46409. */
  46410. captureAnimationsTime: boolean;
  46411. /**
  46412. * Gets the perf counter used for frame time capture
  46413. */
  46414. readonly frameTimeCounter: PerfCounter;
  46415. /**
  46416. * Gets the frame time capture status
  46417. */
  46418. /**
  46419. * Enable or disable the frame time capture
  46420. */
  46421. captureFrameTime: boolean;
  46422. /**
  46423. * Gets the perf counter used for inter-frames time capture
  46424. */
  46425. readonly interFrameTimeCounter: PerfCounter;
  46426. /**
  46427. * Gets the inter-frames time capture status
  46428. */
  46429. /**
  46430. * Enable or disable the inter-frames time capture
  46431. */
  46432. captureInterFrameTime: boolean;
  46433. /**
  46434. * Gets the perf counter used for render time capture
  46435. */
  46436. readonly renderTimeCounter: PerfCounter;
  46437. /**
  46438. * Gets the render time capture status
  46439. */
  46440. /**
  46441. * Enable or disable the render time capture
  46442. */
  46443. captureRenderTime: boolean;
  46444. /**
  46445. * Gets the perf counter used for camera render time capture
  46446. */
  46447. readonly cameraRenderTimeCounter: PerfCounter;
  46448. /**
  46449. * Gets the camera render time capture status
  46450. */
  46451. /**
  46452. * Enable or disable the camera render time capture
  46453. */
  46454. captureCameraRenderTime: boolean;
  46455. /**
  46456. * Gets the perf counter used for draw calls
  46457. */
  46458. readonly drawCallsCounter: PerfCounter;
  46459. /**
  46460. * Instantiates a new scene instrumentation.
  46461. * This class can be used to get instrumentation data from a Babylon engine
  46462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46463. * @param scene Defines the scene to instrument
  46464. */
  46465. constructor(
  46466. /**
  46467. * Defines the scene to instrument
  46468. */
  46469. scene: Scene);
  46470. /**
  46471. * Dispose and release associated resources.
  46472. */
  46473. dispose(): void;
  46474. }
  46475. }
  46476. declare module BABYLON {
  46477. /** @hidden */
  46478. export var glowMapGenerationPixelShader: {
  46479. name: string;
  46480. shader: string;
  46481. };
  46482. }
  46483. declare module BABYLON {
  46484. /** @hidden */
  46485. export var glowMapGenerationVertexShader: {
  46486. name: string;
  46487. shader: string;
  46488. };
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * Effect layer options. This helps customizing the behaviour
  46493. * of the effect layer.
  46494. */
  46495. export interface IEffectLayerOptions {
  46496. /**
  46497. * Multiplication factor apply to the canvas size to compute the render target size
  46498. * used to generated the objects (the smaller the faster).
  46499. */
  46500. mainTextureRatio: number;
  46501. /**
  46502. * Enforces a fixed size texture to ensure effect stability across devices.
  46503. */
  46504. mainTextureFixedSize?: number;
  46505. /**
  46506. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46507. */
  46508. alphaBlendingMode: number;
  46509. /**
  46510. * The camera attached to the layer.
  46511. */
  46512. camera: Nullable<Camera>;
  46513. /**
  46514. * The rendering group to draw the layer in.
  46515. */
  46516. renderingGroupId: number;
  46517. }
  46518. /**
  46519. * The effect layer Helps adding post process effect blended with the main pass.
  46520. *
  46521. * This can be for instance use to generate glow or higlight effects on the scene.
  46522. *
  46523. * The effect layer class can not be used directly and is intented to inherited from to be
  46524. * customized per effects.
  46525. */
  46526. export abstract class EffectLayer {
  46527. private _vertexBuffers;
  46528. private _indexBuffer;
  46529. private _cachedDefines;
  46530. private _effectLayerMapGenerationEffect;
  46531. private _effectLayerOptions;
  46532. private _mergeEffect;
  46533. protected _scene: Scene;
  46534. protected _engine: Engine;
  46535. protected _maxSize: number;
  46536. protected _mainTextureDesiredSize: ISize;
  46537. protected _mainTexture: RenderTargetTexture;
  46538. protected _shouldRender: boolean;
  46539. protected _postProcesses: PostProcess[];
  46540. protected _textures: BaseTexture[];
  46541. protected _emissiveTextureAndColor: {
  46542. texture: Nullable<BaseTexture>;
  46543. color: Color4;
  46544. };
  46545. /**
  46546. * The name of the layer
  46547. */
  46548. name: string;
  46549. /**
  46550. * The clear color of the texture used to generate the glow map.
  46551. */
  46552. neutralColor: Color4;
  46553. /**
  46554. * Specifies wether the highlight layer is enabled or not.
  46555. */
  46556. isEnabled: boolean;
  46557. /**
  46558. * Gets the camera attached to the layer.
  46559. */
  46560. readonly camera: Nullable<Camera>;
  46561. /**
  46562. * Gets the rendering group id the layer should render in.
  46563. */
  46564. readonly renderingGroupId: number;
  46565. /**
  46566. * An event triggered when the effect layer has been disposed.
  46567. */
  46568. onDisposeObservable: Observable<EffectLayer>;
  46569. /**
  46570. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46571. */
  46572. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46573. /**
  46574. * An event triggered when the generated texture is being merged in the scene.
  46575. */
  46576. onBeforeComposeObservable: Observable<EffectLayer>;
  46577. /**
  46578. * An event triggered when the generated texture has been merged in the scene.
  46579. */
  46580. onAfterComposeObservable: Observable<EffectLayer>;
  46581. /**
  46582. * An event triggered when the efffect layer changes its size.
  46583. */
  46584. onSizeChangedObservable: Observable<EffectLayer>;
  46585. /** @hidden */
  46586. static _SceneComponentInitialization: (scene: Scene) => void;
  46587. /**
  46588. * Instantiates a new effect Layer and references it in the scene.
  46589. * @param name The name of the layer
  46590. * @param scene The scene to use the layer in
  46591. */
  46592. constructor(
  46593. /** The Friendly of the effect in the scene */
  46594. name: string, scene: Scene);
  46595. /**
  46596. * Get the effect name of the layer.
  46597. * @return The effect name
  46598. */
  46599. abstract getEffectName(): string;
  46600. /**
  46601. * Checks for the readiness of the element composing the layer.
  46602. * @param subMesh the mesh to check for
  46603. * @param useInstances specify wether or not to use instances to render the mesh
  46604. * @return true if ready otherwise, false
  46605. */
  46606. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46607. /**
  46608. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46609. * @returns true if the effect requires stencil during the main canvas render pass.
  46610. */
  46611. abstract needStencil(): boolean;
  46612. /**
  46613. * Create the merge effect. This is the shader use to blit the information back
  46614. * to the main canvas at the end of the scene rendering.
  46615. * @returns The effect containing the shader used to merge the effect on the main canvas
  46616. */
  46617. protected abstract _createMergeEffect(): Effect;
  46618. /**
  46619. * Creates the render target textures and post processes used in the effect layer.
  46620. */
  46621. protected abstract _createTextureAndPostProcesses(): void;
  46622. /**
  46623. * Implementation specific of rendering the generating effect on the main canvas.
  46624. * @param effect The effect used to render through
  46625. */
  46626. protected abstract _internalRender(effect: Effect): void;
  46627. /**
  46628. * Sets the required values for both the emissive texture and and the main color.
  46629. */
  46630. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46631. /**
  46632. * Free any resources and references associated to a mesh.
  46633. * Internal use
  46634. * @param mesh The mesh to free.
  46635. */
  46636. abstract _disposeMesh(mesh: Mesh): void;
  46637. /**
  46638. * Serializes this layer (Glow or Highlight for example)
  46639. * @returns a serialized layer object
  46640. */
  46641. abstract serialize?(): any;
  46642. /**
  46643. * Initializes the effect layer with the required options.
  46644. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46645. */
  46646. protected _init(options: Partial<IEffectLayerOptions>): void;
  46647. /**
  46648. * Generates the index buffer of the full screen quad blending to the main canvas.
  46649. */
  46650. private _generateIndexBuffer;
  46651. /**
  46652. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46653. */
  46654. private _genrateVertexBuffer;
  46655. /**
  46656. * Sets the main texture desired size which is the closest power of two
  46657. * of the engine canvas size.
  46658. */
  46659. private _setMainTextureSize;
  46660. /**
  46661. * Creates the main texture for the effect layer.
  46662. */
  46663. protected _createMainTexture(): void;
  46664. /**
  46665. * Adds specific effects defines.
  46666. * @param defines The defines to add specifics to.
  46667. */
  46668. protected _addCustomEffectDefines(defines: string[]): void;
  46669. /**
  46670. * Checks for the readiness of the element composing the layer.
  46671. * @param subMesh the mesh to check for
  46672. * @param useInstances specify wether or not to use instances to render the mesh
  46673. * @param emissiveTexture the associated emissive texture used to generate the glow
  46674. * @return true if ready otherwise, false
  46675. */
  46676. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46677. /**
  46678. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46679. */
  46680. render(): void;
  46681. /**
  46682. * Determine if a given mesh will be used in the current effect.
  46683. * @param mesh mesh to test
  46684. * @returns true if the mesh will be used
  46685. */
  46686. hasMesh(mesh: AbstractMesh): boolean;
  46687. /**
  46688. * Returns true if the layer contains information to display, otherwise false.
  46689. * @returns true if the glow layer should be rendered
  46690. */
  46691. shouldRender(): boolean;
  46692. /**
  46693. * Returns true if the mesh should render, otherwise false.
  46694. * @param mesh The mesh to render
  46695. * @returns true if it should render otherwise false
  46696. */
  46697. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46698. /**
  46699. * Returns true if the mesh can be rendered, otherwise false.
  46700. * @param mesh The mesh to render
  46701. * @param material The material used on the mesh
  46702. * @returns true if it can be rendered otherwise false
  46703. */
  46704. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46705. /**
  46706. * Returns true if the mesh should render, otherwise false.
  46707. * @param mesh The mesh to render
  46708. * @returns true if it should render otherwise false
  46709. */
  46710. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46711. /**
  46712. * Renders the submesh passed in parameter to the generation map.
  46713. */
  46714. protected _renderSubMesh(subMesh: SubMesh): void;
  46715. /**
  46716. * Rebuild the required buffers.
  46717. * @hidden Internal use only.
  46718. */
  46719. _rebuild(): void;
  46720. /**
  46721. * Dispose only the render target textures and post process.
  46722. */
  46723. private _disposeTextureAndPostProcesses;
  46724. /**
  46725. * Dispose the highlight layer and free resources.
  46726. */
  46727. dispose(): void;
  46728. /**
  46729. * Gets the class name of the effect layer
  46730. * @returns the string with the class name of the effect layer
  46731. */
  46732. getClassName(): string;
  46733. /**
  46734. * Creates an effect layer from parsed effect layer data
  46735. * @param parsedEffectLayer defines effect layer data
  46736. * @param scene defines the current scene
  46737. * @param rootUrl defines the root URL containing the effect layer information
  46738. * @returns a parsed effect Layer
  46739. */
  46740. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46741. }
  46742. }
  46743. declare module BABYLON {
  46744. interface AbstractScene {
  46745. /**
  46746. * The list of effect layers (highlights/glow) added to the scene
  46747. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46748. * @see http://doc.babylonjs.com/how_to/glow_layer
  46749. */
  46750. effectLayers: Array<EffectLayer>;
  46751. /**
  46752. * Removes the given effect layer from this scene.
  46753. * @param toRemove defines the effect layer to remove
  46754. * @returns the index of the removed effect layer
  46755. */
  46756. removeEffectLayer(toRemove: EffectLayer): number;
  46757. /**
  46758. * Adds the given effect layer to this scene
  46759. * @param newEffectLayer defines the effect layer to add
  46760. */
  46761. addEffectLayer(newEffectLayer: EffectLayer): void;
  46762. }
  46763. /**
  46764. * Defines the layer scene component responsible to manage any effect layers
  46765. * in a given scene.
  46766. */
  46767. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46768. /**
  46769. * The component name helpfull to identify the component in the list of scene components.
  46770. */
  46771. readonly name: string;
  46772. /**
  46773. * The scene the component belongs to.
  46774. */
  46775. scene: Scene;
  46776. private _engine;
  46777. private _renderEffects;
  46778. private _needStencil;
  46779. private _previousStencilState;
  46780. /**
  46781. * Creates a new instance of the component for the given scene
  46782. * @param scene Defines the scene to register the component in
  46783. */
  46784. constructor(scene: Scene);
  46785. /**
  46786. * Registers the component in a given scene
  46787. */
  46788. register(): void;
  46789. /**
  46790. * Rebuilds the elements related to this component in case of
  46791. * context lost for instance.
  46792. */
  46793. rebuild(): void;
  46794. /**
  46795. * Serializes the component data to the specified json object
  46796. * @param serializationObject The object to serialize to
  46797. */
  46798. serialize(serializationObject: any): void;
  46799. /**
  46800. * Adds all the element from the container to the scene
  46801. * @param container the container holding the elements
  46802. */
  46803. addFromContainer(container: AbstractScene): void;
  46804. /**
  46805. * Removes all the elements in the container from the scene
  46806. * @param container contains the elements to remove
  46807. * @param dispose if the removed element should be disposed (default: false)
  46808. */
  46809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46810. /**
  46811. * Disposes the component and the associated ressources.
  46812. */
  46813. dispose(): void;
  46814. private _isReadyForMesh;
  46815. private _renderMainTexture;
  46816. private _setStencil;
  46817. private _setStencilBack;
  46818. private _draw;
  46819. private _drawCamera;
  46820. private _drawRenderingGroup;
  46821. }
  46822. }
  46823. declare module BABYLON {
  46824. /** @hidden */
  46825. export var glowMapMergePixelShader: {
  46826. name: string;
  46827. shader: string;
  46828. };
  46829. }
  46830. declare module BABYLON {
  46831. /** @hidden */
  46832. export var glowMapMergeVertexShader: {
  46833. name: string;
  46834. shader: string;
  46835. };
  46836. }
  46837. declare module BABYLON {
  46838. interface AbstractScene {
  46839. /**
  46840. * Return a the first highlight layer of the scene with a given name.
  46841. * @param name The name of the highlight layer to look for.
  46842. * @return The highlight layer if found otherwise null.
  46843. */
  46844. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46845. }
  46846. /**
  46847. * Glow layer options. This helps customizing the behaviour
  46848. * of the glow layer.
  46849. */
  46850. export interface IGlowLayerOptions {
  46851. /**
  46852. * Multiplication factor apply to the canvas size to compute the render target size
  46853. * used to generated the glowing objects (the smaller the faster).
  46854. */
  46855. mainTextureRatio: number;
  46856. /**
  46857. * Enforces a fixed size texture to ensure resize independant blur.
  46858. */
  46859. mainTextureFixedSize?: number;
  46860. /**
  46861. * How big is the kernel of the blur texture.
  46862. */
  46863. blurKernelSize: number;
  46864. /**
  46865. * The camera attached to the layer.
  46866. */
  46867. camera: Nullable<Camera>;
  46868. /**
  46869. * Enable MSAA by chosing the number of samples.
  46870. */
  46871. mainTextureSamples?: number;
  46872. /**
  46873. * The rendering group to draw the layer in.
  46874. */
  46875. renderingGroupId: number;
  46876. }
  46877. /**
  46878. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46879. *
  46880. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46881. * glowy meshes to your scene.
  46882. *
  46883. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46884. */
  46885. export class GlowLayer extends EffectLayer {
  46886. /**
  46887. * Effect Name of the layer.
  46888. */
  46889. static readonly EffectName: string;
  46890. /**
  46891. * The default blur kernel size used for the glow.
  46892. */
  46893. static DefaultBlurKernelSize: number;
  46894. /**
  46895. * The default texture size ratio used for the glow.
  46896. */
  46897. static DefaultTextureRatio: number;
  46898. /**
  46899. * Sets the kernel size of the blur.
  46900. */
  46901. /**
  46902. * Gets the kernel size of the blur.
  46903. */
  46904. blurKernelSize: number;
  46905. /**
  46906. * Sets the glow intensity.
  46907. */
  46908. /**
  46909. * Gets the glow intensity.
  46910. */
  46911. intensity: number;
  46912. private _options;
  46913. private _intensity;
  46914. private _horizontalBlurPostprocess1;
  46915. private _verticalBlurPostprocess1;
  46916. private _horizontalBlurPostprocess2;
  46917. private _verticalBlurPostprocess2;
  46918. private _blurTexture1;
  46919. private _blurTexture2;
  46920. private _postProcesses1;
  46921. private _postProcesses2;
  46922. private _includedOnlyMeshes;
  46923. private _excludedMeshes;
  46924. /**
  46925. * Callback used to let the user override the color selection on a per mesh basis
  46926. */
  46927. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46928. /**
  46929. * Callback used to let the user override the texture selection on a per mesh basis
  46930. */
  46931. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46932. /**
  46933. * Instantiates a new glow Layer and references it to the scene.
  46934. * @param name The name of the layer
  46935. * @param scene The scene to use the layer in
  46936. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46937. */
  46938. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46939. /**
  46940. * Get the effect name of the layer.
  46941. * @return The effect name
  46942. */
  46943. getEffectName(): string;
  46944. /**
  46945. * Create the merge effect. This is the shader use to blit the information back
  46946. * to the main canvas at the end of the scene rendering.
  46947. */
  46948. protected _createMergeEffect(): Effect;
  46949. /**
  46950. * Creates the render target textures and post processes used in the glow layer.
  46951. */
  46952. protected _createTextureAndPostProcesses(): void;
  46953. /**
  46954. * Checks for the readiness of the element composing the layer.
  46955. * @param subMesh the mesh to check for
  46956. * @param useInstances specify wether or not to use instances to render the mesh
  46957. * @param emissiveTexture the associated emissive texture used to generate the glow
  46958. * @return true if ready otherwise, false
  46959. */
  46960. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46961. /**
  46962. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46963. */
  46964. needStencil(): boolean;
  46965. /**
  46966. * Returns true if the mesh can be rendered, otherwise false.
  46967. * @param mesh The mesh to render
  46968. * @param material The material used on the mesh
  46969. * @returns true if it can be rendered otherwise false
  46970. */
  46971. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46972. /**
  46973. * Implementation specific of rendering the generating effect on the main canvas.
  46974. * @param effect The effect used to render through
  46975. */
  46976. protected _internalRender(effect: Effect): void;
  46977. /**
  46978. * Sets the required values for both the emissive texture and and the main color.
  46979. */
  46980. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46981. /**
  46982. * Returns true if the mesh should render, otherwise false.
  46983. * @param mesh The mesh to render
  46984. * @returns true if it should render otherwise false
  46985. */
  46986. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46987. /**
  46988. * Adds specific effects defines.
  46989. * @param defines The defines to add specifics to.
  46990. */
  46991. protected _addCustomEffectDefines(defines: string[]): void;
  46992. /**
  46993. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46994. * @param mesh The mesh to exclude from the glow layer
  46995. */
  46996. addExcludedMesh(mesh: Mesh): void;
  46997. /**
  46998. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46999. * @param mesh The mesh to remove
  47000. */
  47001. removeExcludedMesh(mesh: Mesh): void;
  47002. /**
  47003. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47004. * @param mesh The mesh to include in the glow layer
  47005. */
  47006. addIncludedOnlyMesh(mesh: Mesh): void;
  47007. /**
  47008. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47009. * @param mesh The mesh to remove
  47010. */
  47011. removeIncludedOnlyMesh(mesh: Mesh): void;
  47012. /**
  47013. * Determine if a given mesh will be used in the glow layer
  47014. * @param mesh The mesh to test
  47015. * @returns true if the mesh will be highlighted by the current glow layer
  47016. */
  47017. hasMesh(mesh: AbstractMesh): boolean;
  47018. /**
  47019. * Free any resources and references associated to a mesh.
  47020. * Internal use
  47021. * @param mesh The mesh to free.
  47022. * @hidden
  47023. */
  47024. _disposeMesh(mesh: Mesh): void;
  47025. /**
  47026. * Gets the class name of the effect layer
  47027. * @returns the string with the class name of the effect layer
  47028. */
  47029. getClassName(): string;
  47030. /**
  47031. * Serializes this glow layer
  47032. * @returns a serialized glow layer object
  47033. */
  47034. serialize(): any;
  47035. /**
  47036. * Creates a Glow Layer from parsed glow layer data
  47037. * @param parsedGlowLayer defines glow layer data
  47038. * @param scene defines the current scene
  47039. * @param rootUrl defines the root URL containing the glow layer information
  47040. * @returns a parsed Glow Layer
  47041. */
  47042. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47043. }
  47044. }
  47045. declare module BABYLON {
  47046. /** @hidden */
  47047. export var glowBlurPostProcessPixelShader: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module BABYLON {
  47053. interface AbstractScene {
  47054. /**
  47055. * Return a the first highlight layer of the scene with a given name.
  47056. * @param name The name of the highlight layer to look for.
  47057. * @return The highlight layer if found otherwise null.
  47058. */
  47059. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47060. }
  47061. /**
  47062. * Highlight layer options. This helps customizing the behaviour
  47063. * of the highlight layer.
  47064. */
  47065. export interface IHighlightLayerOptions {
  47066. /**
  47067. * Multiplication factor apply to the canvas size to compute the render target size
  47068. * used to generated the glowing objects (the smaller the faster).
  47069. */
  47070. mainTextureRatio: number;
  47071. /**
  47072. * Enforces a fixed size texture to ensure resize independant blur.
  47073. */
  47074. mainTextureFixedSize?: number;
  47075. /**
  47076. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47077. * of the picture to blur (the smaller the faster).
  47078. */
  47079. blurTextureSizeRatio: number;
  47080. /**
  47081. * How big in texel of the blur texture is the vertical blur.
  47082. */
  47083. blurVerticalSize: number;
  47084. /**
  47085. * How big in texel of the blur texture is the horizontal blur.
  47086. */
  47087. blurHorizontalSize: number;
  47088. /**
  47089. * Alpha blending mode used to apply the blur. Default is combine.
  47090. */
  47091. alphaBlendingMode: number;
  47092. /**
  47093. * The camera attached to the layer.
  47094. */
  47095. camera: Nullable<Camera>;
  47096. /**
  47097. * Should we display highlight as a solid stroke?
  47098. */
  47099. isStroke?: boolean;
  47100. /**
  47101. * The rendering group to draw the layer in.
  47102. */
  47103. renderingGroupId: number;
  47104. }
  47105. /**
  47106. * The highlight layer Helps adding a glow effect around a mesh.
  47107. *
  47108. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47109. * glowy meshes to your scene.
  47110. *
  47111. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47112. */
  47113. export class HighlightLayer extends EffectLayer {
  47114. name: string;
  47115. /**
  47116. * Effect Name of the highlight layer.
  47117. */
  47118. static readonly EffectName: string;
  47119. /**
  47120. * The neutral color used during the preparation of the glow effect.
  47121. * This is black by default as the blend operation is a blend operation.
  47122. */
  47123. static NeutralColor: Color4;
  47124. /**
  47125. * Stencil value used for glowing meshes.
  47126. */
  47127. static GlowingMeshStencilReference: number;
  47128. /**
  47129. * Stencil value used for the other meshes in the scene.
  47130. */
  47131. static NormalMeshStencilReference: number;
  47132. /**
  47133. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47134. */
  47135. innerGlow: boolean;
  47136. /**
  47137. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47138. */
  47139. outerGlow: boolean;
  47140. /**
  47141. * Specifies the horizontal size of the blur.
  47142. */
  47143. /**
  47144. * Gets the horizontal size of the blur.
  47145. */
  47146. blurHorizontalSize: number;
  47147. /**
  47148. * Specifies the vertical size of the blur.
  47149. */
  47150. /**
  47151. * Gets the vertical size of the blur.
  47152. */
  47153. blurVerticalSize: number;
  47154. /**
  47155. * An event triggered when the highlight layer is being blurred.
  47156. */
  47157. onBeforeBlurObservable: Observable<HighlightLayer>;
  47158. /**
  47159. * An event triggered when the highlight layer has been blurred.
  47160. */
  47161. onAfterBlurObservable: Observable<HighlightLayer>;
  47162. private _instanceGlowingMeshStencilReference;
  47163. private _options;
  47164. private _downSamplePostprocess;
  47165. private _horizontalBlurPostprocess;
  47166. private _verticalBlurPostprocess;
  47167. private _blurTexture;
  47168. private _meshes;
  47169. private _excludedMeshes;
  47170. /**
  47171. * Instantiates a new highlight Layer and references it to the scene..
  47172. * @param name The name of the layer
  47173. * @param scene The scene to use the layer in
  47174. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47175. */
  47176. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47177. /**
  47178. * Get the effect name of the layer.
  47179. * @return The effect name
  47180. */
  47181. getEffectName(): string;
  47182. /**
  47183. * Create the merge effect. This is the shader use to blit the information back
  47184. * to the main canvas at the end of the scene rendering.
  47185. */
  47186. protected _createMergeEffect(): Effect;
  47187. /**
  47188. * Creates the render target textures and post processes used in the highlight layer.
  47189. */
  47190. protected _createTextureAndPostProcesses(): void;
  47191. /**
  47192. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47193. */
  47194. needStencil(): boolean;
  47195. /**
  47196. * Checks for the readiness of the element composing the layer.
  47197. * @param subMesh the mesh to check for
  47198. * @param useInstances specify wether or not to use instances to render the mesh
  47199. * @param emissiveTexture the associated emissive texture used to generate the glow
  47200. * @return true if ready otherwise, false
  47201. */
  47202. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47203. /**
  47204. * Implementation specific of rendering the generating effect on the main canvas.
  47205. * @param effect The effect used to render through
  47206. */
  47207. protected _internalRender(effect: Effect): void;
  47208. /**
  47209. * Returns true if the layer contains information to display, otherwise false.
  47210. */
  47211. shouldRender(): boolean;
  47212. /**
  47213. * Returns true if the mesh should render, otherwise false.
  47214. * @param mesh The mesh to render
  47215. * @returns true if it should render otherwise false
  47216. */
  47217. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47218. /**
  47219. * Sets the required values for both the emissive texture and and the main color.
  47220. */
  47221. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47222. /**
  47223. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47224. * @param mesh The mesh to exclude from the highlight layer
  47225. */
  47226. addExcludedMesh(mesh: Mesh): void;
  47227. /**
  47228. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47229. * @param mesh The mesh to highlight
  47230. */
  47231. removeExcludedMesh(mesh: Mesh): void;
  47232. /**
  47233. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47234. * @param mesh mesh to test
  47235. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47236. */
  47237. hasMesh(mesh: AbstractMesh): boolean;
  47238. /**
  47239. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47240. * @param mesh The mesh to highlight
  47241. * @param color The color of the highlight
  47242. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47243. */
  47244. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47245. /**
  47246. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47247. * @param mesh The mesh to highlight
  47248. */
  47249. removeMesh(mesh: Mesh): void;
  47250. /**
  47251. * Force the stencil to the normal expected value for none glowing parts
  47252. */
  47253. private _defaultStencilReference;
  47254. /**
  47255. * Free any resources and references associated to a mesh.
  47256. * Internal use
  47257. * @param mesh The mesh to free.
  47258. * @hidden
  47259. */
  47260. _disposeMesh(mesh: Mesh): void;
  47261. /**
  47262. * Dispose the highlight layer and free resources.
  47263. */
  47264. dispose(): void;
  47265. /**
  47266. * Gets the class name of the effect layer
  47267. * @returns the string with the class name of the effect layer
  47268. */
  47269. getClassName(): string;
  47270. /**
  47271. * Serializes this Highlight layer
  47272. * @returns a serialized Highlight layer object
  47273. */
  47274. serialize(): any;
  47275. /**
  47276. * Creates a Highlight layer from parsed Highlight layer data
  47277. * @param parsedHightlightLayer defines the Highlight layer data
  47278. * @param scene defines the current scene
  47279. * @param rootUrl defines the root URL containing the Highlight layer information
  47280. * @returns a parsed Highlight layer
  47281. */
  47282. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47283. }
  47284. }
  47285. declare module BABYLON {
  47286. /** @hidden */
  47287. export var lensFlarePixelShader: {
  47288. name: string;
  47289. shader: string;
  47290. };
  47291. }
  47292. declare module BABYLON {
  47293. /** @hidden */
  47294. export var lensFlareVertexShader: {
  47295. name: string;
  47296. shader: string;
  47297. };
  47298. }
  47299. declare module BABYLON {
  47300. /**
  47301. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47302. * It is usually composed of several `lensFlare`.
  47303. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47304. */
  47305. export class LensFlareSystem {
  47306. /**
  47307. * Define the name of the lens flare system
  47308. */
  47309. name: string;
  47310. /**
  47311. * List of lens flares used in this system.
  47312. */
  47313. lensFlares: LensFlare[];
  47314. /**
  47315. * Define a limit from the border the lens flare can be visible.
  47316. */
  47317. borderLimit: number;
  47318. /**
  47319. * Define a viewport border we do not want to see the lens flare in.
  47320. */
  47321. viewportBorder: number;
  47322. /**
  47323. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47324. */
  47325. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47326. /**
  47327. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47328. */
  47329. layerMask: number;
  47330. /**
  47331. * Define the id of the lens flare system in the scene.
  47332. * (equal to name by default)
  47333. */
  47334. id: string;
  47335. private _scene;
  47336. private _emitter;
  47337. private _vertexBuffers;
  47338. private _indexBuffer;
  47339. private _effect;
  47340. private _positionX;
  47341. private _positionY;
  47342. private _isEnabled;
  47343. /** @hidden */
  47344. static _SceneComponentInitialization: (scene: Scene) => void;
  47345. /**
  47346. * Instantiates a lens flare system.
  47347. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47348. * It is usually composed of several `lensFlare`.
  47349. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47350. * @param name Define the name of the lens flare system in the scene
  47351. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47352. * @param scene Define the scene the lens flare system belongs to
  47353. */
  47354. constructor(
  47355. /**
  47356. * Define the name of the lens flare system
  47357. */
  47358. name: string, emitter: any, scene: Scene);
  47359. /**
  47360. * Define if the lens flare system is enabled.
  47361. */
  47362. isEnabled: boolean;
  47363. /**
  47364. * Get the scene the effects belongs to.
  47365. * @returns the scene holding the lens flare system
  47366. */
  47367. getScene(): Scene;
  47368. /**
  47369. * Get the emitter of the lens flare system.
  47370. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47371. * @returns the emitter of the lens flare system
  47372. */
  47373. getEmitter(): any;
  47374. /**
  47375. * Set the emitter of the lens flare system.
  47376. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47377. * @param newEmitter Define the new emitter of the system
  47378. */
  47379. setEmitter(newEmitter: any): void;
  47380. /**
  47381. * Get the lens flare system emitter position.
  47382. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47383. * @returns the position
  47384. */
  47385. getEmitterPosition(): Vector3;
  47386. /**
  47387. * @hidden
  47388. */
  47389. computeEffectivePosition(globalViewport: Viewport): boolean;
  47390. /** @hidden */
  47391. _isVisible(): boolean;
  47392. /**
  47393. * @hidden
  47394. */
  47395. render(): boolean;
  47396. /**
  47397. * Dispose and release the lens flare with its associated resources.
  47398. */
  47399. dispose(): void;
  47400. /**
  47401. * Parse a lens flare system from a JSON repressentation
  47402. * @param parsedLensFlareSystem Define the JSON to parse
  47403. * @param scene Define the scene the parsed system should be instantiated in
  47404. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47405. * @returns the parsed system
  47406. */
  47407. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47408. /**
  47409. * Serialize the current Lens Flare System into a JSON representation.
  47410. * @returns the serialized JSON
  47411. */
  47412. serialize(): any;
  47413. }
  47414. }
  47415. declare module BABYLON {
  47416. /**
  47417. * This represents one of the lens effect in a `lensFlareSystem`.
  47418. * It controls one of the indiviual texture used in the effect.
  47419. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47420. */
  47421. export class LensFlare {
  47422. /**
  47423. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47424. */
  47425. size: number;
  47426. /**
  47427. * 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.
  47428. */
  47429. position: number;
  47430. /**
  47431. * Define the lens color.
  47432. */
  47433. color: Color3;
  47434. /**
  47435. * Define the lens texture.
  47436. */
  47437. texture: Nullable<Texture>;
  47438. /**
  47439. * Define the alpha mode to render this particular lens.
  47440. */
  47441. alphaMode: number;
  47442. private _system;
  47443. /**
  47444. * Creates a new Lens Flare.
  47445. * This represents one of the lens effect in a `lensFlareSystem`.
  47446. * It controls one of the indiviual texture used in the effect.
  47447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47448. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47449. * @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.
  47450. * @param color Define the lens color
  47451. * @param imgUrl Define the lens texture url
  47452. * @param system Define the `lensFlareSystem` this flare is part of
  47453. * @returns The newly created Lens Flare
  47454. */
  47455. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47456. /**
  47457. * Instantiates a new Lens Flare.
  47458. * This represents one of the lens effect in a `lensFlareSystem`.
  47459. * It controls one of the indiviual texture used in the effect.
  47460. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47461. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47462. * @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.
  47463. * @param color Define the lens color
  47464. * @param imgUrl Define the lens texture url
  47465. * @param system Define the `lensFlareSystem` this flare is part of
  47466. */
  47467. constructor(
  47468. /**
  47469. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47470. */
  47471. size: number,
  47472. /**
  47473. * 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.
  47474. */
  47475. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47476. /**
  47477. * Dispose and release the lens flare with its associated resources.
  47478. */
  47479. dispose(): void;
  47480. }
  47481. }
  47482. declare module BABYLON {
  47483. interface AbstractScene {
  47484. /**
  47485. * The list of lens flare system added to the scene
  47486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47487. */
  47488. lensFlareSystems: Array<LensFlareSystem>;
  47489. /**
  47490. * Removes the given lens flare system from this scene.
  47491. * @param toRemove The lens flare system to remove
  47492. * @returns The index of the removed lens flare system
  47493. */
  47494. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47495. /**
  47496. * Adds the given lens flare system to this scene
  47497. * @param newLensFlareSystem The lens flare system to add
  47498. */
  47499. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47500. /**
  47501. * Gets a lens flare system using its name
  47502. * @param name defines the name to look for
  47503. * @returns the lens flare system or null if not found
  47504. */
  47505. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47506. /**
  47507. * Gets a lens flare system using its id
  47508. * @param id defines the id to look for
  47509. * @returns the lens flare system or null if not found
  47510. */
  47511. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47512. }
  47513. /**
  47514. * Defines the lens flare scene component responsible to manage any lens flares
  47515. * in a given scene.
  47516. */
  47517. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47518. /**
  47519. * The component name helpfull to identify the component in the list of scene components.
  47520. */
  47521. readonly name: string;
  47522. /**
  47523. * The scene the component belongs to.
  47524. */
  47525. scene: Scene;
  47526. /**
  47527. * Creates a new instance of the component for the given scene
  47528. * @param scene Defines the scene to register the component in
  47529. */
  47530. constructor(scene: Scene);
  47531. /**
  47532. * Registers the component in a given scene
  47533. */
  47534. register(): void;
  47535. /**
  47536. * Rebuilds the elements related to this component in case of
  47537. * context lost for instance.
  47538. */
  47539. rebuild(): void;
  47540. /**
  47541. * Adds all the element from the container to the scene
  47542. * @param container the container holding the elements
  47543. */
  47544. addFromContainer(container: AbstractScene): void;
  47545. /**
  47546. * Removes all the elements in the container from the scene
  47547. * @param container contains the elements to remove
  47548. * @param dispose if the removed element should be disposed (default: false)
  47549. */
  47550. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47551. /**
  47552. * Serializes the component data to the specified json object
  47553. * @param serializationObject The object to serialize to
  47554. */
  47555. serialize(serializationObject: any): void;
  47556. /**
  47557. * Disposes the component and the associated ressources.
  47558. */
  47559. dispose(): void;
  47560. private _draw;
  47561. }
  47562. }
  47563. declare module BABYLON {
  47564. /**
  47565. * Defines the shadow generator component responsible to manage any shadow generators
  47566. * in a given scene.
  47567. */
  47568. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47569. /**
  47570. * The component name helpfull to identify the component in the list of scene components.
  47571. */
  47572. readonly name: string;
  47573. /**
  47574. * The scene the component belongs to.
  47575. */
  47576. scene: Scene;
  47577. /**
  47578. * Creates a new instance of the component for the given scene
  47579. * @param scene Defines the scene to register the component in
  47580. */
  47581. constructor(scene: Scene);
  47582. /**
  47583. * Registers the component in a given scene
  47584. */
  47585. register(): void;
  47586. /**
  47587. * Rebuilds the elements related to this component in case of
  47588. * context lost for instance.
  47589. */
  47590. rebuild(): void;
  47591. /**
  47592. * Serializes the component data to the specified json object
  47593. * @param serializationObject The object to serialize to
  47594. */
  47595. serialize(serializationObject: any): void;
  47596. /**
  47597. * Adds all the element from the container to the scene
  47598. * @param container the container holding the elements
  47599. */
  47600. addFromContainer(container: AbstractScene): void;
  47601. /**
  47602. * Removes all the elements in the container from the scene
  47603. * @param container contains the elements to remove
  47604. * @param dispose if the removed element should be disposed (default: false)
  47605. */
  47606. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47607. /**
  47608. * Rebuilds the elements related to this component in case of
  47609. * context lost for instance.
  47610. */
  47611. dispose(): void;
  47612. private _gatherRenderTargets;
  47613. }
  47614. }
  47615. declare module BABYLON {
  47616. /**
  47617. * A point light is a light defined by an unique point in world space.
  47618. * The light is emitted in every direction from this point.
  47619. * A good example of a point light is a standard light bulb.
  47620. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47621. */
  47622. export class PointLight extends ShadowLight {
  47623. private _shadowAngle;
  47624. /**
  47625. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47626. * This specifies what angle the shadow will use to be created.
  47627. *
  47628. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47629. */
  47630. /**
  47631. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47632. * This specifies what angle the shadow will use to be created.
  47633. *
  47634. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47635. */
  47636. shadowAngle: number;
  47637. /**
  47638. * Gets the direction if it has been set.
  47639. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47640. */
  47641. /**
  47642. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47643. */
  47644. direction: Vector3;
  47645. /**
  47646. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47647. * A PointLight emits the light in every direction.
  47648. * It can cast shadows.
  47649. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47650. * ```javascript
  47651. * var pointLight = new PointLight("pl", camera.position, scene);
  47652. * ```
  47653. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47654. * @param name The light friendly name
  47655. * @param position The position of the point light in the scene
  47656. * @param scene The scene the lights belongs to
  47657. */
  47658. constructor(name: string, position: Vector3, scene: Scene);
  47659. /**
  47660. * Returns the string "PointLight"
  47661. * @returns the class name
  47662. */
  47663. getClassName(): string;
  47664. /**
  47665. * Returns the integer 0.
  47666. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47667. */
  47668. getTypeID(): number;
  47669. /**
  47670. * Specifies wether or not the shadowmap should be a cube texture.
  47671. * @returns true if the shadowmap needs to be a cube texture.
  47672. */
  47673. needCube(): boolean;
  47674. /**
  47675. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47676. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47677. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47678. */
  47679. getShadowDirection(faceIndex?: number): Vector3;
  47680. /**
  47681. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47682. * - fov = PI / 2
  47683. * - aspect ratio : 1.0
  47684. * - z-near and far equal to the active camera minZ and maxZ.
  47685. * Returns the PointLight.
  47686. */
  47687. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47688. protected _buildUniformLayout(): void;
  47689. /**
  47690. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47691. * @param effect The effect to update
  47692. * @param lightIndex The index of the light in the effect to update
  47693. * @returns The point light
  47694. */
  47695. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47696. /**
  47697. * Prepares the list of defines specific to the light type.
  47698. * @param defines the list of defines
  47699. * @param lightIndex defines the index of the light for the effect
  47700. */
  47701. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47702. }
  47703. }
  47704. declare module BABYLON {
  47705. /**
  47706. * Header information of HDR texture files.
  47707. */
  47708. export interface HDRInfo {
  47709. /**
  47710. * The height of the texture in pixels.
  47711. */
  47712. height: number;
  47713. /**
  47714. * The width of the texture in pixels.
  47715. */
  47716. width: number;
  47717. /**
  47718. * The index of the beginning of the data in the binary file.
  47719. */
  47720. dataPosition: number;
  47721. }
  47722. /**
  47723. * This groups tools to convert HDR texture to native colors array.
  47724. */
  47725. export class HDRTools {
  47726. private static Ldexp;
  47727. private static Rgbe2float;
  47728. private static readStringLine;
  47729. /**
  47730. * Reads header information from an RGBE texture stored in a native array.
  47731. * More information on this format are available here:
  47732. * https://en.wikipedia.org/wiki/RGBE_image_format
  47733. *
  47734. * @param uint8array The binary file stored in native array.
  47735. * @return The header information.
  47736. */
  47737. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47738. /**
  47739. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47740. * This RGBE texture needs to store the information as a panorama.
  47741. *
  47742. * More information on this format are available here:
  47743. * https://en.wikipedia.org/wiki/RGBE_image_format
  47744. *
  47745. * @param buffer The binary file stored in an array buffer.
  47746. * @param size The expected size of the extracted cubemap.
  47747. * @return The Cube Map information.
  47748. */
  47749. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47750. /**
  47751. * Returns the pixels data extracted from an RGBE texture.
  47752. * This pixels will be stored left to right up to down in the R G B order in one array.
  47753. *
  47754. * More information on this format are available here:
  47755. * https://en.wikipedia.org/wiki/RGBE_image_format
  47756. *
  47757. * @param uint8array The binary file stored in an array buffer.
  47758. * @param hdrInfo The header information of the file.
  47759. * @return The pixels data in RGB right to left up to down order.
  47760. */
  47761. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47762. private static RGBE_ReadPixels_RLE;
  47763. }
  47764. }
  47765. declare module BABYLON {
  47766. /**
  47767. * This represents a texture coming from an HDR input.
  47768. *
  47769. * The only supported format is currently panorama picture stored in RGBE format.
  47770. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47771. */
  47772. export class HDRCubeTexture extends BaseTexture {
  47773. private static _facesMapping;
  47774. private _generateHarmonics;
  47775. private _noMipmap;
  47776. private _textureMatrix;
  47777. private _size;
  47778. private _onLoad;
  47779. private _onError;
  47780. /**
  47781. * The texture URL.
  47782. */
  47783. url: string;
  47784. /**
  47785. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47786. */
  47787. coordinatesMode: number;
  47788. protected _isBlocking: boolean;
  47789. /**
  47790. * Sets wether or not the texture is blocking during loading.
  47791. */
  47792. /**
  47793. * Gets wether or not the texture is blocking during loading.
  47794. */
  47795. isBlocking: boolean;
  47796. protected _rotationY: number;
  47797. /**
  47798. * Sets texture matrix rotation angle around Y axis in radians.
  47799. */
  47800. /**
  47801. * Gets texture matrix rotation angle around Y axis radians.
  47802. */
  47803. rotationY: number;
  47804. /**
  47805. * Gets or sets the center of the bounding box associated with the cube texture
  47806. * It must define where the camera used to render the texture was set
  47807. */
  47808. boundingBoxPosition: Vector3;
  47809. private _boundingBoxSize;
  47810. /**
  47811. * Gets or sets the size of the bounding box associated with the cube texture
  47812. * When defined, the cubemap will switch to local mode
  47813. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47814. * @example https://www.babylonjs-playground.com/#RNASML
  47815. */
  47816. boundingBoxSize: Vector3;
  47817. /**
  47818. * Instantiates an HDRTexture from the following parameters.
  47819. *
  47820. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47821. * @param scene The scene the texture will be used in
  47822. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47823. * @param noMipmap Forces to not generate the mipmap if true
  47824. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47825. * @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)
  47826. * @param reserved Reserved flag for internal use.
  47827. */
  47828. 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>);
  47829. /**
  47830. * Get the current class name of the texture useful for serialization or dynamic coding.
  47831. * @returns "HDRCubeTexture"
  47832. */
  47833. getClassName(): string;
  47834. /**
  47835. * Occurs when the file is raw .hdr file.
  47836. */
  47837. private loadTexture;
  47838. clone(): HDRCubeTexture;
  47839. delayLoad(): void;
  47840. /**
  47841. * Get the texture reflection matrix used to rotate/transform the reflection.
  47842. * @returns the reflection matrix
  47843. */
  47844. getReflectionTextureMatrix(): Matrix;
  47845. /**
  47846. * Set the texture reflection matrix used to rotate/transform the reflection.
  47847. * @param value Define the reflection matrix to set
  47848. */
  47849. setReflectionTextureMatrix(value: Matrix): void;
  47850. /**
  47851. * Parses a JSON representation of an HDR Texture in order to create the texture
  47852. * @param parsedTexture Define the JSON representation
  47853. * @param scene Define the scene the texture should be created in
  47854. * @param rootUrl Define the root url in case we need to load relative dependencies
  47855. * @returns the newly created texture after parsing
  47856. */
  47857. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47858. serialize(): any;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /**
  47863. * Class used to control physics engine
  47864. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47865. */
  47866. export class PhysicsEngine implements IPhysicsEngine {
  47867. private _physicsPlugin;
  47868. /**
  47869. * Global value used to control the smallest number supported by the simulation
  47870. */
  47871. static Epsilon: number;
  47872. private _impostors;
  47873. private _joints;
  47874. /**
  47875. * Gets the gravity vector used by the simulation
  47876. */
  47877. gravity: Vector3;
  47878. /**
  47879. * Factory used to create the default physics plugin.
  47880. * @returns The default physics plugin
  47881. */
  47882. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47883. /**
  47884. * Creates a new Physics Engine
  47885. * @param gravity defines the gravity vector used by the simulation
  47886. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47887. */
  47888. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47889. /**
  47890. * Sets the gravity vector used by the simulation
  47891. * @param gravity defines the gravity vector to use
  47892. */
  47893. setGravity(gravity: Vector3): void;
  47894. /**
  47895. * Set the time step of the physics engine.
  47896. * Default is 1/60.
  47897. * To slow it down, enter 1/600 for example.
  47898. * To speed it up, 1/30
  47899. * @param newTimeStep defines the new timestep to apply to this world.
  47900. */
  47901. setTimeStep(newTimeStep?: number): void;
  47902. /**
  47903. * Get the time step of the physics engine.
  47904. * @returns the current time step
  47905. */
  47906. getTimeStep(): number;
  47907. /**
  47908. * Release all resources
  47909. */
  47910. dispose(): void;
  47911. /**
  47912. * Gets the name of the current physics plugin
  47913. * @returns the name of the plugin
  47914. */
  47915. getPhysicsPluginName(): string;
  47916. /**
  47917. * Adding a new impostor for the impostor tracking.
  47918. * This will be done by the impostor itself.
  47919. * @param impostor the impostor to add
  47920. */
  47921. addImpostor(impostor: PhysicsImpostor): void;
  47922. /**
  47923. * Remove an impostor from the engine.
  47924. * This impostor and its mesh will not longer be updated by the physics engine.
  47925. * @param impostor the impostor to remove
  47926. */
  47927. removeImpostor(impostor: PhysicsImpostor): void;
  47928. /**
  47929. * Add a joint to the physics engine
  47930. * @param mainImpostor defines the main impostor to which the joint is added.
  47931. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47932. * @param joint defines the joint that will connect both impostors.
  47933. */
  47934. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47935. /**
  47936. * Removes a joint from the simulation
  47937. * @param mainImpostor defines the impostor used with the joint
  47938. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47939. * @param joint defines the joint to remove
  47940. */
  47941. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47942. /**
  47943. * Called by the scene. No need to call it.
  47944. * @param delta defines the timespam between frames
  47945. */
  47946. _step(delta: number): void;
  47947. /**
  47948. * Gets the current plugin used to run the simulation
  47949. * @returns current plugin
  47950. */
  47951. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47952. /**
  47953. * Gets the list of physic impostors
  47954. * @returns an array of PhysicsImpostor
  47955. */
  47956. getImpostors(): Array<PhysicsImpostor>;
  47957. /**
  47958. * Gets the impostor for a physics enabled object
  47959. * @param object defines the object impersonated by the impostor
  47960. * @returns the PhysicsImpostor or null if not found
  47961. */
  47962. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47963. /**
  47964. * Gets the impostor for a physics body object
  47965. * @param body defines physics body used by the impostor
  47966. * @returns the PhysicsImpostor or null if not found
  47967. */
  47968. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47969. /**
  47970. * Does a raycast in the physics world
  47971. * @param from when should the ray start?
  47972. * @param to when should the ray end?
  47973. * @returns PhysicsRaycastResult
  47974. */
  47975. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47976. }
  47977. }
  47978. declare module BABYLON {
  47979. /** @hidden */
  47980. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47981. private _useDeltaForWorldStep;
  47982. world: any;
  47983. name: string;
  47984. private _physicsMaterials;
  47985. private _fixedTimeStep;
  47986. private _cannonRaycastResult;
  47987. private _raycastResult;
  47988. private _removeAfterStep;
  47989. BJSCANNON: any;
  47990. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47991. setGravity(gravity: Vector3): void;
  47992. setTimeStep(timeStep: number): void;
  47993. getTimeStep(): number;
  47994. executeStep(delta: number): void;
  47995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47998. private _processChildMeshes;
  47999. removePhysicsBody(impostor: PhysicsImpostor): void;
  48000. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48001. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48002. private _addMaterial;
  48003. private _checkWithEpsilon;
  48004. private _createShape;
  48005. private _createHeightmap;
  48006. private _minus90X;
  48007. private _plus90X;
  48008. private _tmpPosition;
  48009. private _tmpDeltaPosition;
  48010. private _tmpUnityRotation;
  48011. private _updatePhysicsBodyTransformation;
  48012. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48013. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48014. isSupported(): boolean;
  48015. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48016. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48017. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48018. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48019. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48020. getBodyMass(impostor: PhysicsImpostor): number;
  48021. getBodyFriction(impostor: PhysicsImpostor): number;
  48022. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48023. getBodyRestitution(impostor: PhysicsImpostor): number;
  48024. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48025. sleepBody(impostor: PhysicsImpostor): void;
  48026. wakeUpBody(impostor: PhysicsImpostor): void;
  48027. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48028. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48029. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48030. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48031. getRadius(impostor: PhysicsImpostor): number;
  48032. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48033. dispose(): void;
  48034. private _extendNamespace;
  48035. /**
  48036. * Does a raycast in the physics world
  48037. * @param from when should the ray start?
  48038. * @param to when should the ray end?
  48039. * @returns PhysicsRaycastResult
  48040. */
  48041. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48042. }
  48043. }
  48044. declare module BABYLON {
  48045. /** @hidden */
  48046. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48047. world: any;
  48048. name: string;
  48049. BJSOIMO: any;
  48050. private _raycastResult;
  48051. constructor(iterations?: number, oimoInjection?: any);
  48052. setGravity(gravity: Vector3): void;
  48053. setTimeStep(timeStep: number): void;
  48054. getTimeStep(): number;
  48055. private _tmpImpostorsArray;
  48056. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48057. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48058. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48059. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48060. private _tmpPositionVector;
  48061. removePhysicsBody(impostor: PhysicsImpostor): void;
  48062. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48063. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48064. isSupported(): boolean;
  48065. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48066. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48068. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48069. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48070. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48071. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48072. getBodyMass(impostor: PhysicsImpostor): number;
  48073. getBodyFriction(impostor: PhysicsImpostor): number;
  48074. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48075. getBodyRestitution(impostor: PhysicsImpostor): number;
  48076. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48077. sleepBody(impostor: PhysicsImpostor): void;
  48078. wakeUpBody(impostor: PhysicsImpostor): void;
  48079. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48080. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48081. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48082. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48083. getRadius(impostor: PhysicsImpostor): number;
  48084. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48085. dispose(): void;
  48086. /**
  48087. * Does a raycast in the physics world
  48088. * @param from when should the ray start?
  48089. * @param to when should the ray end?
  48090. * @returns PhysicsRaycastResult
  48091. */
  48092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48093. }
  48094. }
  48095. declare module BABYLON {
  48096. /**
  48097. * Class containing static functions to help procedurally build meshes
  48098. */
  48099. export class RibbonBuilder {
  48100. /**
  48101. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48102. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48103. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48104. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48105. * * 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
  48106. * * 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
  48107. * * 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
  48108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48109. * * 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
  48110. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48111. * * 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
  48112. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48113. * * 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
  48114. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48116. * @param name defines the name of the mesh
  48117. * @param options defines the options used to create the mesh
  48118. * @param scene defines the hosting scene
  48119. * @returns the ribbon mesh
  48120. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48122. */
  48123. static CreateRibbon(name: string, options: {
  48124. pathArray: Vector3[][];
  48125. closeArray?: boolean;
  48126. closePath?: boolean;
  48127. offset?: number;
  48128. updatable?: boolean;
  48129. sideOrientation?: number;
  48130. frontUVs?: Vector4;
  48131. backUVs?: Vector4;
  48132. instance?: Mesh;
  48133. invertUV?: boolean;
  48134. uvs?: Vector2[];
  48135. colors?: Color4[];
  48136. }, scene?: Nullable<Scene>): Mesh;
  48137. }
  48138. }
  48139. declare module BABYLON {
  48140. /**
  48141. * Class containing static functions to help procedurally build meshes
  48142. */
  48143. export class ShapeBuilder {
  48144. /**
  48145. * 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.
  48146. * * 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.
  48147. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48148. * * 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.
  48149. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48150. * * 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
  48151. * * 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
  48152. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48154. * * 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
  48155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48157. * @param name defines the name of the mesh
  48158. * @param options defines the options used to create the mesh
  48159. * @param scene defines the hosting scene
  48160. * @returns the extruded shape mesh
  48161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48163. */
  48164. static ExtrudeShape(name: string, options: {
  48165. shape: Vector3[];
  48166. path: Vector3[];
  48167. scale?: number;
  48168. rotation?: number;
  48169. cap?: number;
  48170. updatable?: boolean;
  48171. sideOrientation?: number;
  48172. frontUVs?: Vector4;
  48173. backUVs?: Vector4;
  48174. instance?: Mesh;
  48175. invertUV?: boolean;
  48176. }, scene?: Nullable<Scene>): Mesh;
  48177. /**
  48178. * Creates an custom extruded shape mesh.
  48179. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48180. * * 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.
  48181. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48182. * * 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
  48183. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48184. * * 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
  48185. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48186. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48187. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48188. * * 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
  48189. * * 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
  48190. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48192. * * 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
  48193. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48195. * @param name defines the name of the mesh
  48196. * @param options defines the options used to create the mesh
  48197. * @param scene defines the hosting scene
  48198. * @returns the custom extruded shape mesh
  48199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48202. */
  48203. static ExtrudeShapeCustom(name: string, options: {
  48204. shape: Vector3[];
  48205. path: Vector3[];
  48206. scaleFunction?: any;
  48207. rotationFunction?: any;
  48208. ribbonCloseArray?: boolean;
  48209. ribbonClosePath?: boolean;
  48210. cap?: number;
  48211. updatable?: boolean;
  48212. sideOrientation?: number;
  48213. frontUVs?: Vector4;
  48214. backUVs?: Vector4;
  48215. instance?: Mesh;
  48216. invertUV?: boolean;
  48217. }, scene?: Nullable<Scene>): Mesh;
  48218. private static _ExtrudeShapeGeneric;
  48219. }
  48220. }
  48221. declare module BABYLON {
  48222. /**
  48223. * AmmoJS Physics plugin
  48224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48225. * @see https://github.com/kripken/ammo.js/
  48226. */
  48227. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48228. private _useDeltaForWorldStep;
  48229. /**
  48230. * Reference to the Ammo library
  48231. */
  48232. bjsAMMO: any;
  48233. /**
  48234. * Created ammoJS world which physics bodies are added to
  48235. */
  48236. world: any;
  48237. /**
  48238. * Name of the plugin
  48239. */
  48240. name: string;
  48241. private _timeStep;
  48242. private _fixedTimeStep;
  48243. private _maxSteps;
  48244. private _tmpQuaternion;
  48245. private _tmpAmmoTransform;
  48246. private _tmpAmmoQuaternion;
  48247. private _tmpAmmoConcreteContactResultCallback;
  48248. private _collisionConfiguration;
  48249. private _dispatcher;
  48250. private _overlappingPairCache;
  48251. private _solver;
  48252. private _softBodySolver;
  48253. private _tmpAmmoVectorA;
  48254. private _tmpAmmoVectorB;
  48255. private _tmpAmmoVectorC;
  48256. private _tmpAmmoVectorD;
  48257. private _tmpContactCallbackResult;
  48258. private _tmpAmmoVectorRCA;
  48259. private _tmpAmmoVectorRCB;
  48260. private _raycastResult;
  48261. private static readonly DISABLE_COLLISION_FLAG;
  48262. private static readonly KINEMATIC_FLAG;
  48263. private static readonly DISABLE_DEACTIVATION_FLAG;
  48264. /**
  48265. * Initializes the ammoJS plugin
  48266. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48267. * @param ammoInjection can be used to inject your own ammo reference
  48268. */
  48269. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48270. /**
  48271. * Sets the gravity of the physics world (m/(s^2))
  48272. * @param gravity Gravity to set
  48273. */
  48274. setGravity(gravity: Vector3): void;
  48275. /**
  48276. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48277. * @param timeStep timestep to use in seconds
  48278. */
  48279. setTimeStep(timeStep: number): void;
  48280. /**
  48281. * 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)
  48282. * @param fixedTimeStep fixedTimeStep to use in seconds
  48283. */
  48284. setFixedTimeStep(fixedTimeStep: number): void;
  48285. /**
  48286. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48287. * @param maxSteps the maximum number of steps by the physics engine per frame
  48288. */
  48289. setMaxSteps(maxSteps: number): void;
  48290. /**
  48291. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48292. * @returns the current timestep in seconds
  48293. */
  48294. getTimeStep(): number;
  48295. private _isImpostorInContact;
  48296. private _isImpostorPairInContact;
  48297. private _stepSimulation;
  48298. /**
  48299. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48300. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48301. * After the step the babylon meshes are set to the position of the physics imposters
  48302. * @param delta amount of time to step forward
  48303. * @param impostors array of imposters to update before/after the step
  48304. */
  48305. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48306. /**
  48307. * Update babylon mesh to match physics world object
  48308. * @param impostor imposter to match
  48309. */
  48310. private _afterSoftStep;
  48311. /**
  48312. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48313. * @param impostor imposter to match
  48314. */
  48315. private _ropeStep;
  48316. /**
  48317. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48318. * @param impostor imposter to match
  48319. */
  48320. private _softbodyOrClothStep;
  48321. private _tmpVector;
  48322. private _tmpMatrix;
  48323. /**
  48324. * Applies an impulse on the imposter
  48325. * @param impostor imposter to apply impulse to
  48326. * @param force amount of force to be applied to the imposter
  48327. * @param contactPoint the location to apply the impulse on the imposter
  48328. */
  48329. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48330. /**
  48331. * Applies a force on the imposter
  48332. * @param impostor imposter to apply force
  48333. * @param force amount of force to be applied to the imposter
  48334. * @param contactPoint the location to apply the force on the imposter
  48335. */
  48336. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48337. /**
  48338. * Creates a physics body using the plugin
  48339. * @param impostor the imposter to create the physics body on
  48340. */
  48341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48342. /**
  48343. * Removes the physics body from the imposter and disposes of the body's memory
  48344. * @param impostor imposter to remove the physics body from
  48345. */
  48346. removePhysicsBody(impostor: PhysicsImpostor): void;
  48347. /**
  48348. * Generates a joint
  48349. * @param impostorJoint the imposter joint to create the joint with
  48350. */
  48351. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48352. /**
  48353. * Removes a joint
  48354. * @param impostorJoint the imposter joint to remove the joint from
  48355. */
  48356. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48357. private _addMeshVerts;
  48358. /**
  48359. * Initialise the soft body vertices to match its object's (mesh) vertices
  48360. * Softbody vertices (nodes) are in world space and to match this
  48361. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48362. * @param impostor to create the softbody for
  48363. */
  48364. private _softVertexData;
  48365. /**
  48366. * Create an impostor's soft body
  48367. * @param impostor to create the softbody for
  48368. */
  48369. private _createSoftbody;
  48370. /**
  48371. * Create cloth for an impostor
  48372. * @param impostor to create the softbody for
  48373. */
  48374. private _createCloth;
  48375. /**
  48376. * Create rope for an impostor
  48377. * @param impostor to create the softbody for
  48378. */
  48379. private _createRope;
  48380. private _addHullVerts;
  48381. private _createShape;
  48382. /**
  48383. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48384. * @param impostor imposter containing the physics body and babylon object
  48385. */
  48386. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48387. /**
  48388. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48389. * @param impostor imposter containing the physics body and babylon object
  48390. * @param newPosition new position
  48391. * @param newRotation new rotation
  48392. */
  48393. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48394. /**
  48395. * If this plugin is supported
  48396. * @returns true if its supported
  48397. */
  48398. isSupported(): boolean;
  48399. /**
  48400. * Sets the linear velocity of the physics body
  48401. * @param impostor imposter to set the velocity on
  48402. * @param velocity velocity to set
  48403. */
  48404. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48405. /**
  48406. * Sets the angular velocity of the physics body
  48407. * @param impostor imposter to set the velocity on
  48408. * @param velocity velocity to set
  48409. */
  48410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48411. /**
  48412. * gets the linear velocity
  48413. * @param impostor imposter to get linear velocity from
  48414. * @returns linear velocity
  48415. */
  48416. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48417. /**
  48418. * gets the angular velocity
  48419. * @param impostor imposter to get angular velocity from
  48420. * @returns angular velocity
  48421. */
  48422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48423. /**
  48424. * Sets the mass of physics body
  48425. * @param impostor imposter to set the mass on
  48426. * @param mass mass to set
  48427. */
  48428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48429. /**
  48430. * Gets the mass of the physics body
  48431. * @param impostor imposter to get the mass from
  48432. * @returns mass
  48433. */
  48434. getBodyMass(impostor: PhysicsImpostor): number;
  48435. /**
  48436. * Gets friction of the impostor
  48437. * @param impostor impostor to get friction from
  48438. * @returns friction value
  48439. */
  48440. getBodyFriction(impostor: PhysicsImpostor): number;
  48441. /**
  48442. * Sets friction of the impostor
  48443. * @param impostor impostor to set friction on
  48444. * @param friction friction value
  48445. */
  48446. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48447. /**
  48448. * Gets restitution of the impostor
  48449. * @param impostor impostor to get restitution from
  48450. * @returns restitution value
  48451. */
  48452. getBodyRestitution(impostor: PhysicsImpostor): number;
  48453. /**
  48454. * Sets resitution of the impostor
  48455. * @param impostor impostor to set resitution on
  48456. * @param restitution resitution value
  48457. */
  48458. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48459. /**
  48460. * Gets pressure inside the impostor
  48461. * @param impostor impostor to get pressure from
  48462. * @returns pressure value
  48463. */
  48464. getBodyPressure(impostor: PhysicsImpostor): number;
  48465. /**
  48466. * Sets pressure inside a soft body impostor
  48467. * Cloth and rope must remain 0 pressure
  48468. * @param impostor impostor to set pressure on
  48469. * @param pressure pressure value
  48470. */
  48471. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48472. /**
  48473. * Gets stiffness of the impostor
  48474. * @param impostor impostor to get stiffness from
  48475. * @returns pressure value
  48476. */
  48477. getBodyStiffness(impostor: PhysicsImpostor): number;
  48478. /**
  48479. * Sets stiffness of the impostor
  48480. * @param impostor impostor to set stiffness on
  48481. * @param stiffness stiffness value from 0 to 1
  48482. */
  48483. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48484. /**
  48485. * Gets velocityIterations of the impostor
  48486. * @param impostor impostor to get velocity iterations from
  48487. * @returns velocityIterations value
  48488. */
  48489. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48490. /**
  48491. * Sets velocityIterations of the impostor
  48492. * @param impostor impostor to set velocity iterations on
  48493. * @param velocityIterations velocityIterations value
  48494. */
  48495. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48496. /**
  48497. * Gets positionIterations of the impostor
  48498. * @param impostor impostor to get position iterations from
  48499. * @returns positionIterations value
  48500. */
  48501. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48502. /**
  48503. * Sets positionIterations of the impostor
  48504. * @param impostor impostor to set position on
  48505. * @param positionIterations positionIterations value
  48506. */
  48507. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48508. /**
  48509. * Append an anchor to a cloth object
  48510. * @param impostor is the cloth impostor to add anchor to
  48511. * @param otherImpostor is the rigid impostor to anchor to
  48512. * @param width ratio across width from 0 to 1
  48513. * @param height ratio up height from 0 to 1
  48514. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48515. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48516. */
  48517. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48518. /**
  48519. * Append an hook to a rope object
  48520. * @param impostor is the rope impostor to add hook to
  48521. * @param otherImpostor is the rigid impostor to hook to
  48522. * @param length ratio along the rope from 0 to 1
  48523. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48524. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48525. */
  48526. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48527. /**
  48528. * Sleeps the physics body and stops it from being active
  48529. * @param impostor impostor to sleep
  48530. */
  48531. sleepBody(impostor: PhysicsImpostor): void;
  48532. /**
  48533. * Activates the physics body
  48534. * @param impostor impostor to activate
  48535. */
  48536. wakeUpBody(impostor: PhysicsImpostor): void;
  48537. /**
  48538. * Updates the distance parameters of the joint
  48539. * @param joint joint to update
  48540. * @param maxDistance maximum distance of the joint
  48541. * @param minDistance minimum distance of the joint
  48542. */
  48543. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48544. /**
  48545. * Sets a motor on the joint
  48546. * @param joint joint to set motor on
  48547. * @param speed speed of the motor
  48548. * @param maxForce maximum force of the motor
  48549. * @param motorIndex index of the motor
  48550. */
  48551. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48552. /**
  48553. * Sets the motors limit
  48554. * @param joint joint to set limit on
  48555. * @param upperLimit upper limit
  48556. * @param lowerLimit lower limit
  48557. */
  48558. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48559. /**
  48560. * Syncs the position and rotation of a mesh with the impostor
  48561. * @param mesh mesh to sync
  48562. * @param impostor impostor to update the mesh with
  48563. */
  48564. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48565. /**
  48566. * Gets the radius of the impostor
  48567. * @param impostor impostor to get radius from
  48568. * @returns the radius
  48569. */
  48570. getRadius(impostor: PhysicsImpostor): number;
  48571. /**
  48572. * Gets the box size of the impostor
  48573. * @param impostor impostor to get box size from
  48574. * @param result the resulting box size
  48575. */
  48576. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48577. /**
  48578. * Disposes of the impostor
  48579. */
  48580. dispose(): void;
  48581. /**
  48582. * Does a raycast in the physics world
  48583. * @param from when should the ray start?
  48584. * @param to when should the ray end?
  48585. * @returns PhysicsRaycastResult
  48586. */
  48587. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48588. }
  48589. }
  48590. declare module BABYLON {
  48591. interface AbstractScene {
  48592. /**
  48593. * The list of reflection probes added to the scene
  48594. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48595. */
  48596. reflectionProbes: Array<ReflectionProbe>;
  48597. /**
  48598. * Removes the given reflection probe from this scene.
  48599. * @param toRemove The reflection probe to remove
  48600. * @returns The index of the removed reflection probe
  48601. */
  48602. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48603. /**
  48604. * Adds the given reflection probe to this scene.
  48605. * @param newReflectionProbe The reflection probe to add
  48606. */
  48607. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48608. }
  48609. /**
  48610. * Class used to generate realtime reflection / refraction cube textures
  48611. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48612. */
  48613. export class ReflectionProbe {
  48614. /** defines the name of the probe */
  48615. name: string;
  48616. private _scene;
  48617. private _renderTargetTexture;
  48618. private _projectionMatrix;
  48619. private _viewMatrix;
  48620. private _target;
  48621. private _add;
  48622. private _attachedMesh;
  48623. private _invertYAxis;
  48624. /** Gets or sets probe position (center of the cube map) */
  48625. position: Vector3;
  48626. /**
  48627. * Creates a new reflection probe
  48628. * @param name defines the name of the probe
  48629. * @param size defines the texture resolution (for each face)
  48630. * @param scene defines the hosting scene
  48631. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48632. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48633. */
  48634. constructor(
  48635. /** defines the name of the probe */
  48636. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48637. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48638. samples: number;
  48639. /** Gets or sets the refresh rate to use (on every frame by default) */
  48640. refreshRate: number;
  48641. /**
  48642. * Gets the hosting scene
  48643. * @returns a Scene
  48644. */
  48645. getScene(): Scene;
  48646. /** Gets the internal CubeTexture used to render to */
  48647. readonly cubeTexture: RenderTargetTexture;
  48648. /** Gets the list of meshes to render */
  48649. readonly renderList: Nullable<AbstractMesh[]>;
  48650. /**
  48651. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48652. * @param mesh defines the mesh to attach to
  48653. */
  48654. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48655. /**
  48656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48657. * @param renderingGroupId The rendering group id corresponding to its index
  48658. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48659. */
  48660. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48661. /**
  48662. * Clean all associated resources
  48663. */
  48664. dispose(): void;
  48665. /**
  48666. * Converts the reflection probe information to a readable string for debug purpose.
  48667. * @param fullDetails Supports for multiple levels of logging within scene loading
  48668. * @returns the human readable reflection probe info
  48669. */
  48670. toString(fullDetails?: boolean): string;
  48671. /**
  48672. * Get the class name of the relfection probe.
  48673. * @returns "ReflectionProbe"
  48674. */
  48675. getClassName(): string;
  48676. /**
  48677. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48678. * @returns The JSON representation of the texture
  48679. */
  48680. serialize(): any;
  48681. /**
  48682. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48683. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48684. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48685. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48686. * @returns The parsed reflection probe if successful
  48687. */
  48688. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48689. }
  48690. }
  48691. declare module BABYLON {
  48692. /** @hidden */
  48693. export var _BabylonLoaderRegistered: boolean;
  48694. }
  48695. declare module BABYLON {
  48696. /**
  48697. * The Physically based simple base material of BJS.
  48698. *
  48699. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48700. * It is used as the base class for both the specGloss and metalRough conventions.
  48701. */
  48702. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48703. /**
  48704. * Number of Simultaneous lights allowed on the material.
  48705. */
  48706. maxSimultaneousLights: number;
  48707. /**
  48708. * If sets to true, disables all the lights affecting the material.
  48709. */
  48710. disableLighting: boolean;
  48711. /**
  48712. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48713. */
  48714. environmentTexture: BaseTexture;
  48715. /**
  48716. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48717. */
  48718. invertNormalMapX: boolean;
  48719. /**
  48720. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48721. */
  48722. invertNormalMapY: boolean;
  48723. /**
  48724. * Normal map used in the model.
  48725. */
  48726. normalTexture: BaseTexture;
  48727. /**
  48728. * Emissivie color used to self-illuminate the model.
  48729. */
  48730. emissiveColor: Color3;
  48731. /**
  48732. * Emissivie texture used to self-illuminate the model.
  48733. */
  48734. emissiveTexture: BaseTexture;
  48735. /**
  48736. * Occlusion Channel Strenght.
  48737. */
  48738. occlusionStrength: number;
  48739. /**
  48740. * Occlusion Texture of the material (adding extra occlusion effects).
  48741. */
  48742. occlusionTexture: BaseTexture;
  48743. /**
  48744. * Defines the alpha limits in alpha test mode.
  48745. */
  48746. alphaCutOff: number;
  48747. /**
  48748. * Gets the current double sided mode.
  48749. */
  48750. /**
  48751. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48752. */
  48753. doubleSided: boolean;
  48754. /**
  48755. * Stores the pre-calculated light information of a mesh in a texture.
  48756. */
  48757. lightmapTexture: BaseTexture;
  48758. /**
  48759. * If true, the light map contains occlusion information instead of lighting info.
  48760. */
  48761. useLightmapAsShadowmap: boolean;
  48762. /**
  48763. * Instantiates a new PBRMaterial instance.
  48764. *
  48765. * @param name The material name
  48766. * @param scene The scene the material will be use in.
  48767. */
  48768. constructor(name: string, scene: Scene);
  48769. getClassName(): string;
  48770. }
  48771. }
  48772. declare module BABYLON {
  48773. /**
  48774. * The PBR material of BJS following the metal roughness convention.
  48775. *
  48776. * This fits to the PBR convention in the GLTF definition:
  48777. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48778. */
  48779. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48780. /**
  48781. * The base color has two different interpretations depending on the value of metalness.
  48782. * When the material is a metal, the base color is the specific measured reflectance value
  48783. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48784. * of the material.
  48785. */
  48786. baseColor: Color3;
  48787. /**
  48788. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48789. * well as opacity information in the alpha channel.
  48790. */
  48791. baseTexture: BaseTexture;
  48792. /**
  48793. * Specifies the metallic scalar value of the material.
  48794. * Can also be used to scale the metalness values of the metallic texture.
  48795. */
  48796. metallic: number;
  48797. /**
  48798. * Specifies the roughness scalar value of the material.
  48799. * Can also be used to scale the roughness values of the metallic texture.
  48800. */
  48801. roughness: number;
  48802. /**
  48803. * Texture containing both the metallic value in the B channel and the
  48804. * roughness value in the G channel to keep better precision.
  48805. */
  48806. metallicRoughnessTexture: BaseTexture;
  48807. /**
  48808. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48809. *
  48810. * @param name The material name
  48811. * @param scene The scene the material will be use in.
  48812. */
  48813. constructor(name: string, scene: Scene);
  48814. /**
  48815. * Return the currrent class name of the material.
  48816. */
  48817. getClassName(): string;
  48818. /**
  48819. * Makes a duplicate of the current material.
  48820. * @param name - name to use for the new material.
  48821. */
  48822. clone(name: string): PBRMetallicRoughnessMaterial;
  48823. /**
  48824. * Serialize the material to a parsable JSON object.
  48825. */
  48826. serialize(): any;
  48827. /**
  48828. * Parses a JSON object correponding to the serialize function.
  48829. */
  48830. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48831. }
  48832. }
  48833. declare module BABYLON {
  48834. /**
  48835. * The PBR material of BJS following the specular glossiness convention.
  48836. *
  48837. * This fits to the PBR convention in the GLTF definition:
  48838. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48839. */
  48840. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48841. /**
  48842. * Specifies the diffuse color of the material.
  48843. */
  48844. diffuseColor: Color3;
  48845. /**
  48846. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48847. * channel.
  48848. */
  48849. diffuseTexture: BaseTexture;
  48850. /**
  48851. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48852. */
  48853. specularColor: Color3;
  48854. /**
  48855. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48856. */
  48857. glossiness: number;
  48858. /**
  48859. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48860. */
  48861. specularGlossinessTexture: BaseTexture;
  48862. /**
  48863. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48864. *
  48865. * @param name The material name
  48866. * @param scene The scene the material will be use in.
  48867. */
  48868. constructor(name: string, scene: Scene);
  48869. /**
  48870. * Return the currrent class name of the material.
  48871. */
  48872. getClassName(): string;
  48873. /**
  48874. * Makes a duplicate of the current material.
  48875. * @param name - name to use for the new material.
  48876. */
  48877. clone(name: string): PBRSpecularGlossinessMaterial;
  48878. /**
  48879. * Serialize the material to a parsable JSON object.
  48880. */
  48881. serialize(): any;
  48882. /**
  48883. * Parses a JSON object correponding to the serialize function.
  48884. */
  48885. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48886. }
  48887. }
  48888. declare module BABYLON {
  48889. /**
  48890. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48891. * It can help converting any input color in a desired output one. This can then be used to create effects
  48892. * from sepia, black and white to sixties or futuristic rendering...
  48893. *
  48894. * The only supported format is currently 3dl.
  48895. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48896. */
  48897. export class ColorGradingTexture extends BaseTexture {
  48898. /**
  48899. * The current texture matrix. (will always be identity in color grading texture)
  48900. */
  48901. private _textureMatrix;
  48902. /**
  48903. * The texture URL.
  48904. */
  48905. url: string;
  48906. /**
  48907. * Empty line regex stored for GC.
  48908. */
  48909. private static _noneEmptyLineRegex;
  48910. private _engine;
  48911. /**
  48912. * Instantiates a ColorGradingTexture from the following parameters.
  48913. *
  48914. * @param url The location of the color gradind data (currently only supporting 3dl)
  48915. * @param scene The scene the texture will be used in
  48916. */
  48917. constructor(url: string, scene: Scene);
  48918. /**
  48919. * Returns the texture matrix used in most of the material.
  48920. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48921. */
  48922. getTextureMatrix(): Matrix;
  48923. /**
  48924. * Occurs when the file being loaded is a .3dl LUT file.
  48925. */
  48926. private load3dlTexture;
  48927. /**
  48928. * Starts the loading process of the texture.
  48929. */
  48930. private loadTexture;
  48931. /**
  48932. * Clones the color gradind texture.
  48933. */
  48934. clone(): ColorGradingTexture;
  48935. /**
  48936. * Called during delayed load for textures.
  48937. */
  48938. delayLoad(): void;
  48939. /**
  48940. * Parses a color grading texture serialized by Babylon.
  48941. * @param parsedTexture The texture information being parsedTexture
  48942. * @param scene The scene to load the texture in
  48943. * @param rootUrl The root url of the data assets to load
  48944. * @return A color gradind texture
  48945. */
  48946. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48947. /**
  48948. * Serializes the LUT texture to json format.
  48949. */
  48950. serialize(): any;
  48951. }
  48952. }
  48953. declare module BABYLON {
  48954. /**
  48955. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48956. */
  48957. export class EquiRectangularCubeTexture extends BaseTexture {
  48958. /** The six faces of the cube. */
  48959. private static _FacesMapping;
  48960. private _noMipmap;
  48961. private _onLoad;
  48962. private _onError;
  48963. /** The size of the cubemap. */
  48964. private _size;
  48965. /** The buffer of the image. */
  48966. private _buffer;
  48967. /** The width of the input image. */
  48968. private _width;
  48969. /** The height of the input image. */
  48970. private _height;
  48971. /** The URL to the image. */
  48972. url: string;
  48973. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48974. coordinatesMode: number;
  48975. /**
  48976. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48977. * @param url The location of the image
  48978. * @param scene The scene the texture will be used in
  48979. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48980. * @param noMipmap Forces to not generate the mipmap if true
  48981. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48982. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48983. * @param onLoad — defines a callback called when texture is loaded
  48984. * @param onError — defines a callback called if there is an error
  48985. */
  48986. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48987. /**
  48988. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48989. */
  48990. private loadImage;
  48991. /**
  48992. * Convert the image buffer into a cubemap and create a CubeTexture.
  48993. */
  48994. private loadTexture;
  48995. /**
  48996. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48997. * @param buffer The ArrayBuffer that should be converted.
  48998. * @returns The buffer as Float32Array.
  48999. */
  49000. private getFloat32ArrayFromArrayBuffer;
  49001. /**
  49002. * Get the current class name of the texture useful for serialization or dynamic coding.
  49003. * @returns "EquiRectangularCubeTexture"
  49004. */
  49005. getClassName(): string;
  49006. /**
  49007. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49008. * @returns A clone of the current EquiRectangularCubeTexture.
  49009. */
  49010. clone(): EquiRectangularCubeTexture;
  49011. }
  49012. }
  49013. declare module BABYLON {
  49014. /**
  49015. * Based on jsTGALoader - Javascript loader for TGA file
  49016. * By Vincent Thibault
  49017. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49018. */
  49019. export class TGATools {
  49020. private static _TYPE_INDEXED;
  49021. private static _TYPE_RGB;
  49022. private static _TYPE_GREY;
  49023. private static _TYPE_RLE_INDEXED;
  49024. private static _TYPE_RLE_RGB;
  49025. private static _TYPE_RLE_GREY;
  49026. private static _ORIGIN_MASK;
  49027. private static _ORIGIN_SHIFT;
  49028. private static _ORIGIN_BL;
  49029. private static _ORIGIN_BR;
  49030. private static _ORIGIN_UL;
  49031. private static _ORIGIN_UR;
  49032. /**
  49033. * Gets the header of a TGA file
  49034. * @param data defines the TGA data
  49035. * @returns the header
  49036. */
  49037. static GetTGAHeader(data: Uint8Array): any;
  49038. /**
  49039. * Uploads TGA content to a Babylon Texture
  49040. * @hidden
  49041. */
  49042. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49043. /** @hidden */
  49044. 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;
  49045. /** @hidden */
  49046. 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;
  49047. /** @hidden */
  49048. 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;
  49049. /** @hidden */
  49050. 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;
  49051. /** @hidden */
  49052. 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;
  49053. /** @hidden */
  49054. 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;
  49055. }
  49056. }
  49057. declare module BABYLON {
  49058. /**
  49059. * Implementation of the TGA Texture Loader.
  49060. * @hidden
  49061. */
  49062. export class _TGATextureLoader implements IInternalTextureLoader {
  49063. /**
  49064. * Defines wether the loader supports cascade loading the different faces.
  49065. */
  49066. readonly supportCascades: boolean;
  49067. /**
  49068. * This returns if the loader support the current file information.
  49069. * @param extension defines the file extension of the file being loaded
  49070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49071. * @param fallback defines the fallback internal texture if any
  49072. * @param isBase64 defines whether the texture is encoded as a base64
  49073. * @param isBuffer defines whether the texture data are stored as a buffer
  49074. * @returns true if the loader can load the specified file
  49075. */
  49076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49077. /**
  49078. * Transform the url before loading if required.
  49079. * @param rootUrl the url of the texture
  49080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49081. * @returns the transformed texture
  49082. */
  49083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49084. /**
  49085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49086. * @param rootUrl the url of the texture
  49087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49088. * @returns the fallback texture
  49089. */
  49090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49091. /**
  49092. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49093. * @param data contains the texture data
  49094. * @param texture defines the BabylonJS internal texture
  49095. * @param createPolynomials will be true if polynomials have been requested
  49096. * @param onLoad defines the callback to trigger once the texture is ready
  49097. * @param onError defines the callback to trigger in case of error
  49098. */
  49099. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49100. /**
  49101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49102. * @param data contains the texture data
  49103. * @param texture defines the BabylonJS internal texture
  49104. * @param callback defines the method to call once ready to upload
  49105. */
  49106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49107. }
  49108. }
  49109. declare module BABYLON {
  49110. /**
  49111. * 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.
  49112. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49113. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49114. */
  49115. export class CustomProceduralTexture extends ProceduralTexture {
  49116. private _animate;
  49117. private _time;
  49118. private _config;
  49119. private _texturePath;
  49120. /**
  49121. * Instantiates a new Custom Procedural Texture.
  49122. * 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.
  49123. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49124. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49125. * @param name Define the name of the texture
  49126. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49127. * @param size Define the size of the texture to create
  49128. * @param scene Define the scene the texture belongs to
  49129. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49130. * @param generateMipMaps Define if the texture should creates mip maps or not
  49131. */
  49132. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49133. private _loadJson;
  49134. /**
  49135. * Is the texture ready to be used ? (rendered at least once)
  49136. * @returns true if ready, otherwise, false.
  49137. */
  49138. isReady(): boolean;
  49139. /**
  49140. * Render the texture to its associated render target.
  49141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49142. */
  49143. render(useCameraPostProcess?: boolean): void;
  49144. /**
  49145. * Update the list of dependant textures samplers in the shader.
  49146. */
  49147. updateTextures(): void;
  49148. /**
  49149. * Update the uniform values of the procedural texture in the shader.
  49150. */
  49151. updateShaderUniforms(): void;
  49152. /**
  49153. * Define if the texture animates or not.
  49154. */
  49155. animate: boolean;
  49156. }
  49157. }
  49158. declare module BABYLON {
  49159. /** @hidden */
  49160. export var noisePixelShader: {
  49161. name: string;
  49162. shader: string;
  49163. };
  49164. }
  49165. declare module BABYLON {
  49166. /**
  49167. * Class used to generate noise procedural textures
  49168. */
  49169. export class NoiseProceduralTexture extends ProceduralTexture {
  49170. private _time;
  49171. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49172. brightness: number;
  49173. /** Defines the number of octaves to process */
  49174. octaves: number;
  49175. /** Defines the level of persistence (0.8 by default) */
  49176. persistence: number;
  49177. /** Gets or sets animation speed factor (default is 1) */
  49178. animationSpeedFactor: number;
  49179. /**
  49180. * Creates a new NoiseProceduralTexture
  49181. * @param name defines the name fo the texture
  49182. * @param size defines the size of the texture (default is 256)
  49183. * @param scene defines the hosting scene
  49184. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49185. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49186. */
  49187. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49188. private _updateShaderUniforms;
  49189. protected _getDefines(): string;
  49190. /** Generate the current state of the procedural texture */
  49191. render(useCameraPostProcess?: boolean): void;
  49192. /**
  49193. * Serializes this noise procedural texture
  49194. * @returns a serialized noise procedural texture object
  49195. */
  49196. serialize(): any;
  49197. /**
  49198. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49199. * @param parsedTexture defines parsed texture data
  49200. * @param scene defines the current scene
  49201. * @param rootUrl defines the root URL containing noise procedural texture information
  49202. * @returns a parsed NoiseProceduralTexture
  49203. */
  49204. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49205. }
  49206. }
  49207. declare module BABYLON {
  49208. /**
  49209. * Raw cube texture where the raw buffers are passed in
  49210. */
  49211. export class RawCubeTexture extends CubeTexture {
  49212. /**
  49213. * Creates a cube texture where the raw buffers are passed in.
  49214. * @param scene defines the scene the texture is attached to
  49215. * @param data defines the array of data to use to create each face
  49216. * @param size defines the size of the textures
  49217. * @param format defines the format of the data
  49218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49219. * @param generateMipMaps defines if the engine should generate the mip levels
  49220. * @param invertY defines if data must be stored with Y axis inverted
  49221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49222. * @param compression defines the compression used (null by default)
  49223. */
  49224. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49225. /**
  49226. * Updates the raw cube texture.
  49227. * @param data defines the data to store
  49228. * @param format defines the data format
  49229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49230. * @param invertY defines if data must be stored with Y axis inverted
  49231. * @param compression defines the compression used (null by default)
  49232. * @param level defines which level of the texture to update
  49233. */
  49234. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49235. /**
  49236. * Updates a raw cube texture with RGBD encoded data.
  49237. * @param data defines the array of data [mipmap][face] to use to create each face
  49238. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49239. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49240. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49241. * @returns a promsie that resolves when the operation is complete
  49242. */
  49243. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49244. /**
  49245. * Clones the raw cube texture.
  49246. * @return a new cube texture
  49247. */
  49248. clone(): CubeTexture;
  49249. /** @hidden */
  49250. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49251. }
  49252. }
  49253. declare module BABYLON {
  49254. /**
  49255. * Class used to store 3D textures containing user data
  49256. */
  49257. export class RawTexture3D extends Texture {
  49258. /** Gets or sets the texture format to use */
  49259. format: number;
  49260. private _engine;
  49261. /**
  49262. * Create a new RawTexture3D
  49263. * @param data defines the data of the texture
  49264. * @param width defines the width of the texture
  49265. * @param height defines the height of the texture
  49266. * @param depth defines the depth of the texture
  49267. * @param format defines the texture format to use
  49268. * @param scene defines the hosting scene
  49269. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49270. * @param invertY defines if texture must be stored with Y axis inverted
  49271. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49272. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49273. */
  49274. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49275. /** Gets or sets the texture format to use */
  49276. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49277. /**
  49278. * Update the texture with new data
  49279. * @param data defines the data to store in the texture
  49280. */
  49281. update(data: ArrayBufferView): void;
  49282. }
  49283. }
  49284. declare module BABYLON {
  49285. /**
  49286. * Creates a refraction texture used by refraction channel of the standard material.
  49287. * It is like a mirror but to see through a material.
  49288. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49289. */
  49290. export class RefractionTexture extends RenderTargetTexture {
  49291. /**
  49292. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49293. * 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.
  49294. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49295. */
  49296. refractionPlane: Plane;
  49297. /**
  49298. * Define how deep under the surface we should see.
  49299. */
  49300. depth: number;
  49301. /**
  49302. * Creates a refraction texture used by refraction channel of the standard material.
  49303. * It is like a mirror but to see through a material.
  49304. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49305. * @param name Define the texture name
  49306. * @param size Define the size of the underlying texture
  49307. * @param scene Define the scene the refraction belongs to
  49308. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49309. */
  49310. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49311. /**
  49312. * Clone the refraction texture.
  49313. * @returns the cloned texture
  49314. */
  49315. clone(): RefractionTexture;
  49316. /**
  49317. * Serialize the texture to a JSON representation you could use in Parse later on
  49318. * @returns the serialized JSON representation
  49319. */
  49320. serialize(): any;
  49321. }
  49322. }
  49323. declare module BABYLON {
  49324. /**
  49325. * Defines the options related to the creation of an HtmlElementTexture
  49326. */
  49327. export interface IHtmlElementTextureOptions {
  49328. /**
  49329. * Defines wether mip maps should be created or not.
  49330. */
  49331. generateMipMaps?: boolean;
  49332. /**
  49333. * Defines the sampling mode of the texture.
  49334. */
  49335. samplingMode?: number;
  49336. /**
  49337. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49338. */
  49339. engine: Nullable<Engine>;
  49340. /**
  49341. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49342. */
  49343. scene: Nullable<Scene>;
  49344. }
  49345. /**
  49346. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49347. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49348. * is automatically managed.
  49349. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49350. * in your application.
  49351. *
  49352. * As the update is not automatic, you need to call them manually.
  49353. */
  49354. export class HtmlElementTexture extends BaseTexture {
  49355. /**
  49356. * The texture URL.
  49357. */
  49358. element: HTMLVideoElement | HTMLCanvasElement;
  49359. private static readonly DefaultOptions;
  49360. private _textureMatrix;
  49361. private _engine;
  49362. private _isVideo;
  49363. private _generateMipMaps;
  49364. private _samplingMode;
  49365. /**
  49366. * Instantiates a HtmlElementTexture from the following parameters.
  49367. *
  49368. * @param name Defines the name of the texture
  49369. * @param element Defines the video or canvas the texture is filled with
  49370. * @param options Defines the other none mandatory texture creation options
  49371. */
  49372. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49373. private _createInternalTexture;
  49374. /**
  49375. * Returns the texture matrix used in most of the material.
  49376. */
  49377. getTextureMatrix(): Matrix;
  49378. /**
  49379. * Updates the content of the texture.
  49380. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49381. */
  49382. update(invertY?: Nullable<boolean>): void;
  49383. }
  49384. }
  49385. declare module BABYLON {
  49386. /**
  49387. * Helper class to push actions to a pool of workers.
  49388. */
  49389. export class WorkerPool implements IDisposable {
  49390. private _workerInfos;
  49391. private _pendingActions;
  49392. /**
  49393. * Constructor
  49394. * @param workers Array of workers to use for actions
  49395. */
  49396. constructor(workers: Array<Worker>);
  49397. /**
  49398. * Terminates all workers and clears any pending actions.
  49399. */
  49400. dispose(): void;
  49401. /**
  49402. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49403. * pended until a worker has completed its action.
  49404. * @param action The action to perform. Call onComplete when the action is complete.
  49405. */
  49406. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49407. private _execute;
  49408. }
  49409. }
  49410. declare module BABYLON {
  49411. /**
  49412. * Configuration for Draco compression
  49413. */
  49414. export interface IDracoCompressionConfiguration {
  49415. /**
  49416. * Configuration for the decoder.
  49417. */
  49418. decoder?: {
  49419. /**
  49420. * The url to the WebAssembly module.
  49421. */
  49422. wasmUrl?: string;
  49423. /**
  49424. * The url to the WebAssembly binary.
  49425. */
  49426. wasmBinaryUrl?: string;
  49427. /**
  49428. * The url to the fallback JavaScript module.
  49429. */
  49430. fallbackUrl?: string;
  49431. };
  49432. }
  49433. /**
  49434. * Draco compression (https://google.github.io/draco/)
  49435. *
  49436. * This class wraps the Draco module.
  49437. *
  49438. * **Encoder**
  49439. *
  49440. * The encoder is not currently implemented.
  49441. *
  49442. * **Decoder**
  49443. *
  49444. * 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.
  49445. *
  49446. * To update the configuration, use the following code:
  49447. * ```javascript
  49448. * DracoCompression.Configuration = {
  49449. * decoder: {
  49450. * wasmUrl: "<url to the WebAssembly library>",
  49451. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49452. * fallbackUrl: "<url to the fallback JavaScript library>",
  49453. * }
  49454. * };
  49455. * ```
  49456. *
  49457. * 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.
  49458. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49459. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49460. *
  49461. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49462. * ```javascript
  49463. * var dracoCompression = new DracoCompression();
  49464. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49465. * [VertexBuffer.PositionKind]: 0
  49466. * });
  49467. * ```
  49468. *
  49469. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49470. */
  49471. export class DracoCompression implements IDisposable {
  49472. private _workerPoolPromise;
  49473. /**
  49474. * The configuration. Defaults to the following urls:
  49475. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49476. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49477. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49478. */
  49479. static Configuration: IDracoCompressionConfiguration;
  49480. /**
  49481. * Returns true if the decoder is available.
  49482. */
  49483. static readonly DecoderAvailable: boolean;
  49484. /**
  49485. * Default number of workers to create when creating the draco compression object.
  49486. */
  49487. static DefaultNumWorkers: number;
  49488. private static GetDefaultNumWorkers;
  49489. /**
  49490. * Constructor
  49491. * @param numWorkers The number of workers for async operations
  49492. */
  49493. constructor(numWorkers?: number);
  49494. /**
  49495. * Stop all async operations and release resources.
  49496. */
  49497. dispose(): void;
  49498. /**
  49499. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49500. * @returns a promise that resolves when ready
  49501. */
  49502. whenReadyAsync(): Promise<void>;
  49503. /**
  49504. * Decode Draco compressed mesh data to vertex data.
  49505. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49506. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49507. * @returns A promise that resolves with the decoded vertex data
  49508. */
  49509. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49510. [kind: string]: number;
  49511. }): Promise<VertexData>;
  49512. /**
  49513. * The worker function that gets converted to a blob url to pass into a worker.
  49514. */
  49515. private static _Worker;
  49516. private _loadDecoderWasmBinaryAsync;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Class for building Constructive Solid Geometry
  49522. */
  49523. export class CSG {
  49524. private polygons;
  49525. /**
  49526. * The world matrix
  49527. */
  49528. matrix: Matrix;
  49529. /**
  49530. * Stores the position
  49531. */
  49532. position: Vector3;
  49533. /**
  49534. * Stores the rotation
  49535. */
  49536. rotation: Vector3;
  49537. /**
  49538. * Stores the rotation quaternion
  49539. */
  49540. rotationQuaternion: Nullable<Quaternion>;
  49541. /**
  49542. * Stores the scaling vector
  49543. */
  49544. scaling: Vector3;
  49545. /**
  49546. * Convert the Mesh to CSG
  49547. * @param mesh The Mesh to convert to CSG
  49548. * @returns A new CSG from the Mesh
  49549. */
  49550. static FromMesh(mesh: Mesh): CSG;
  49551. /**
  49552. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49553. * @param polygons Polygons used to construct a CSG solid
  49554. */
  49555. private static FromPolygons;
  49556. /**
  49557. * Clones, or makes a deep copy, of the CSG
  49558. * @returns A new CSG
  49559. */
  49560. clone(): CSG;
  49561. /**
  49562. * Unions this CSG with another CSG
  49563. * @param csg The CSG to union against this CSG
  49564. * @returns The unioned CSG
  49565. */
  49566. union(csg: CSG): CSG;
  49567. /**
  49568. * Unions this CSG with another CSG in place
  49569. * @param csg The CSG to union against this CSG
  49570. */
  49571. unionInPlace(csg: CSG): void;
  49572. /**
  49573. * Subtracts this CSG with another CSG
  49574. * @param csg The CSG to subtract against this CSG
  49575. * @returns A new CSG
  49576. */
  49577. subtract(csg: CSG): CSG;
  49578. /**
  49579. * Subtracts this CSG with another CSG in place
  49580. * @param csg The CSG to subtact against this CSG
  49581. */
  49582. subtractInPlace(csg: CSG): void;
  49583. /**
  49584. * Intersect this CSG with another CSG
  49585. * @param csg The CSG to intersect against this CSG
  49586. * @returns A new CSG
  49587. */
  49588. intersect(csg: CSG): CSG;
  49589. /**
  49590. * Intersects this CSG with another CSG in place
  49591. * @param csg The CSG to intersect against this CSG
  49592. */
  49593. intersectInPlace(csg: CSG): void;
  49594. /**
  49595. * Return a new CSG solid with solid and empty space switched. This solid is
  49596. * not modified.
  49597. * @returns A new CSG solid with solid and empty space switched
  49598. */
  49599. inverse(): CSG;
  49600. /**
  49601. * Inverses the CSG in place
  49602. */
  49603. inverseInPlace(): void;
  49604. /**
  49605. * This is used to keep meshes transformations so they can be restored
  49606. * when we build back a Babylon Mesh
  49607. * NB : All CSG operations are performed in world coordinates
  49608. * @param csg The CSG to copy the transform attributes from
  49609. * @returns This CSG
  49610. */
  49611. copyTransformAttributes(csg: CSG): CSG;
  49612. /**
  49613. * Build Raw mesh from CSG
  49614. * Coordinates here are in world space
  49615. * @param name The name of the mesh geometry
  49616. * @param scene The Scene
  49617. * @param keepSubMeshes Specifies if the submeshes should be kept
  49618. * @returns A new Mesh
  49619. */
  49620. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49621. /**
  49622. * Build Mesh from CSG taking material and transforms into account
  49623. * @param name The name of the Mesh
  49624. * @param material The material of the Mesh
  49625. * @param scene The Scene
  49626. * @param keepSubMeshes Specifies if submeshes should be kept
  49627. * @returns The new Mesh
  49628. */
  49629. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49630. }
  49631. }
  49632. declare module BABYLON {
  49633. /**
  49634. * Class used to create a trail following a mesh
  49635. */
  49636. export class TrailMesh extends Mesh {
  49637. private _generator;
  49638. private _autoStart;
  49639. private _running;
  49640. private _diameter;
  49641. private _length;
  49642. private _sectionPolygonPointsCount;
  49643. private _sectionVectors;
  49644. private _sectionNormalVectors;
  49645. private _beforeRenderObserver;
  49646. /**
  49647. * @constructor
  49648. * @param name The value used by scene.getMeshByName() to do a lookup.
  49649. * @param generator The mesh to generate a trail.
  49650. * @param scene The scene to add this mesh to.
  49651. * @param diameter Diameter of trailing mesh. Default is 1.
  49652. * @param length Length of trailing mesh. Default is 60.
  49653. * @param autoStart Automatically start trailing mesh. Default true.
  49654. */
  49655. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49656. /**
  49657. * "TrailMesh"
  49658. * @returns "TrailMesh"
  49659. */
  49660. getClassName(): string;
  49661. private _createMesh;
  49662. /**
  49663. * Start trailing mesh.
  49664. */
  49665. start(): void;
  49666. /**
  49667. * Stop trailing mesh.
  49668. */
  49669. stop(): void;
  49670. /**
  49671. * Update trailing mesh geometry.
  49672. */
  49673. update(): void;
  49674. /**
  49675. * Returns a new TrailMesh object.
  49676. * @param name is a string, the name given to the new mesh
  49677. * @param newGenerator use new generator object for cloned trail mesh
  49678. * @returns a new mesh
  49679. */
  49680. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49681. /**
  49682. * Serializes this trail mesh
  49683. * @param serializationObject object to write serialization to
  49684. */
  49685. serialize(serializationObject: any): void;
  49686. /**
  49687. * Parses a serialized trail mesh
  49688. * @param parsedMesh the serialized mesh
  49689. * @param scene the scene to create the trail mesh in
  49690. * @returns the created trail mesh
  49691. */
  49692. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49693. }
  49694. }
  49695. declare module BABYLON {
  49696. /**
  49697. * Class containing static functions to help procedurally build meshes
  49698. */
  49699. export class TorusKnotBuilder {
  49700. /**
  49701. * Creates a torus knot mesh
  49702. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49703. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49704. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49705. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49707. * * 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
  49708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49709. * @param name defines the name of the mesh
  49710. * @param options defines the options used to create the mesh
  49711. * @param scene defines the hosting scene
  49712. * @returns the torus knot mesh
  49713. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49714. */
  49715. static CreateTorusKnot(name: string, options: {
  49716. radius?: number;
  49717. tube?: number;
  49718. radialSegments?: number;
  49719. tubularSegments?: number;
  49720. p?: number;
  49721. q?: number;
  49722. updatable?: boolean;
  49723. sideOrientation?: number;
  49724. frontUVs?: Vector4;
  49725. backUVs?: Vector4;
  49726. }, scene: any): Mesh;
  49727. }
  49728. }
  49729. declare module BABYLON {
  49730. /**
  49731. * Polygon
  49732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49733. */
  49734. export class Polygon {
  49735. /**
  49736. * Creates a rectangle
  49737. * @param xmin bottom X coord
  49738. * @param ymin bottom Y coord
  49739. * @param xmax top X coord
  49740. * @param ymax top Y coord
  49741. * @returns points that make the resulting rectation
  49742. */
  49743. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49744. /**
  49745. * Creates a circle
  49746. * @param radius radius of circle
  49747. * @param cx scale in x
  49748. * @param cy scale in y
  49749. * @param numberOfSides number of sides that make up the circle
  49750. * @returns points that make the resulting circle
  49751. */
  49752. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49753. /**
  49754. * Creates a polygon from input string
  49755. * @param input Input polygon data
  49756. * @returns the parsed points
  49757. */
  49758. static Parse(input: string): Vector2[];
  49759. /**
  49760. * Starts building a polygon from x and y coordinates
  49761. * @param x x coordinate
  49762. * @param y y coordinate
  49763. * @returns the started path2
  49764. */
  49765. static StartingAt(x: number, y: number): Path2;
  49766. }
  49767. /**
  49768. * Builds a polygon
  49769. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49770. */
  49771. export class PolygonMeshBuilder {
  49772. private _points;
  49773. private _outlinepoints;
  49774. private _holes;
  49775. private _name;
  49776. private _scene;
  49777. private _epoints;
  49778. private _eholes;
  49779. private _addToepoint;
  49780. /**
  49781. * Babylon reference to the earcut plugin.
  49782. */
  49783. bjsEarcut: any;
  49784. /**
  49785. * Creates a PolygonMeshBuilder
  49786. * @param name name of the builder
  49787. * @param contours Path of the polygon
  49788. * @param scene scene to add to when creating the mesh
  49789. * @param earcutInjection can be used to inject your own earcut reference
  49790. */
  49791. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49792. /**
  49793. * Adds a whole within the polygon
  49794. * @param hole Array of points defining the hole
  49795. * @returns this
  49796. */
  49797. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49798. /**
  49799. * Creates the polygon
  49800. * @param updatable If the mesh should be updatable
  49801. * @param depth The depth of the mesh created
  49802. * @returns the created mesh
  49803. */
  49804. build(updatable?: boolean, depth?: number): Mesh;
  49805. /**
  49806. * Creates the polygon
  49807. * @param depth The depth of the mesh created
  49808. * @returns the created VertexData
  49809. */
  49810. buildVertexData(depth?: number): VertexData;
  49811. /**
  49812. * Adds a side to the polygon
  49813. * @param positions points that make the polygon
  49814. * @param normals normals of the polygon
  49815. * @param uvs uvs of the polygon
  49816. * @param indices indices of the polygon
  49817. * @param bounds bounds of the polygon
  49818. * @param points points of the polygon
  49819. * @param depth depth of the polygon
  49820. * @param flip flip of the polygon
  49821. */
  49822. private addSide;
  49823. }
  49824. }
  49825. declare module BABYLON {
  49826. /**
  49827. * Class containing static functions to help procedurally build meshes
  49828. */
  49829. export class PolygonBuilder {
  49830. /**
  49831. * Creates a polygon mesh
  49832. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49833. * * 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
  49834. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49836. * * 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)
  49837. * * Remember you can only change the shape positions, not their number when updating a polygon
  49838. * @param name defines the name of the mesh
  49839. * @param options defines the options used to create the mesh
  49840. * @param scene defines the hosting scene
  49841. * @param earcutInjection can be used to inject your own earcut reference
  49842. * @returns the polygon mesh
  49843. */
  49844. static CreatePolygon(name: string, options: {
  49845. shape: Vector3[];
  49846. holes?: Vector3[][];
  49847. depth?: number;
  49848. faceUV?: Vector4[];
  49849. faceColors?: Color4[];
  49850. updatable?: boolean;
  49851. sideOrientation?: number;
  49852. frontUVs?: Vector4;
  49853. backUVs?: Vector4;
  49854. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49855. /**
  49856. * Creates an extruded polygon mesh, with depth in the Y direction.
  49857. * * 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)
  49858. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49859. * @param name defines the name of the mesh
  49860. * @param options defines the options used to create the mesh
  49861. * @param scene defines the hosting scene
  49862. * @param earcutInjection can be used to inject your own earcut reference
  49863. * @returns the polygon mesh
  49864. */
  49865. static ExtrudePolygon(name: string, options: {
  49866. shape: Vector3[];
  49867. holes?: Vector3[][];
  49868. depth?: number;
  49869. faceUV?: Vector4[];
  49870. faceColors?: Color4[];
  49871. updatable?: boolean;
  49872. sideOrientation?: number;
  49873. frontUVs?: Vector4;
  49874. backUVs?: Vector4;
  49875. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49876. }
  49877. }
  49878. declare module BABYLON {
  49879. /**
  49880. * Class containing static functions to help procedurally build meshes
  49881. */
  49882. export class LatheBuilder {
  49883. /**
  49884. * Creates lathe mesh.
  49885. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49886. * * 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
  49887. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49888. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49889. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49890. * * 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
  49891. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49892. * * 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
  49893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49894. * * 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
  49895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49897. * @param name defines the name of the mesh
  49898. * @param options defines the options used to create the mesh
  49899. * @param scene defines the hosting scene
  49900. * @returns the lathe mesh
  49901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49902. */
  49903. static CreateLathe(name: string, options: {
  49904. shape: Vector3[];
  49905. radius?: number;
  49906. tessellation?: number;
  49907. clip?: number;
  49908. arc?: number;
  49909. closed?: boolean;
  49910. updatable?: boolean;
  49911. sideOrientation?: number;
  49912. frontUVs?: Vector4;
  49913. backUVs?: Vector4;
  49914. cap?: number;
  49915. invertUV?: boolean;
  49916. }, scene?: Nullable<Scene>): Mesh;
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. /**
  49921. * Class containing static functions to help procedurally build meshes
  49922. */
  49923. export class TubeBuilder {
  49924. /**
  49925. * Creates a tube mesh.
  49926. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49927. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49928. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49929. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49930. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49931. * * 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)
  49932. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49933. * * 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
  49934. * * 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
  49935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49936. * * 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
  49937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49939. * @param name defines the name of the mesh
  49940. * @param options defines the options used to create the mesh
  49941. * @param scene defines the hosting scene
  49942. * @returns the tube mesh
  49943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49944. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49945. */
  49946. static CreateTube(name: string, options: {
  49947. path: Vector3[];
  49948. radius?: number;
  49949. tessellation?: number;
  49950. radiusFunction?: {
  49951. (i: number, distance: number): number;
  49952. };
  49953. cap?: number;
  49954. arc?: number;
  49955. updatable?: boolean;
  49956. sideOrientation?: number;
  49957. frontUVs?: Vector4;
  49958. backUVs?: Vector4;
  49959. instance?: Mesh;
  49960. invertUV?: boolean;
  49961. }, scene?: Nullable<Scene>): Mesh;
  49962. }
  49963. }
  49964. declare module BABYLON {
  49965. /**
  49966. * Class containing static functions to help procedurally build meshes
  49967. */
  49968. export class IcoSphereBuilder {
  49969. /**
  49970. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49971. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49972. * * 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`)
  49973. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49974. * * 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
  49975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49976. * * 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
  49977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49978. * @param name defines the name of the mesh
  49979. * @param options defines the options used to create the mesh
  49980. * @param scene defines the hosting scene
  49981. * @returns the icosahedron mesh
  49982. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49983. */
  49984. static CreateIcoSphere(name: string, options: {
  49985. radius?: number;
  49986. radiusX?: number;
  49987. radiusY?: number;
  49988. radiusZ?: number;
  49989. flat?: boolean;
  49990. subdivisions?: number;
  49991. sideOrientation?: number;
  49992. frontUVs?: Vector4;
  49993. backUVs?: Vector4;
  49994. updatable?: boolean;
  49995. }, scene?: Nullable<Scene>): Mesh;
  49996. }
  49997. }
  49998. declare module BABYLON {
  49999. /**
  50000. * Class containing static functions to help procedurally build meshes
  50001. */
  50002. export class DecalBuilder {
  50003. /**
  50004. * Creates a decal mesh.
  50005. * 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
  50006. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50007. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50008. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50009. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50010. * @param name defines the name of the mesh
  50011. * @param sourceMesh defines the mesh where the decal must be applied
  50012. * @param options defines the options used to create the mesh
  50013. * @param scene defines the hosting scene
  50014. * @returns the decal mesh
  50015. * @see https://doc.babylonjs.com/how_to/decals
  50016. */
  50017. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50018. position?: Vector3;
  50019. normal?: Vector3;
  50020. size?: Vector3;
  50021. angle?: number;
  50022. }): Mesh;
  50023. }
  50024. }
  50025. declare module BABYLON {
  50026. /**
  50027. * Class containing static functions to help procedurally build meshes
  50028. */
  50029. export class MeshBuilder {
  50030. /**
  50031. * Creates a box mesh
  50032. * * The parameter `size` sets the size (float) of each box side (default 1)
  50033. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50034. * * 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)
  50035. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50037. * * 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
  50038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50039. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50040. * @param name defines the name of the mesh
  50041. * @param options defines the options used to create the mesh
  50042. * @param scene defines the hosting scene
  50043. * @returns the box mesh
  50044. */
  50045. static CreateBox(name: string, options: {
  50046. size?: number;
  50047. width?: number;
  50048. height?: number;
  50049. depth?: number;
  50050. faceUV?: Vector4[];
  50051. faceColors?: Color4[];
  50052. sideOrientation?: number;
  50053. frontUVs?: Vector4;
  50054. backUVs?: Vector4;
  50055. updatable?: boolean;
  50056. }, scene?: Nullable<Scene>): Mesh;
  50057. /**
  50058. * Creates a sphere mesh
  50059. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50060. * * 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`)
  50061. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50062. * * 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
  50063. * * 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)
  50064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50065. * * 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
  50066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50067. * @param name defines the name of the mesh
  50068. * @param options defines the options used to create the mesh
  50069. * @param scene defines the hosting scene
  50070. * @returns the sphere mesh
  50071. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50072. */
  50073. static CreateSphere(name: string, options: {
  50074. segments?: number;
  50075. diameter?: number;
  50076. diameterX?: number;
  50077. diameterY?: number;
  50078. diameterZ?: number;
  50079. arc?: number;
  50080. slice?: number;
  50081. sideOrientation?: number;
  50082. frontUVs?: Vector4;
  50083. backUVs?: Vector4;
  50084. updatable?: boolean;
  50085. }, scene?: Nullable<Scene>): Mesh;
  50086. /**
  50087. * Creates a plane polygonal mesh. By default, this is a disc
  50088. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50089. * * 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
  50090. * * 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
  50091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50092. * * 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
  50093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50094. * @param name defines the name of the mesh
  50095. * @param options defines the options used to create the mesh
  50096. * @param scene defines the hosting scene
  50097. * @returns the plane polygonal mesh
  50098. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50099. */
  50100. static CreateDisc(name: string, options: {
  50101. radius?: number;
  50102. tessellation?: number;
  50103. arc?: number;
  50104. updatable?: boolean;
  50105. sideOrientation?: number;
  50106. frontUVs?: Vector4;
  50107. backUVs?: Vector4;
  50108. }, scene?: Nullable<Scene>): Mesh;
  50109. /**
  50110. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50111. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50112. * * 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`)
  50113. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50114. * * 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
  50115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50116. * * 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
  50117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50118. * @param name defines the name of the mesh
  50119. * @param options defines the options used to create the mesh
  50120. * @param scene defines the hosting scene
  50121. * @returns the icosahedron mesh
  50122. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50123. */
  50124. static CreateIcoSphere(name: string, options: {
  50125. radius?: number;
  50126. radiusX?: number;
  50127. radiusY?: number;
  50128. radiusZ?: number;
  50129. flat?: boolean;
  50130. subdivisions?: number;
  50131. sideOrientation?: number;
  50132. frontUVs?: Vector4;
  50133. backUVs?: Vector4;
  50134. updatable?: boolean;
  50135. }, scene?: Nullable<Scene>): Mesh;
  50136. /**
  50137. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50138. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50139. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50140. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50141. * * 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
  50142. * * 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
  50143. * * 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
  50144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50145. * * 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
  50146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50147. * * 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
  50148. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50149. * * 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
  50150. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50152. * @param name defines the name of the mesh
  50153. * @param options defines the options used to create the mesh
  50154. * @param scene defines the hosting scene
  50155. * @returns the ribbon mesh
  50156. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50158. */
  50159. static CreateRibbon(name: string, options: {
  50160. pathArray: Vector3[][];
  50161. closeArray?: boolean;
  50162. closePath?: boolean;
  50163. offset?: number;
  50164. updatable?: boolean;
  50165. sideOrientation?: number;
  50166. frontUVs?: Vector4;
  50167. backUVs?: Vector4;
  50168. instance?: Mesh;
  50169. invertUV?: boolean;
  50170. uvs?: Vector2[];
  50171. colors?: Color4[];
  50172. }, scene?: Nullable<Scene>): Mesh;
  50173. /**
  50174. * Creates a cylinder or a cone mesh
  50175. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50176. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50177. * * 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.
  50178. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50179. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50180. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50181. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50182. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50183. * * 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).
  50184. * * 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
  50185. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50186. * * 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
  50187. * * 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.
  50188. * * If `enclose` is false, a ring surface is one element.
  50189. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50190. * * 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
  50191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50192. * * 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
  50193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50194. * @param name defines the name of the mesh
  50195. * @param options defines the options used to create the mesh
  50196. * @param scene defines the hosting scene
  50197. * @returns the cylinder mesh
  50198. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50199. */
  50200. static CreateCylinder(name: string, options: {
  50201. height?: number;
  50202. diameterTop?: number;
  50203. diameterBottom?: number;
  50204. diameter?: number;
  50205. tessellation?: number;
  50206. subdivisions?: number;
  50207. arc?: number;
  50208. faceColors?: Color4[];
  50209. faceUV?: Vector4[];
  50210. updatable?: boolean;
  50211. hasRings?: boolean;
  50212. enclose?: boolean;
  50213. sideOrientation?: number;
  50214. frontUVs?: Vector4;
  50215. backUVs?: Vector4;
  50216. }, scene?: Nullable<Scene>): Mesh;
  50217. /**
  50218. * Creates a torus mesh
  50219. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50220. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50221. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50223. * * 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
  50224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50225. * @param name defines the name of the mesh
  50226. * @param options defines the options used to create the mesh
  50227. * @param scene defines the hosting scene
  50228. * @returns the torus mesh
  50229. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50230. */
  50231. static CreateTorus(name: string, options: {
  50232. diameter?: number;
  50233. thickness?: number;
  50234. tessellation?: number;
  50235. updatable?: boolean;
  50236. sideOrientation?: number;
  50237. frontUVs?: Vector4;
  50238. backUVs?: Vector4;
  50239. }, scene?: Nullable<Scene>): Mesh;
  50240. /**
  50241. * Creates a torus knot mesh
  50242. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50243. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50244. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50245. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50247. * * 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
  50248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50249. * @param name defines the name of the mesh
  50250. * @param options defines the options used to create the mesh
  50251. * @param scene defines the hosting scene
  50252. * @returns the torus knot mesh
  50253. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50254. */
  50255. static CreateTorusKnot(name: string, options: {
  50256. radius?: number;
  50257. tube?: number;
  50258. radialSegments?: number;
  50259. tubularSegments?: number;
  50260. p?: number;
  50261. q?: number;
  50262. updatable?: boolean;
  50263. sideOrientation?: number;
  50264. frontUVs?: Vector4;
  50265. backUVs?: Vector4;
  50266. }, scene?: Nullable<Scene>): Mesh;
  50267. /**
  50268. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50269. * * 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
  50270. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50271. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50272. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50273. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50274. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50275. * * 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
  50276. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50279. * @param name defines the name of the new line system
  50280. * @param options defines the options used to create the line system
  50281. * @param scene defines the hosting scene
  50282. * @returns a new line system mesh
  50283. */
  50284. static CreateLineSystem(name: string, options: {
  50285. lines: Vector3[][];
  50286. updatable?: boolean;
  50287. instance?: Nullable<LinesMesh>;
  50288. colors?: Nullable<Color4[][]>;
  50289. useVertexAlpha?: boolean;
  50290. }, scene: Nullable<Scene>): LinesMesh;
  50291. /**
  50292. * Creates a line mesh
  50293. * 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
  50294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50295. * * The parameter `points` is an array successive Vector3
  50296. * * 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
  50297. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50299. * * When updating an instance, remember that only point positions can change, not the number of points
  50300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50302. * @param name defines the name of the new line system
  50303. * @param options defines the options used to create the line system
  50304. * @param scene defines the hosting scene
  50305. * @returns a new line mesh
  50306. */
  50307. static CreateLines(name: string, options: {
  50308. points: Vector3[];
  50309. updatable?: boolean;
  50310. instance?: Nullable<LinesMesh>;
  50311. colors?: Color4[];
  50312. useVertexAlpha?: boolean;
  50313. }, scene?: Nullable<Scene>): LinesMesh;
  50314. /**
  50315. * Creates a dashed line mesh
  50316. * * 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
  50317. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50318. * * The parameter `points` is an array successive Vector3
  50319. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50320. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50321. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50322. * * 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
  50323. * * When updating an instance, remember that only point positions can change, not the number of points
  50324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50325. * @param name defines the name of the mesh
  50326. * @param options defines the options used to create the mesh
  50327. * @param scene defines the hosting scene
  50328. * @returns the dashed line mesh
  50329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50330. */
  50331. static CreateDashedLines(name: string, options: {
  50332. points: Vector3[];
  50333. dashSize?: number;
  50334. gapSize?: number;
  50335. dashNb?: number;
  50336. updatable?: boolean;
  50337. instance?: LinesMesh;
  50338. }, scene?: Nullable<Scene>): LinesMesh;
  50339. /**
  50340. * 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.
  50341. * * 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.
  50342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50343. * * 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.
  50344. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50345. * * 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
  50346. * * 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
  50347. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50352. * @param name defines the name of the mesh
  50353. * @param options defines the options used to create the mesh
  50354. * @param scene defines the hosting scene
  50355. * @returns the extruded shape mesh
  50356. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50358. */
  50359. static ExtrudeShape(name: string, options: {
  50360. shape: Vector3[];
  50361. path: Vector3[];
  50362. scale?: number;
  50363. rotation?: number;
  50364. cap?: number;
  50365. updatable?: boolean;
  50366. sideOrientation?: number;
  50367. frontUVs?: Vector4;
  50368. backUVs?: Vector4;
  50369. instance?: Mesh;
  50370. invertUV?: boolean;
  50371. }, scene?: Nullable<Scene>): Mesh;
  50372. /**
  50373. * Creates an custom extruded shape mesh.
  50374. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50375. * * 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.
  50376. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50377. * * 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
  50378. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50379. * * 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
  50380. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50381. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50382. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50383. * * 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
  50384. * * 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
  50385. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50387. * * 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
  50388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50390. * @param name defines the name of the mesh
  50391. * @param options defines the options used to create the mesh
  50392. * @param scene defines the hosting scene
  50393. * @returns the custom extruded shape mesh
  50394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50397. */
  50398. static ExtrudeShapeCustom(name: string, options: {
  50399. shape: Vector3[];
  50400. path: Vector3[];
  50401. scaleFunction?: any;
  50402. rotationFunction?: any;
  50403. ribbonCloseArray?: boolean;
  50404. ribbonClosePath?: boolean;
  50405. cap?: number;
  50406. updatable?: boolean;
  50407. sideOrientation?: number;
  50408. frontUVs?: Vector4;
  50409. backUVs?: Vector4;
  50410. instance?: Mesh;
  50411. invertUV?: boolean;
  50412. }, scene?: Nullable<Scene>): Mesh;
  50413. /**
  50414. * Creates lathe mesh.
  50415. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50416. * * 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
  50417. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50418. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50419. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50420. * * 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
  50421. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50422. * * 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
  50423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50424. * * 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
  50425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50427. * @param name defines the name of the mesh
  50428. * @param options defines the options used to create the mesh
  50429. * @param scene defines the hosting scene
  50430. * @returns the lathe mesh
  50431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50432. */
  50433. static CreateLathe(name: string, options: {
  50434. shape: Vector3[];
  50435. radius?: number;
  50436. tessellation?: number;
  50437. clip?: number;
  50438. arc?: number;
  50439. closed?: boolean;
  50440. updatable?: boolean;
  50441. sideOrientation?: number;
  50442. frontUVs?: Vector4;
  50443. backUVs?: Vector4;
  50444. cap?: number;
  50445. invertUV?: boolean;
  50446. }, scene?: Nullable<Scene>): Mesh;
  50447. /**
  50448. * Creates a plane mesh
  50449. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50450. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50451. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50453. * * 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
  50454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50455. * @param name defines the name of the mesh
  50456. * @param options defines the options used to create the mesh
  50457. * @param scene defines the hosting scene
  50458. * @returns the plane mesh
  50459. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50460. */
  50461. static CreatePlane(name: string, options: {
  50462. size?: number;
  50463. width?: number;
  50464. height?: number;
  50465. sideOrientation?: number;
  50466. frontUVs?: Vector4;
  50467. backUVs?: Vector4;
  50468. updatable?: boolean;
  50469. sourcePlane?: Plane;
  50470. }, scene?: Nullable<Scene>): Mesh;
  50471. /**
  50472. * Creates a ground mesh
  50473. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50474. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50476. * @param name defines the name of the mesh
  50477. * @param options defines the options used to create the mesh
  50478. * @param scene defines the hosting scene
  50479. * @returns the ground mesh
  50480. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50481. */
  50482. static CreateGround(name: string, options: {
  50483. width?: number;
  50484. height?: number;
  50485. subdivisions?: number;
  50486. subdivisionsX?: number;
  50487. subdivisionsY?: number;
  50488. updatable?: boolean;
  50489. }, scene?: Nullable<Scene>): Mesh;
  50490. /**
  50491. * Creates a tiled ground mesh
  50492. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50493. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50494. * * 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
  50495. * * 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
  50496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50497. * @param name defines the name of the mesh
  50498. * @param options defines the options used to create the mesh
  50499. * @param scene defines the hosting scene
  50500. * @returns the tiled ground mesh
  50501. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50502. */
  50503. static CreateTiledGround(name: string, options: {
  50504. xmin: number;
  50505. zmin: number;
  50506. xmax: number;
  50507. zmax: number;
  50508. subdivisions?: {
  50509. w: number;
  50510. h: number;
  50511. };
  50512. precision?: {
  50513. w: number;
  50514. h: number;
  50515. };
  50516. updatable?: boolean;
  50517. }, scene?: Nullable<Scene>): Mesh;
  50518. /**
  50519. * Creates a ground mesh from a height map
  50520. * * The parameter `url` sets the URL of the height map image resource.
  50521. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50522. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50523. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50524. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50525. * * 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.
  50526. * * 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).
  50527. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50529. * @param name defines the name of the mesh
  50530. * @param url defines the url to the height map
  50531. * @param options defines the options used to create the mesh
  50532. * @param scene defines the hosting scene
  50533. * @returns the ground mesh
  50534. * @see https://doc.babylonjs.com/babylon101/height_map
  50535. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50536. */
  50537. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50538. width?: number;
  50539. height?: number;
  50540. subdivisions?: number;
  50541. minHeight?: number;
  50542. maxHeight?: number;
  50543. colorFilter?: Color3;
  50544. alphaFilter?: number;
  50545. updatable?: boolean;
  50546. onReady?: (mesh: GroundMesh) => void;
  50547. }, scene?: Nullable<Scene>): GroundMesh;
  50548. /**
  50549. * Creates a polygon mesh
  50550. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50551. * * 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
  50552. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50554. * * 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)
  50555. * * Remember you can only change the shape positions, not their number when updating a polygon
  50556. * @param name defines the name of the mesh
  50557. * @param options defines the options used to create the mesh
  50558. * @param scene defines the hosting scene
  50559. * @param earcutInjection can be used to inject your own earcut reference
  50560. * @returns the polygon mesh
  50561. */
  50562. static CreatePolygon(name: string, options: {
  50563. shape: Vector3[];
  50564. holes?: Vector3[][];
  50565. depth?: number;
  50566. faceUV?: Vector4[];
  50567. faceColors?: Color4[];
  50568. updatable?: boolean;
  50569. sideOrientation?: number;
  50570. frontUVs?: Vector4;
  50571. backUVs?: Vector4;
  50572. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50573. /**
  50574. * Creates an extruded polygon mesh, with depth in the Y direction.
  50575. * * 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)
  50576. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50577. * @param name defines the name of the mesh
  50578. * @param options defines the options used to create the mesh
  50579. * @param scene defines the hosting scene
  50580. * @param earcutInjection can be used to inject your own earcut reference
  50581. * @returns the polygon mesh
  50582. */
  50583. static ExtrudePolygon(name: string, options: {
  50584. shape: Vector3[];
  50585. holes?: Vector3[][];
  50586. depth?: number;
  50587. faceUV?: Vector4[];
  50588. faceColors?: Color4[];
  50589. updatable?: boolean;
  50590. sideOrientation?: number;
  50591. frontUVs?: Vector4;
  50592. backUVs?: Vector4;
  50593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50594. /**
  50595. * Creates a tube mesh.
  50596. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50597. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50598. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50599. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50600. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50601. * * 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)
  50602. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50603. * * 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
  50604. * * 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
  50605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50606. * * 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
  50607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50609. * @param name defines the name of the mesh
  50610. * @param options defines the options used to create the mesh
  50611. * @param scene defines the hosting scene
  50612. * @returns the tube mesh
  50613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50614. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50615. */
  50616. static CreateTube(name: string, options: {
  50617. path: Vector3[];
  50618. radius?: number;
  50619. tessellation?: number;
  50620. radiusFunction?: {
  50621. (i: number, distance: number): number;
  50622. };
  50623. cap?: number;
  50624. arc?: number;
  50625. updatable?: boolean;
  50626. sideOrientation?: number;
  50627. frontUVs?: Vector4;
  50628. backUVs?: Vector4;
  50629. instance?: Mesh;
  50630. invertUV?: boolean;
  50631. }, scene?: Nullable<Scene>): Mesh;
  50632. /**
  50633. * Creates a polyhedron mesh
  50634. * * 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
  50635. * * The parameter `size` (positive float, default 1) sets the polygon size
  50636. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50637. * * 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`
  50638. * * 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
  50639. * * 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)`)
  50640. * * 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
  50641. * * 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
  50642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50643. * * 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
  50644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50645. * @param name defines the name of the mesh
  50646. * @param options defines the options used to create the mesh
  50647. * @param scene defines the hosting scene
  50648. * @returns the polyhedron mesh
  50649. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50650. */
  50651. static CreatePolyhedron(name: string, options: {
  50652. type?: number;
  50653. size?: number;
  50654. sizeX?: number;
  50655. sizeY?: number;
  50656. sizeZ?: number;
  50657. custom?: any;
  50658. faceUV?: Vector4[];
  50659. faceColors?: Color4[];
  50660. flat?: boolean;
  50661. updatable?: boolean;
  50662. sideOrientation?: number;
  50663. frontUVs?: Vector4;
  50664. backUVs?: Vector4;
  50665. }, scene?: Nullable<Scene>): Mesh;
  50666. /**
  50667. * Creates a decal mesh.
  50668. * 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
  50669. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50670. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50671. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50672. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50673. * @param name defines the name of the mesh
  50674. * @param sourceMesh defines the mesh where the decal must be applied
  50675. * @param options defines the options used to create the mesh
  50676. * @param scene defines the hosting scene
  50677. * @returns the decal mesh
  50678. * @see https://doc.babylonjs.com/how_to/decals
  50679. */
  50680. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50681. position?: Vector3;
  50682. normal?: Vector3;
  50683. size?: Vector3;
  50684. angle?: number;
  50685. }): Mesh;
  50686. }
  50687. }
  50688. declare module BABYLON {
  50689. /**
  50690. * A simplifier interface for future simplification implementations
  50691. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50692. */
  50693. export interface ISimplifier {
  50694. /**
  50695. * Simplification of a given mesh according to the given settings.
  50696. * Since this requires computation, it is assumed that the function runs async.
  50697. * @param settings The settings of the simplification, including quality and distance
  50698. * @param successCallback A callback that will be called after the mesh was simplified.
  50699. * @param errorCallback in case of an error, this callback will be called. optional.
  50700. */
  50701. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50702. }
  50703. /**
  50704. * Expected simplification settings.
  50705. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50706. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50707. */
  50708. export interface ISimplificationSettings {
  50709. /**
  50710. * Gets or sets the expected quality
  50711. */
  50712. quality: number;
  50713. /**
  50714. * Gets or sets the distance when this optimized version should be used
  50715. */
  50716. distance: number;
  50717. /**
  50718. * Gets an already optimized mesh
  50719. */
  50720. optimizeMesh?: boolean;
  50721. }
  50722. /**
  50723. * Class used to specify simplification options
  50724. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50725. */
  50726. export class SimplificationSettings implements ISimplificationSettings {
  50727. /** expected quality */
  50728. quality: number;
  50729. /** distance when this optimized version should be used */
  50730. distance: number;
  50731. /** already optimized mesh */
  50732. optimizeMesh?: boolean | undefined;
  50733. /**
  50734. * Creates a SimplificationSettings
  50735. * @param quality expected quality
  50736. * @param distance distance when this optimized version should be used
  50737. * @param optimizeMesh already optimized mesh
  50738. */
  50739. constructor(
  50740. /** expected quality */
  50741. quality: number,
  50742. /** distance when this optimized version should be used */
  50743. distance: number,
  50744. /** already optimized mesh */
  50745. optimizeMesh?: boolean | undefined);
  50746. }
  50747. /**
  50748. * Interface used to define a simplification task
  50749. */
  50750. export interface ISimplificationTask {
  50751. /**
  50752. * Array of settings
  50753. */
  50754. settings: Array<ISimplificationSettings>;
  50755. /**
  50756. * Simplification type
  50757. */
  50758. simplificationType: SimplificationType;
  50759. /**
  50760. * Mesh to simplify
  50761. */
  50762. mesh: Mesh;
  50763. /**
  50764. * Callback called on success
  50765. */
  50766. successCallback?: () => void;
  50767. /**
  50768. * Defines if parallel processing can be used
  50769. */
  50770. parallelProcessing: boolean;
  50771. }
  50772. /**
  50773. * Queue used to order the simplification tasks
  50774. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50775. */
  50776. export class SimplificationQueue {
  50777. private _simplificationArray;
  50778. /**
  50779. * Gets a boolean indicating that the process is still running
  50780. */
  50781. running: boolean;
  50782. /**
  50783. * Creates a new queue
  50784. */
  50785. constructor();
  50786. /**
  50787. * Adds a new simplification task
  50788. * @param task defines a task to add
  50789. */
  50790. addTask(task: ISimplificationTask): void;
  50791. /**
  50792. * Execute next task
  50793. */
  50794. executeNext(): void;
  50795. /**
  50796. * Execute a simplification task
  50797. * @param task defines the task to run
  50798. */
  50799. runSimplification(task: ISimplificationTask): void;
  50800. private getSimplifier;
  50801. }
  50802. /**
  50803. * The implemented types of simplification
  50804. * At the moment only Quadratic Error Decimation is implemented
  50805. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50806. */
  50807. export enum SimplificationType {
  50808. /** Quadratic error decimation */
  50809. QUADRATIC = 0
  50810. }
  50811. }
  50812. declare module BABYLON {
  50813. interface Scene {
  50814. /** @hidden (Backing field) */
  50815. _simplificationQueue: SimplificationQueue;
  50816. /**
  50817. * Gets or sets the simplification queue attached to the scene
  50818. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50819. */
  50820. simplificationQueue: SimplificationQueue;
  50821. }
  50822. interface Mesh {
  50823. /**
  50824. * Simplify the mesh according to the given array of settings.
  50825. * Function will return immediately and will simplify async
  50826. * @param settings a collection of simplification settings
  50827. * @param parallelProcessing should all levels calculate parallel or one after the other
  50828. * @param simplificationType the type of simplification to run
  50829. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50830. * @returns the current mesh
  50831. */
  50832. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50833. }
  50834. /**
  50835. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50836. * created in a scene
  50837. */
  50838. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50839. /**
  50840. * The component name helpfull to identify the component in the list of scene components.
  50841. */
  50842. readonly name: string;
  50843. /**
  50844. * The scene the component belongs to.
  50845. */
  50846. scene: Scene;
  50847. /**
  50848. * Creates a new instance of the component for the given scene
  50849. * @param scene Defines the scene to register the component in
  50850. */
  50851. constructor(scene: Scene);
  50852. /**
  50853. * Registers the component in a given scene
  50854. */
  50855. register(): void;
  50856. /**
  50857. * Rebuilds the elements related to this component in case of
  50858. * context lost for instance.
  50859. */
  50860. rebuild(): void;
  50861. /**
  50862. * Disposes the component and the associated ressources
  50863. */
  50864. dispose(): void;
  50865. private _beforeCameraUpdate;
  50866. }
  50867. }
  50868. declare module BABYLON {
  50869. /**
  50870. * Class used to enable access to IndexedDB
  50871. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50872. */
  50873. export class Database implements IOfflineProvider {
  50874. private _callbackManifestChecked;
  50875. private _currentSceneUrl;
  50876. private _db;
  50877. private _enableSceneOffline;
  50878. private _enableTexturesOffline;
  50879. private _manifestVersionFound;
  50880. private _mustUpdateRessources;
  50881. private _hasReachedQuota;
  50882. private _isSupported;
  50883. private _idbFactory;
  50884. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50885. private static IsUASupportingBlobStorage;
  50886. /**
  50887. * Gets a boolean indicating if Database storate is enabled (off by default)
  50888. */
  50889. static IDBStorageEnabled: boolean;
  50890. /**
  50891. * Gets a boolean indicating if scene must be saved in the database
  50892. */
  50893. readonly enableSceneOffline: boolean;
  50894. /**
  50895. * Gets a boolean indicating if textures must be saved in the database
  50896. */
  50897. readonly enableTexturesOffline: boolean;
  50898. /**
  50899. * Creates a new Database
  50900. * @param urlToScene defines the url to load the scene
  50901. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50902. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50903. */
  50904. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50905. private static _ParseURL;
  50906. private static _ReturnFullUrlLocation;
  50907. private _checkManifestFile;
  50908. /**
  50909. * Open the database and make it available
  50910. * @param successCallback defines the callback to call on success
  50911. * @param errorCallback defines the callback to call on error
  50912. */
  50913. open(successCallback: () => void, errorCallback: () => void): void;
  50914. /**
  50915. * Loads an image from the database
  50916. * @param url defines the url to load from
  50917. * @param image defines the target DOM image
  50918. */
  50919. loadImage(url: string, image: HTMLImageElement): void;
  50920. private _loadImageFromDBAsync;
  50921. private _saveImageIntoDBAsync;
  50922. private _checkVersionFromDB;
  50923. private _loadVersionFromDBAsync;
  50924. private _saveVersionIntoDBAsync;
  50925. /**
  50926. * Loads a file from database
  50927. * @param url defines the URL to load from
  50928. * @param sceneLoaded defines a callback to call on success
  50929. * @param progressCallBack defines a callback to call when progress changed
  50930. * @param errorCallback defines a callback to call on error
  50931. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50932. */
  50933. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50934. private _loadFileAsync;
  50935. private _saveFileAsync;
  50936. /**
  50937. * Validates if xhr data is correct
  50938. * @param xhr defines the request to validate
  50939. * @param dataType defines the expected data type
  50940. * @returns true if data is correct
  50941. */
  50942. private static _ValidateXHRData;
  50943. }
  50944. }
  50945. declare module BABYLON {
  50946. /** @hidden */
  50947. export var gpuUpdateParticlesPixelShader: {
  50948. name: string;
  50949. shader: string;
  50950. };
  50951. }
  50952. declare module BABYLON {
  50953. /** @hidden */
  50954. export var gpuUpdateParticlesVertexShader: {
  50955. name: string;
  50956. shader: string;
  50957. };
  50958. }
  50959. declare module BABYLON {
  50960. /** @hidden */
  50961. export var clipPlaneFragmentDeclaration2: {
  50962. name: string;
  50963. shader: string;
  50964. };
  50965. }
  50966. declare module BABYLON {
  50967. /** @hidden */
  50968. export var gpuRenderParticlesPixelShader: {
  50969. name: string;
  50970. shader: string;
  50971. };
  50972. }
  50973. declare module BABYLON {
  50974. /** @hidden */
  50975. export var clipPlaneVertexDeclaration2: {
  50976. name: string;
  50977. shader: string;
  50978. };
  50979. }
  50980. declare module BABYLON {
  50981. /** @hidden */
  50982. export var gpuRenderParticlesVertexShader: {
  50983. name: string;
  50984. shader: string;
  50985. };
  50986. }
  50987. declare module BABYLON {
  50988. /**
  50989. * This represents a GPU particle system in Babylon
  50990. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50991. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50992. */
  50993. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50994. /**
  50995. * The layer mask we are rendering the particles through.
  50996. */
  50997. layerMask: number;
  50998. private _capacity;
  50999. private _activeCount;
  51000. private _currentActiveCount;
  51001. private _accumulatedCount;
  51002. private _renderEffect;
  51003. private _updateEffect;
  51004. private _buffer0;
  51005. private _buffer1;
  51006. private _spriteBuffer;
  51007. private _updateVAO;
  51008. private _renderVAO;
  51009. private _targetIndex;
  51010. private _sourceBuffer;
  51011. private _targetBuffer;
  51012. private _engine;
  51013. private _currentRenderId;
  51014. private _started;
  51015. private _stopped;
  51016. private _timeDelta;
  51017. private _randomTexture;
  51018. private _randomTexture2;
  51019. private _attributesStrideSize;
  51020. private _updateEffectOptions;
  51021. private _randomTextureSize;
  51022. private _actualFrame;
  51023. private readonly _rawTextureWidth;
  51024. /**
  51025. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51026. */
  51027. static readonly IsSupported: boolean;
  51028. /**
  51029. * An event triggered when the system is disposed.
  51030. */
  51031. onDisposeObservable: Observable<GPUParticleSystem>;
  51032. /**
  51033. * Gets the maximum number of particles active at the same time.
  51034. * @returns The max number of active particles.
  51035. */
  51036. getCapacity(): number;
  51037. /**
  51038. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51039. * to override the particles.
  51040. */
  51041. forceDepthWrite: boolean;
  51042. /**
  51043. * Gets or set the number of active particles
  51044. */
  51045. activeParticleCount: number;
  51046. private _preWarmDone;
  51047. /**
  51048. * Is this system ready to be used/rendered
  51049. * @return true if the system is ready
  51050. */
  51051. isReady(): boolean;
  51052. /**
  51053. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51054. * @returns True if it has been started, otherwise false.
  51055. */
  51056. isStarted(): boolean;
  51057. /**
  51058. * Starts the particle system and begins to emit
  51059. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51060. */
  51061. start(delay?: number): void;
  51062. /**
  51063. * Stops the particle system.
  51064. */
  51065. stop(): void;
  51066. /**
  51067. * Remove all active particles
  51068. */
  51069. reset(): void;
  51070. /**
  51071. * Returns the string "GPUParticleSystem"
  51072. * @returns a string containing the class name
  51073. */
  51074. getClassName(): string;
  51075. private _colorGradientsTexture;
  51076. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51077. /**
  51078. * Adds a new color gradient
  51079. * @param gradient defines the gradient to use (between 0 and 1)
  51080. * @param color1 defines the color to affect to the specified gradient
  51081. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51082. * @returns the current particle system
  51083. */
  51084. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51085. /**
  51086. * Remove a specific color gradient
  51087. * @param gradient defines the gradient to remove
  51088. * @returns the current particle system
  51089. */
  51090. removeColorGradient(gradient: number): GPUParticleSystem;
  51091. private _angularSpeedGradientsTexture;
  51092. private _sizeGradientsTexture;
  51093. private _velocityGradientsTexture;
  51094. private _limitVelocityGradientsTexture;
  51095. private _dragGradientsTexture;
  51096. private _addFactorGradient;
  51097. /**
  51098. * Adds a new size gradient
  51099. * @param gradient defines the gradient to use (between 0 and 1)
  51100. * @param factor defines the size factor to affect to the specified gradient
  51101. * @returns the current particle system
  51102. */
  51103. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51104. /**
  51105. * Remove a specific size gradient
  51106. * @param gradient defines the gradient to remove
  51107. * @returns the current particle system
  51108. */
  51109. removeSizeGradient(gradient: number): GPUParticleSystem;
  51110. /**
  51111. * Adds a new angular speed gradient
  51112. * @param gradient defines the gradient to use (between 0 and 1)
  51113. * @param factor defines the angular speed to affect to the specified gradient
  51114. * @returns the current particle system
  51115. */
  51116. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51117. /**
  51118. * Remove a specific angular speed gradient
  51119. * @param gradient defines the gradient to remove
  51120. * @returns the current particle system
  51121. */
  51122. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51123. /**
  51124. * Adds a new velocity gradient
  51125. * @param gradient defines the gradient to use (between 0 and 1)
  51126. * @param factor defines the velocity to affect to the specified gradient
  51127. * @returns the current particle system
  51128. */
  51129. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51130. /**
  51131. * Remove a specific velocity gradient
  51132. * @param gradient defines the gradient to remove
  51133. * @returns the current particle system
  51134. */
  51135. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51136. /**
  51137. * Adds a new limit velocity gradient
  51138. * @param gradient defines the gradient to use (between 0 and 1)
  51139. * @param factor defines the limit velocity value to affect to the specified gradient
  51140. * @returns the current particle system
  51141. */
  51142. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51143. /**
  51144. * Remove a specific limit velocity gradient
  51145. * @param gradient defines the gradient to remove
  51146. * @returns the current particle system
  51147. */
  51148. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51149. /**
  51150. * Adds a new drag gradient
  51151. * @param gradient defines the gradient to use (between 0 and 1)
  51152. * @param factor defines the drag value to affect to the specified gradient
  51153. * @returns the current particle system
  51154. */
  51155. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51156. /**
  51157. * Remove a specific drag gradient
  51158. * @param gradient defines the gradient to remove
  51159. * @returns the current particle system
  51160. */
  51161. removeDragGradient(gradient: number): GPUParticleSystem;
  51162. /**
  51163. * Not supported by GPUParticleSystem
  51164. * @param gradient defines the gradient to use (between 0 and 1)
  51165. * @param factor defines the emit rate value to affect to the specified gradient
  51166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51167. * @returns the current particle system
  51168. */
  51169. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51170. /**
  51171. * Not supported by GPUParticleSystem
  51172. * @param gradient defines the gradient to remove
  51173. * @returns the current particle system
  51174. */
  51175. removeEmitRateGradient(gradient: number): IParticleSystem;
  51176. /**
  51177. * Not supported by GPUParticleSystem
  51178. * @param gradient defines the gradient to use (between 0 and 1)
  51179. * @param factor defines the start size value to affect to the specified gradient
  51180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51181. * @returns the current particle system
  51182. */
  51183. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51184. /**
  51185. * Not supported by GPUParticleSystem
  51186. * @param gradient defines the gradient to remove
  51187. * @returns the current particle system
  51188. */
  51189. removeStartSizeGradient(gradient: number): IParticleSystem;
  51190. /**
  51191. * Not supported by GPUParticleSystem
  51192. * @param gradient defines the gradient to use (between 0 and 1)
  51193. * @param min defines the color remap minimal range
  51194. * @param max defines the color remap maximal range
  51195. * @returns the current particle system
  51196. */
  51197. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51198. /**
  51199. * Not supported by GPUParticleSystem
  51200. * @param gradient defines the gradient to remove
  51201. * @returns the current particle system
  51202. */
  51203. removeColorRemapGradient(): IParticleSystem;
  51204. /**
  51205. * Not supported by GPUParticleSystem
  51206. * @param gradient defines the gradient to use (between 0 and 1)
  51207. * @param min defines the alpha remap minimal range
  51208. * @param max defines the alpha remap maximal range
  51209. * @returns the current particle system
  51210. */
  51211. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51212. /**
  51213. * Not supported by GPUParticleSystem
  51214. * @param gradient defines the gradient to remove
  51215. * @returns the current particle system
  51216. */
  51217. removeAlphaRemapGradient(): IParticleSystem;
  51218. /**
  51219. * Not supported by GPUParticleSystem
  51220. * @param gradient defines the gradient to use (between 0 and 1)
  51221. * @param color defines the color to affect to the specified gradient
  51222. * @returns the current particle system
  51223. */
  51224. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51225. /**
  51226. * Not supported by GPUParticleSystem
  51227. * @param gradient defines the gradient to remove
  51228. * @returns the current particle system
  51229. */
  51230. removeRampGradient(): IParticleSystem;
  51231. /**
  51232. * Not supported by GPUParticleSystem
  51233. * @returns the list of ramp gradients
  51234. */
  51235. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51236. /**
  51237. * Not supported by GPUParticleSystem
  51238. * Gets or sets a boolean indicating that ramp gradients must be used
  51239. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51240. */
  51241. useRampGradients: boolean;
  51242. /**
  51243. * Not supported by GPUParticleSystem
  51244. * @param gradient defines the gradient to use (between 0 and 1)
  51245. * @param factor defines the life time factor to affect to the specified gradient
  51246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51247. * @returns the current particle system
  51248. */
  51249. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51250. /**
  51251. * Not supported by GPUParticleSystem
  51252. * @param gradient defines the gradient to remove
  51253. * @returns the current particle system
  51254. */
  51255. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51256. /**
  51257. * Instantiates a GPU particle system.
  51258. * 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.
  51259. * @param name The name of the particle system
  51260. * @param options The options used to create the system
  51261. * @param scene The scene the particle system belongs to
  51262. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51263. */
  51264. constructor(name: string, options: Partial<{
  51265. capacity: number;
  51266. randomTextureSize: number;
  51267. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51268. protected _reset(): void;
  51269. private _createUpdateVAO;
  51270. private _createRenderVAO;
  51271. private _initialize;
  51272. /** @hidden */
  51273. _recreateUpdateEffect(): void;
  51274. /** @hidden */
  51275. _recreateRenderEffect(): void;
  51276. /**
  51277. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51278. * @param preWarm defines if we are in the pre-warmimg phase
  51279. */
  51280. animate(preWarm?: boolean): void;
  51281. private _createFactorGradientTexture;
  51282. private _createSizeGradientTexture;
  51283. private _createAngularSpeedGradientTexture;
  51284. private _createVelocityGradientTexture;
  51285. private _createLimitVelocityGradientTexture;
  51286. private _createDragGradientTexture;
  51287. private _createColorGradientTexture;
  51288. /**
  51289. * Renders the particle system in its current state
  51290. * @param preWarm defines if the system should only update the particles but not render them
  51291. * @returns the current number of particles
  51292. */
  51293. render(preWarm?: boolean): number;
  51294. /**
  51295. * Rebuilds the particle system
  51296. */
  51297. rebuild(): void;
  51298. private _releaseBuffers;
  51299. private _releaseVAOs;
  51300. /**
  51301. * Disposes the particle system and free the associated resources
  51302. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51303. */
  51304. dispose(disposeTexture?: boolean): void;
  51305. /**
  51306. * Clones the particle system.
  51307. * @param name The name of the cloned object
  51308. * @param newEmitter The new emitter to use
  51309. * @returns the cloned particle system
  51310. */
  51311. clone(name: string, newEmitter: any): GPUParticleSystem;
  51312. /**
  51313. * Serializes the particle system to a JSON object.
  51314. * @returns the JSON object
  51315. */
  51316. serialize(): any;
  51317. /**
  51318. * Parses a JSON object to create a GPU particle system.
  51319. * @param parsedParticleSystem The JSON object to parse
  51320. * @param scene The scene to create the particle system in
  51321. * @param rootUrl The root url to use to load external dependencies like texture
  51322. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51323. * @returns the parsed GPU particle system
  51324. */
  51325. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51326. }
  51327. }
  51328. declare module BABYLON {
  51329. /**
  51330. * Represents a set of particle systems working together to create a specific effect
  51331. */
  51332. export class ParticleSystemSet implements IDisposable {
  51333. private _emitterCreationOptions;
  51334. private _emitterNode;
  51335. /**
  51336. * Gets the particle system list
  51337. */
  51338. systems: IParticleSystem[];
  51339. /**
  51340. * Gets the emitter node used with this set
  51341. */
  51342. readonly emitterNode: Nullable<TransformNode>;
  51343. /**
  51344. * Creates a new emitter mesh as a sphere
  51345. * @param options defines the options used to create the sphere
  51346. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51347. * @param scene defines the hosting scene
  51348. */
  51349. setEmitterAsSphere(options: {
  51350. diameter: number;
  51351. segments: number;
  51352. color: Color3;
  51353. }, renderingGroupId: number, scene: Scene): void;
  51354. /**
  51355. * Starts all particle systems of the set
  51356. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51357. */
  51358. start(emitter?: AbstractMesh): void;
  51359. /**
  51360. * Release all associated resources
  51361. */
  51362. dispose(): void;
  51363. /**
  51364. * Serialize the set into a JSON compatible object
  51365. * @returns a JSON compatible representation of the set
  51366. */
  51367. serialize(): any;
  51368. /**
  51369. * Parse a new ParticleSystemSet from a serialized source
  51370. * @param data defines a JSON compatible representation of the set
  51371. * @param scene defines the hosting scene
  51372. * @param gpu defines if we want GPU particles or CPU particles
  51373. * @returns a new ParticleSystemSet
  51374. */
  51375. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51376. }
  51377. }
  51378. declare module BABYLON {
  51379. /**
  51380. * This class is made for on one-liner static method to help creating particle system set.
  51381. */
  51382. export class ParticleHelper {
  51383. /**
  51384. * Gets or sets base Assets URL
  51385. */
  51386. static BaseAssetsUrl: string;
  51387. /**
  51388. * Create a default particle system that you can tweak
  51389. * @param emitter defines the emitter to use
  51390. * @param capacity defines the system capacity (default is 500 particles)
  51391. * @param scene defines the hosting scene
  51392. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51393. * @returns the new Particle system
  51394. */
  51395. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51396. /**
  51397. * This is the main static method (one-liner) of this helper to create different particle systems
  51398. * @param type This string represents the type to the particle system to create
  51399. * @param scene The scene where the particle system should live
  51400. * @param gpu If the system will use gpu
  51401. * @returns the ParticleSystemSet created
  51402. */
  51403. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51404. /**
  51405. * Static function used to export a particle system to a ParticleSystemSet variable.
  51406. * Please note that the emitter shape is not exported
  51407. * @param systems defines the particle systems to export
  51408. * @returns the created particle system set
  51409. */
  51410. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51411. }
  51412. }
  51413. declare module BABYLON {
  51414. interface Engine {
  51415. /**
  51416. * Create an effect to use with particle systems.
  51417. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51418. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51419. * @param uniformsNames defines a list of attribute names
  51420. * @param samplers defines an array of string used to represent textures
  51421. * @param defines defines the string containing the defines to use to compile the shaders
  51422. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51423. * @param onCompiled defines a function to call when the effect creation is successful
  51424. * @param onError defines a function to call when the effect creation has failed
  51425. * @returns the new Effect
  51426. */
  51427. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51428. }
  51429. interface Mesh {
  51430. /**
  51431. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51432. * @returns an array of IParticleSystem
  51433. */
  51434. getEmittedParticleSystems(): IParticleSystem[];
  51435. /**
  51436. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51437. * @returns an array of IParticleSystem
  51438. */
  51439. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51440. }
  51441. /**
  51442. * @hidden
  51443. */
  51444. export var _IDoNeedToBeInTheBuild: number;
  51445. }
  51446. declare module BABYLON {
  51447. interface Scene {
  51448. /** @hidden (Backing field) */
  51449. _physicsEngine: Nullable<IPhysicsEngine>;
  51450. /**
  51451. * Gets the current physics engine
  51452. * @returns a IPhysicsEngine or null if none attached
  51453. */
  51454. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51455. /**
  51456. * Enables physics to the current scene
  51457. * @param gravity defines the scene's gravity for the physics engine
  51458. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51459. * @return a boolean indicating if the physics engine was initialized
  51460. */
  51461. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51462. /**
  51463. * Disables and disposes the physics engine associated with the scene
  51464. */
  51465. disablePhysicsEngine(): void;
  51466. /**
  51467. * Gets a boolean indicating if there is an active physics engine
  51468. * @returns a boolean indicating if there is an active physics engine
  51469. */
  51470. isPhysicsEnabled(): boolean;
  51471. /**
  51472. * Deletes a physics compound impostor
  51473. * @param compound defines the compound to delete
  51474. */
  51475. deleteCompoundImpostor(compound: any): void;
  51476. /**
  51477. * An event triggered when physic simulation is about to be run
  51478. */
  51479. onBeforePhysicsObservable: Observable<Scene>;
  51480. /**
  51481. * An event triggered when physic simulation has been done
  51482. */
  51483. onAfterPhysicsObservable: Observable<Scene>;
  51484. }
  51485. interface AbstractMesh {
  51486. /** @hidden */
  51487. _physicsImpostor: Nullable<PhysicsImpostor>;
  51488. /**
  51489. * Gets or sets impostor used for physic simulation
  51490. * @see http://doc.babylonjs.com/features/physics_engine
  51491. */
  51492. physicsImpostor: Nullable<PhysicsImpostor>;
  51493. /**
  51494. * Gets the current physics impostor
  51495. * @see http://doc.babylonjs.com/features/physics_engine
  51496. * @returns a physics impostor or null
  51497. */
  51498. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51499. /** Apply a physic impulse to the mesh
  51500. * @param force defines the force to apply
  51501. * @param contactPoint defines where to apply the force
  51502. * @returns the current mesh
  51503. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51504. */
  51505. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51506. /**
  51507. * Creates a physic joint between two meshes
  51508. * @param otherMesh defines the other mesh to use
  51509. * @param pivot1 defines the pivot to use on this mesh
  51510. * @param pivot2 defines the pivot to use on the other mesh
  51511. * @param options defines additional options (can be plugin dependent)
  51512. * @returns the current mesh
  51513. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51514. */
  51515. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51516. /** @hidden */
  51517. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51518. }
  51519. /**
  51520. * Defines the physics engine scene component responsible to manage a physics engine
  51521. */
  51522. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51523. /**
  51524. * The component name helpful to identify the component in the list of scene components.
  51525. */
  51526. readonly name: string;
  51527. /**
  51528. * The scene the component belongs to.
  51529. */
  51530. scene: Scene;
  51531. /**
  51532. * Creates a new instance of the component for the given scene
  51533. * @param scene Defines the scene to register the component in
  51534. */
  51535. constructor(scene: Scene);
  51536. /**
  51537. * Registers the component in a given scene
  51538. */
  51539. register(): void;
  51540. /**
  51541. * Rebuilds the elements related to this component in case of
  51542. * context lost for instance.
  51543. */
  51544. rebuild(): void;
  51545. /**
  51546. * Disposes the component and the associated ressources
  51547. */
  51548. dispose(): void;
  51549. }
  51550. }
  51551. declare module BABYLON {
  51552. /**
  51553. * A helper for physics simulations
  51554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51555. */
  51556. export class PhysicsHelper {
  51557. private _scene;
  51558. private _physicsEngine;
  51559. /**
  51560. * Initializes the Physics helper
  51561. * @param scene Babylon.js scene
  51562. */
  51563. constructor(scene: Scene);
  51564. /**
  51565. * Applies a radial explosion impulse
  51566. * @param origin the origin of the explosion
  51567. * @param radiusOrEventOptions the radius or the options of radial explosion
  51568. * @param strength the explosion strength
  51569. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51570. * @returns A physics radial explosion event, or null
  51571. */
  51572. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51573. /**
  51574. * Applies a radial explosion force
  51575. * @param origin the origin of the explosion
  51576. * @param radiusOrEventOptions the radius or the options of radial explosion
  51577. * @param strength the explosion strength
  51578. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51579. * @returns A physics radial explosion event, or null
  51580. */
  51581. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51582. /**
  51583. * Creates a gravitational field
  51584. * @param origin the origin of the explosion
  51585. * @param radiusOrEventOptions the radius or the options of radial explosion
  51586. * @param strength the explosion strength
  51587. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51588. * @returns A physics gravitational field event, or null
  51589. */
  51590. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51591. /**
  51592. * Creates a physics updraft event
  51593. * @param origin the origin of the updraft
  51594. * @param radiusOrEventOptions the radius or the options of the updraft
  51595. * @param strength the strength of the updraft
  51596. * @param height the height of the updraft
  51597. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51598. * @returns A physics updraft event, or null
  51599. */
  51600. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51601. /**
  51602. * Creates a physics vortex event
  51603. * @param origin the of the vortex
  51604. * @param radiusOrEventOptions the radius or the options of the vortex
  51605. * @param strength the strength of the vortex
  51606. * @param height the height of the vortex
  51607. * @returns a Physics vortex event, or null
  51608. * A physics vortex event or null
  51609. */
  51610. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51611. }
  51612. /**
  51613. * Represents a physics radial explosion event
  51614. */
  51615. class PhysicsRadialExplosionEvent {
  51616. private _scene;
  51617. private _options;
  51618. private _sphere;
  51619. private _dataFetched;
  51620. /**
  51621. * Initializes a radial explosioin event
  51622. * @param _scene BabylonJS scene
  51623. * @param _options The options for the vortex event
  51624. */
  51625. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51626. /**
  51627. * Returns the data related to the radial explosion event (sphere).
  51628. * @returns The radial explosion event data
  51629. */
  51630. getData(): PhysicsRadialExplosionEventData;
  51631. /**
  51632. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51633. * @param impostor A physics imposter
  51634. * @param origin the origin of the explosion
  51635. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51636. */
  51637. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51638. /**
  51639. * Triggers affecterd impostors callbacks
  51640. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51641. */
  51642. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51643. /**
  51644. * Disposes the sphere.
  51645. * @param force Specifies if the sphere should be disposed by force
  51646. */
  51647. dispose(force?: boolean): void;
  51648. /*** Helpers ***/
  51649. private _prepareSphere;
  51650. private _intersectsWithSphere;
  51651. }
  51652. /**
  51653. * Represents a gravitational field event
  51654. */
  51655. class PhysicsGravitationalFieldEvent {
  51656. private _physicsHelper;
  51657. private _scene;
  51658. private _origin;
  51659. private _options;
  51660. private _tickCallback;
  51661. private _sphere;
  51662. private _dataFetched;
  51663. /**
  51664. * Initializes the physics gravitational field event
  51665. * @param _physicsHelper A physics helper
  51666. * @param _scene BabylonJS scene
  51667. * @param _origin The origin position of the gravitational field event
  51668. * @param _options The options for the vortex event
  51669. */
  51670. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51671. /**
  51672. * Returns the data related to the gravitational field event (sphere).
  51673. * @returns A gravitational field event
  51674. */
  51675. getData(): PhysicsGravitationalFieldEventData;
  51676. /**
  51677. * Enables the gravitational field.
  51678. */
  51679. enable(): void;
  51680. /**
  51681. * Disables the gravitational field.
  51682. */
  51683. disable(): void;
  51684. /**
  51685. * Disposes the sphere.
  51686. * @param force The force to dispose from the gravitational field event
  51687. */
  51688. dispose(force?: boolean): void;
  51689. private _tick;
  51690. }
  51691. /**
  51692. * Represents a physics updraft event
  51693. */
  51694. class PhysicsUpdraftEvent {
  51695. private _scene;
  51696. private _origin;
  51697. private _options;
  51698. private _physicsEngine;
  51699. private _originTop;
  51700. private _originDirection;
  51701. private _tickCallback;
  51702. private _cylinder;
  51703. private _cylinderPosition;
  51704. private _dataFetched;
  51705. /**
  51706. * Initializes the physics updraft event
  51707. * @param _scene BabylonJS scene
  51708. * @param _origin The origin position of the updraft
  51709. * @param _options The options for the updraft event
  51710. */
  51711. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51712. /**
  51713. * Returns the data related to the updraft event (cylinder).
  51714. * @returns A physics updraft event
  51715. */
  51716. getData(): PhysicsUpdraftEventData;
  51717. /**
  51718. * Enables the updraft.
  51719. */
  51720. enable(): void;
  51721. /**
  51722. * Disables the updraft.
  51723. */
  51724. disable(): void;
  51725. /**
  51726. * Disposes the cylinder.
  51727. * @param force Specifies if the updraft should be disposed by force
  51728. */
  51729. dispose(force?: boolean): void;
  51730. private getImpostorHitData;
  51731. private _tick;
  51732. /*** Helpers ***/
  51733. private _prepareCylinder;
  51734. private _intersectsWithCylinder;
  51735. }
  51736. /**
  51737. * Represents a physics vortex event
  51738. */
  51739. class PhysicsVortexEvent {
  51740. private _scene;
  51741. private _origin;
  51742. private _options;
  51743. private _physicsEngine;
  51744. private _originTop;
  51745. private _tickCallback;
  51746. private _cylinder;
  51747. private _cylinderPosition;
  51748. private _dataFetched;
  51749. /**
  51750. * Initializes the physics vortex event
  51751. * @param _scene The BabylonJS scene
  51752. * @param _origin The origin position of the vortex
  51753. * @param _options The options for the vortex event
  51754. */
  51755. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51756. /**
  51757. * Returns the data related to the vortex event (cylinder).
  51758. * @returns The physics vortex event data
  51759. */
  51760. getData(): PhysicsVortexEventData;
  51761. /**
  51762. * Enables the vortex.
  51763. */
  51764. enable(): void;
  51765. /**
  51766. * Disables the cortex.
  51767. */
  51768. disable(): void;
  51769. /**
  51770. * Disposes the sphere.
  51771. * @param force
  51772. */
  51773. dispose(force?: boolean): void;
  51774. private getImpostorHitData;
  51775. private _tick;
  51776. /*** Helpers ***/
  51777. private _prepareCylinder;
  51778. private _intersectsWithCylinder;
  51779. }
  51780. /**
  51781. * Options fot the radial explosion event
  51782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51783. */
  51784. export class PhysicsRadialExplosionEventOptions {
  51785. /**
  51786. * The radius of the sphere for the radial explosion.
  51787. */
  51788. radius: number;
  51789. /**
  51790. * The strenth of the explosion.
  51791. */
  51792. strength: number;
  51793. /**
  51794. * The strenght of the force in correspondence to the distance of the affected object
  51795. */
  51796. falloff: PhysicsRadialImpulseFalloff;
  51797. /**
  51798. * Sphere options for the radial explosion.
  51799. */
  51800. sphere: {
  51801. segments: number;
  51802. diameter: number;
  51803. };
  51804. /**
  51805. * Sphere options for the radial explosion.
  51806. */
  51807. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51808. }
  51809. /**
  51810. * Options fot the updraft event
  51811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51812. */
  51813. export class PhysicsUpdraftEventOptions {
  51814. /**
  51815. * The radius of the cylinder for the vortex
  51816. */
  51817. radius: number;
  51818. /**
  51819. * The strenth of the updraft.
  51820. */
  51821. strength: number;
  51822. /**
  51823. * The height of the cylinder for the updraft.
  51824. */
  51825. height: number;
  51826. /**
  51827. * The mode for the the updraft.
  51828. */
  51829. updraftMode: PhysicsUpdraftMode;
  51830. }
  51831. /**
  51832. * Options fot the vortex event
  51833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51834. */
  51835. export class PhysicsVortexEventOptions {
  51836. /**
  51837. * The radius of the cylinder for the vortex
  51838. */
  51839. radius: number;
  51840. /**
  51841. * The strenth of the vortex.
  51842. */
  51843. strength: number;
  51844. /**
  51845. * The height of the cylinder for the vortex.
  51846. */
  51847. height: number;
  51848. /**
  51849. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51850. */
  51851. centripetalForceThreshold: number;
  51852. /**
  51853. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51854. */
  51855. centripetalForceMultiplier: number;
  51856. /**
  51857. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51858. */
  51859. centrifugalForceMultiplier: number;
  51860. /**
  51861. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51862. */
  51863. updraftForceMultiplier: number;
  51864. }
  51865. /**
  51866. * The strenght of the force in correspondence to the distance of the affected object
  51867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51868. */
  51869. export enum PhysicsRadialImpulseFalloff {
  51870. /** Defines that impulse is constant in strength across it's whole radius */
  51871. Constant = 0,
  51872. /** Defines that impulse gets weaker if it's further from the origin */
  51873. Linear = 1
  51874. }
  51875. /**
  51876. * The strength of the force in correspondence to the distance of the affected object
  51877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51878. */
  51879. export enum PhysicsUpdraftMode {
  51880. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51881. Center = 0,
  51882. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51883. Perpendicular = 1
  51884. }
  51885. /**
  51886. * Interface for a physics hit data
  51887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51888. */
  51889. export interface PhysicsHitData {
  51890. /**
  51891. * The force applied at the contact point
  51892. */
  51893. force: Vector3;
  51894. /**
  51895. * The contact point
  51896. */
  51897. contactPoint: Vector3;
  51898. /**
  51899. * The distance from the origin to the contact point
  51900. */
  51901. distanceFromOrigin: number;
  51902. }
  51903. /**
  51904. * Interface for radial explosion event data
  51905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51906. */
  51907. export interface PhysicsRadialExplosionEventData {
  51908. /**
  51909. * A sphere used for the radial explosion event
  51910. */
  51911. sphere: Mesh;
  51912. }
  51913. /**
  51914. * Interface for gravitational field event data
  51915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51916. */
  51917. export interface PhysicsGravitationalFieldEventData {
  51918. /**
  51919. * A sphere mesh used for the gravitational field event
  51920. */
  51921. sphere: Mesh;
  51922. }
  51923. /**
  51924. * Interface for updraft event data
  51925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51926. */
  51927. export interface PhysicsUpdraftEventData {
  51928. /**
  51929. * A cylinder used for the updraft event
  51930. */
  51931. cylinder: Mesh;
  51932. }
  51933. /**
  51934. * Interface for vortex event data
  51935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51936. */
  51937. export interface PhysicsVortexEventData {
  51938. /**
  51939. * A cylinder used for the vortex event
  51940. */
  51941. cylinder: Mesh;
  51942. }
  51943. /**
  51944. * Interface for an affected physics impostor
  51945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51946. */
  51947. export interface PhysicsAffectedImpostorWithData {
  51948. /**
  51949. * The impostor affected by the effect
  51950. */
  51951. impostor: PhysicsImpostor;
  51952. /**
  51953. * The data about the hit/horce from the explosion
  51954. */
  51955. hitData: PhysicsHitData;
  51956. }
  51957. }
  51958. declare module BABYLON {
  51959. /** @hidden */
  51960. export var blackAndWhitePixelShader: {
  51961. name: string;
  51962. shader: string;
  51963. };
  51964. }
  51965. declare module BABYLON {
  51966. /**
  51967. * Post process used to render in black and white
  51968. */
  51969. export class BlackAndWhitePostProcess extends PostProcess {
  51970. /**
  51971. * Linear about to convert he result to black and white (default: 1)
  51972. */
  51973. degree: number;
  51974. /**
  51975. * Creates a black and white post process
  51976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51977. * @param name The name of the effect.
  51978. * @param options The required width/height ratio to downsize to before computing the render pass.
  51979. * @param camera The camera to apply the render pass to.
  51980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51981. * @param engine The engine which the post process will be applied. (default: current engine)
  51982. * @param reusable If the post process can be reused on the same frame. (default: false)
  51983. */
  51984. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51985. }
  51986. }
  51987. declare module BABYLON {
  51988. /**
  51989. * This represents a set of one or more post processes in Babylon.
  51990. * A post process can be used to apply a shader to a texture after it is rendered.
  51991. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51992. */
  51993. export class PostProcessRenderEffect {
  51994. private _postProcesses;
  51995. private _getPostProcesses;
  51996. private _singleInstance;
  51997. private _cameras;
  51998. private _indicesForCamera;
  51999. /**
  52000. * Name of the effect
  52001. * @hidden
  52002. */
  52003. _name: string;
  52004. /**
  52005. * Instantiates a post process render effect.
  52006. * A post process can be used to apply a shader to a texture after it is rendered.
  52007. * @param engine The engine the effect is tied to
  52008. * @param name The name of the effect
  52009. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52010. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52011. */
  52012. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52013. /**
  52014. * Checks if all the post processes in the effect are supported.
  52015. */
  52016. readonly isSupported: boolean;
  52017. /**
  52018. * Updates the current state of the effect
  52019. * @hidden
  52020. */
  52021. _update(): void;
  52022. /**
  52023. * Attaches the effect on cameras
  52024. * @param cameras The camera to attach to.
  52025. * @hidden
  52026. */
  52027. _attachCameras(cameras: Camera): void;
  52028. /**
  52029. * Attaches the effect on cameras
  52030. * @param cameras The camera to attach to.
  52031. * @hidden
  52032. */
  52033. _attachCameras(cameras: Camera[]): void;
  52034. /**
  52035. * Detatches the effect on cameras
  52036. * @param cameras The camera to detatch from.
  52037. * @hidden
  52038. */
  52039. _detachCameras(cameras: Camera): void;
  52040. /**
  52041. * Detatches the effect on cameras
  52042. * @param cameras The camera to detatch from.
  52043. * @hidden
  52044. */
  52045. _detachCameras(cameras: Camera[]): void;
  52046. /**
  52047. * Enables the effect on given cameras
  52048. * @param cameras The camera to enable.
  52049. * @hidden
  52050. */
  52051. _enable(cameras: Camera): void;
  52052. /**
  52053. * Enables the effect on given cameras
  52054. * @param cameras The camera to enable.
  52055. * @hidden
  52056. */
  52057. _enable(cameras: Nullable<Camera[]>): void;
  52058. /**
  52059. * Disables the effect on the given cameras
  52060. * @param cameras The camera to disable.
  52061. * @hidden
  52062. */
  52063. _disable(cameras: Camera): void;
  52064. /**
  52065. * Disables the effect on the given cameras
  52066. * @param cameras The camera to disable.
  52067. * @hidden
  52068. */
  52069. _disable(cameras: Nullable<Camera[]>): void;
  52070. /**
  52071. * Gets a list of the post processes contained in the effect.
  52072. * @param camera The camera to get the post processes on.
  52073. * @returns The list of the post processes in the effect.
  52074. */
  52075. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52076. }
  52077. }
  52078. declare module BABYLON {
  52079. /** @hidden */
  52080. export var extractHighlightsPixelShader: {
  52081. name: string;
  52082. shader: string;
  52083. };
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * 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.
  52088. */
  52089. export class ExtractHighlightsPostProcess extends PostProcess {
  52090. /**
  52091. * The luminance threshold, pixels below this value will be set to black.
  52092. */
  52093. threshold: number;
  52094. /** @hidden */
  52095. _exposure: number;
  52096. /**
  52097. * Post process which has the input texture to be used when performing highlight extraction
  52098. * @hidden
  52099. */
  52100. _inputPostProcess: Nullable<PostProcess>;
  52101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52102. }
  52103. }
  52104. declare module BABYLON {
  52105. /** @hidden */
  52106. export var bloomMergePixelShader: {
  52107. name: string;
  52108. shader: string;
  52109. };
  52110. }
  52111. declare module BABYLON {
  52112. /**
  52113. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52114. */
  52115. export class BloomMergePostProcess extends PostProcess {
  52116. /** Weight of the bloom to be added to the original input. */
  52117. weight: number;
  52118. /**
  52119. * Creates a new instance of @see BloomMergePostProcess
  52120. * @param name The name of the effect.
  52121. * @param originalFromInput Post process which's input will be used for the merge.
  52122. * @param blurred Blurred highlights post process which's output will be used.
  52123. * @param weight Weight of the bloom to be added to the original input.
  52124. * @param options The required width/height ratio to downsize to before computing the render pass.
  52125. * @param camera The camera to apply the render pass to.
  52126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52127. * @param engine The engine which the post process will be applied. (default: current engine)
  52128. * @param reusable If the post process can be reused on the same frame. (default: false)
  52129. * @param textureType Type of textures used when performing the post process. (default: 0)
  52130. * @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)
  52131. */
  52132. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52133. /** Weight of the bloom to be added to the original input. */
  52134. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52135. }
  52136. }
  52137. declare module BABYLON {
  52138. /**
  52139. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52140. */
  52141. export class BloomEffect extends PostProcessRenderEffect {
  52142. private bloomScale;
  52143. /**
  52144. * @hidden Internal
  52145. */
  52146. _effects: Array<PostProcess>;
  52147. /**
  52148. * @hidden Internal
  52149. */
  52150. _downscale: ExtractHighlightsPostProcess;
  52151. private _blurX;
  52152. private _blurY;
  52153. private _merge;
  52154. /**
  52155. * The luminance threshold to find bright areas of the image to bloom.
  52156. */
  52157. threshold: number;
  52158. /**
  52159. * The strength of the bloom.
  52160. */
  52161. weight: number;
  52162. /**
  52163. * Specifies the size of the bloom blur kernel, relative to the final output size
  52164. */
  52165. kernel: number;
  52166. /**
  52167. * Creates a new instance of @see BloomEffect
  52168. * @param scene The scene the effect belongs to.
  52169. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52170. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52171. * @param bloomWeight The the strength of bloom.
  52172. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52173. * @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)
  52174. */
  52175. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52176. /**
  52177. * Disposes each of the internal effects for a given camera.
  52178. * @param camera The camera to dispose the effect on.
  52179. */
  52180. disposeEffects(camera: Camera): void;
  52181. /**
  52182. * @hidden Internal
  52183. */
  52184. _updateEffects(): void;
  52185. /**
  52186. * Internal
  52187. * @returns if all the contained post processes are ready.
  52188. * @hidden
  52189. */
  52190. _isReady(): boolean;
  52191. }
  52192. }
  52193. declare module BABYLON {
  52194. /** @hidden */
  52195. export var chromaticAberrationPixelShader: {
  52196. name: string;
  52197. shader: string;
  52198. };
  52199. }
  52200. declare module BABYLON {
  52201. /**
  52202. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52203. */
  52204. export class ChromaticAberrationPostProcess extends PostProcess {
  52205. /**
  52206. * The amount of seperation of rgb channels (default: 30)
  52207. */
  52208. aberrationAmount: number;
  52209. /**
  52210. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52211. */
  52212. radialIntensity: number;
  52213. /**
  52214. * 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))
  52215. */
  52216. direction: Vector2;
  52217. /**
  52218. * 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))
  52219. */
  52220. centerPosition: Vector2;
  52221. /**
  52222. * Creates a new instance ChromaticAberrationPostProcess
  52223. * @param name The name of the effect.
  52224. * @param screenWidth The width of the screen to apply the effect on.
  52225. * @param screenHeight The height of the screen to apply the effect on.
  52226. * @param options The required width/height ratio to downsize to before computing the render pass.
  52227. * @param camera The camera to apply the render pass to.
  52228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52229. * @param engine The engine which the post process will be applied. (default: current engine)
  52230. * @param reusable If the post process can be reused on the same frame. (default: false)
  52231. * @param textureType Type of textures used when performing the post process. (default: 0)
  52232. * @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)
  52233. */
  52234. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52235. }
  52236. }
  52237. declare module BABYLON {
  52238. /** @hidden */
  52239. export var circleOfConfusionPixelShader: {
  52240. name: string;
  52241. shader: string;
  52242. };
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52247. */
  52248. export class CircleOfConfusionPostProcess extends PostProcess {
  52249. /**
  52250. * 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.
  52251. */
  52252. lensSize: number;
  52253. /**
  52254. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52255. */
  52256. fStop: number;
  52257. /**
  52258. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52259. */
  52260. focusDistance: number;
  52261. /**
  52262. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52263. */
  52264. focalLength: number;
  52265. private _depthTexture;
  52266. /**
  52267. * Creates a new instance CircleOfConfusionPostProcess
  52268. * @param name The name of the effect.
  52269. * @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.
  52270. * @param options The required width/height ratio to downsize to before computing the render pass.
  52271. * @param camera The camera to apply the render pass to.
  52272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52273. * @param engine The engine which the post process will be applied. (default: current engine)
  52274. * @param reusable If the post process can be reused on the same frame. (default: false)
  52275. * @param textureType Type of textures used when performing the post process. (default: 0)
  52276. * @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)
  52277. */
  52278. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52279. /**
  52280. * 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.
  52281. */
  52282. depthTexture: RenderTargetTexture;
  52283. }
  52284. }
  52285. declare module BABYLON {
  52286. /** @hidden */
  52287. export var colorCorrectionPixelShader: {
  52288. name: string;
  52289. shader: string;
  52290. };
  52291. }
  52292. declare module BABYLON {
  52293. /**
  52294. *
  52295. * This post-process allows the modification of rendered colors by using
  52296. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52297. *
  52298. * The object needs to be provided an url to a texture containing the color
  52299. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52300. * Use an image editing software to tweak the LUT to match your needs.
  52301. *
  52302. * For an example of a color LUT, see here:
  52303. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52304. * For explanations on color grading, see here:
  52305. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52306. *
  52307. */
  52308. export class ColorCorrectionPostProcess extends PostProcess {
  52309. private _colorTableTexture;
  52310. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52311. }
  52312. }
  52313. declare module BABYLON {
  52314. /** @hidden */
  52315. export var convolutionPixelShader: {
  52316. name: string;
  52317. shader: string;
  52318. };
  52319. }
  52320. declare module BABYLON {
  52321. /**
  52322. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52323. * input texture to perform effects such as edge detection or sharpening
  52324. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52325. */
  52326. export class ConvolutionPostProcess extends PostProcess {
  52327. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52328. kernel: number[];
  52329. /**
  52330. * Creates a new instance ConvolutionPostProcess
  52331. * @param name The name of the effect.
  52332. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52333. * @param options The required width/height ratio to downsize to before computing the render pass.
  52334. * @param camera The camera to apply the render pass to.
  52335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52336. * @param engine The engine which the post process will be applied. (default: current engine)
  52337. * @param reusable If the post process can be reused on the same frame. (default: false)
  52338. * @param textureType Type of textures used when performing the post process. (default: 0)
  52339. */
  52340. constructor(name: string,
  52341. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52342. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52343. /**
  52344. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52345. */
  52346. static EdgeDetect0Kernel: number[];
  52347. /**
  52348. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52349. */
  52350. static EdgeDetect1Kernel: number[];
  52351. /**
  52352. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52353. */
  52354. static EdgeDetect2Kernel: number[];
  52355. /**
  52356. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52357. */
  52358. static SharpenKernel: number[];
  52359. /**
  52360. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52361. */
  52362. static EmbossKernel: number[];
  52363. /**
  52364. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52365. */
  52366. static GaussianKernel: number[];
  52367. }
  52368. }
  52369. declare module BABYLON {
  52370. /**
  52371. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52372. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52373. * based on samples that have a large difference in distance than the center pixel.
  52374. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52375. */
  52376. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52377. direction: Vector2;
  52378. /**
  52379. * Creates a new instance CircleOfConfusionPostProcess
  52380. * @param name The name of the effect.
  52381. * @param scene The scene the effect belongs to.
  52382. * @param direction The direction the blur should be applied.
  52383. * @param kernel The size of the kernel used to blur.
  52384. * @param options The required width/height ratio to downsize to before computing the render pass.
  52385. * @param camera The camera to apply the render pass to.
  52386. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52387. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52389. * @param engine The engine which the post process will be applied. (default: current engine)
  52390. * @param reusable If the post process can be reused on the same frame. (default: false)
  52391. * @param textureType Type of textures used when performing the post process. (default: 0)
  52392. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  52393. */
  52394. constructor(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);
  52395. }
  52396. }
  52397. declare module BABYLON {
  52398. /** @hidden */
  52399. export var depthOfFieldMergePixelShader: {
  52400. name: string;
  52401. shader: string;
  52402. };
  52403. }
  52404. declare module BABYLON {
  52405. /**
  52406. * Options to be set when merging outputs from the default pipeline.
  52407. */
  52408. export class DepthOfFieldMergePostProcessOptions {
  52409. /**
  52410. * The original image to merge on top of
  52411. */
  52412. originalFromInput: PostProcess;
  52413. /**
  52414. * Parameters to perform the merge of the depth of field effect
  52415. */
  52416. depthOfField?: {
  52417. circleOfConfusion: PostProcess;
  52418. blurSteps: Array<PostProcess>;
  52419. };
  52420. /**
  52421. * Parameters to perform the merge of bloom effect
  52422. */
  52423. bloom?: {
  52424. blurred: PostProcess;
  52425. weight: number;
  52426. };
  52427. }
  52428. /**
  52429. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52430. */
  52431. export class DepthOfFieldMergePostProcess extends PostProcess {
  52432. private blurSteps;
  52433. /**
  52434. * Creates a new instance of DepthOfFieldMergePostProcess
  52435. * @param name The name of the effect.
  52436. * @param originalFromInput Post process which's input will be used for the merge.
  52437. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52438. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52439. * @param options The required width/height ratio to downsize to before computing the render pass.
  52440. * @param camera The camera to apply the render pass to.
  52441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52442. * @param engine The engine which the post process will be applied. (default: current engine)
  52443. * @param reusable If the post process can be reused on the same frame. (default: false)
  52444. * @param textureType Type of textures used when performing the post process. (default: 0)
  52445. * @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)
  52446. */
  52447. 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);
  52448. /**
  52449. * Updates the effect with the current post process compile time values and recompiles the shader.
  52450. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52451. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52452. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52453. * @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
  52454. * @param onCompiled Called when the shader has been compiled.
  52455. * @param onError Called if there is an error when compiling a shader.
  52456. */
  52457. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52458. }
  52459. }
  52460. declare module BABYLON {
  52461. /**
  52462. * Specifies the level of max blur that should be applied when using the depth of field effect
  52463. */
  52464. export enum DepthOfFieldEffectBlurLevel {
  52465. /**
  52466. * Subtle blur
  52467. */
  52468. Low = 0,
  52469. /**
  52470. * Medium blur
  52471. */
  52472. Medium = 1,
  52473. /**
  52474. * Large blur
  52475. */
  52476. High = 2
  52477. }
  52478. /**
  52479. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52480. */
  52481. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52482. private _circleOfConfusion;
  52483. /**
  52484. * @hidden Internal, blurs from high to low
  52485. */
  52486. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52487. private _depthOfFieldBlurY;
  52488. private _dofMerge;
  52489. /**
  52490. * @hidden Internal post processes in depth of field effect
  52491. */
  52492. _effects: Array<PostProcess>;
  52493. /**
  52494. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52495. */
  52496. focalLength: number;
  52497. /**
  52498. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52499. */
  52500. fStop: number;
  52501. /**
  52502. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52503. */
  52504. focusDistance: number;
  52505. /**
  52506. * 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.
  52507. */
  52508. lensSize: number;
  52509. /**
  52510. * Creates a new instance DepthOfFieldEffect
  52511. * @param scene The scene the effect belongs to.
  52512. * @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.
  52513. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52514. * @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)
  52515. */
  52516. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52517. /**
  52518. * 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.
  52519. */
  52520. depthTexture: RenderTargetTexture;
  52521. /**
  52522. * Disposes each of the internal effects for a given camera.
  52523. * @param camera The camera to dispose the effect on.
  52524. */
  52525. disposeEffects(camera: Camera): void;
  52526. /**
  52527. * @hidden Internal
  52528. */
  52529. _updateEffects(): void;
  52530. /**
  52531. * Internal
  52532. * @returns if all the contained post processes are ready.
  52533. * @hidden
  52534. */
  52535. _isReady(): boolean;
  52536. }
  52537. }
  52538. declare module BABYLON {
  52539. /** @hidden */
  52540. export var displayPassPixelShader: {
  52541. name: string;
  52542. shader: string;
  52543. };
  52544. }
  52545. declare module BABYLON {
  52546. /**
  52547. * DisplayPassPostProcess which produces an output the same as it's input
  52548. */
  52549. export class DisplayPassPostProcess extends PostProcess {
  52550. /**
  52551. * Creates the DisplayPassPostProcess
  52552. * @param name The name of the effect.
  52553. * @param options The required width/height ratio to downsize to before computing the render pass.
  52554. * @param camera The camera to apply the render pass to.
  52555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52556. * @param engine The engine which the post process will be applied. (default: current engine)
  52557. * @param reusable If the post process can be reused on the same frame. (default: false)
  52558. */
  52559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52560. }
  52561. }
  52562. declare module BABYLON {
  52563. /** @hidden */
  52564. export var filterPixelShader: {
  52565. name: string;
  52566. shader: string;
  52567. };
  52568. }
  52569. declare module BABYLON {
  52570. /**
  52571. * Applies a kernel filter to the image
  52572. */
  52573. export class FilterPostProcess extends PostProcess {
  52574. /** The matrix to be applied to the image */
  52575. kernelMatrix: Matrix;
  52576. /**
  52577. *
  52578. * @param name The name of the effect.
  52579. * @param kernelMatrix The matrix to be applied to the image
  52580. * @param options The required width/height ratio to downsize to before computing the render pass.
  52581. * @param camera The camera to apply the render pass to.
  52582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52583. * @param engine The engine which the post process will be applied. (default: current engine)
  52584. * @param reusable If the post process can be reused on the same frame. (default: false)
  52585. */
  52586. constructor(name: string,
  52587. /** The matrix to be applied to the image */
  52588. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. /** @hidden */
  52593. export var fxaaPixelShader: {
  52594. name: string;
  52595. shader: string;
  52596. };
  52597. }
  52598. declare module BABYLON {
  52599. /** @hidden */
  52600. export var fxaaVertexShader: {
  52601. name: string;
  52602. shader: string;
  52603. };
  52604. }
  52605. declare module BABYLON {
  52606. /**
  52607. * Fxaa post process
  52608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52609. */
  52610. export class FxaaPostProcess extends PostProcess {
  52611. /** @hidden */
  52612. texelWidth: number;
  52613. /** @hidden */
  52614. texelHeight: number;
  52615. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52616. private _getDefines;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. /** @hidden */
  52621. export var grainPixelShader: {
  52622. name: string;
  52623. shader: string;
  52624. };
  52625. }
  52626. declare module BABYLON {
  52627. /**
  52628. * The GrainPostProcess adds noise to the image at mid luminance levels
  52629. */
  52630. export class GrainPostProcess extends PostProcess {
  52631. /**
  52632. * The intensity of the grain added (default: 30)
  52633. */
  52634. intensity: number;
  52635. /**
  52636. * If the grain should be randomized on every frame
  52637. */
  52638. animated: boolean;
  52639. /**
  52640. * Creates a new instance of @see GrainPostProcess
  52641. * @param name The name of the effect.
  52642. * @param options The required width/height ratio to downsize to before computing the render pass.
  52643. * @param camera The camera to apply the render pass to.
  52644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52645. * @param engine The engine which the post process will be applied. (default: current engine)
  52646. * @param reusable If the post process can be reused on the same frame. (default: false)
  52647. * @param textureType Type of textures used when performing the post process. (default: 0)
  52648. * @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)
  52649. */
  52650. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52651. }
  52652. }
  52653. declare module BABYLON {
  52654. /** @hidden */
  52655. export var highlightsPixelShader: {
  52656. name: string;
  52657. shader: string;
  52658. };
  52659. }
  52660. declare module BABYLON {
  52661. /**
  52662. * Extracts highlights from the image
  52663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52664. */
  52665. export class HighlightsPostProcess extends PostProcess {
  52666. /**
  52667. * Extracts highlights from the image
  52668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52669. * @param name The name of the effect.
  52670. * @param options The required width/height ratio to downsize to before computing the render pass.
  52671. * @param camera The camera to apply the render pass to.
  52672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52673. * @param engine The engine which the post process will be applied. (default: current engine)
  52674. * @param reusable If the post process can be reused on the same frame. (default: false)
  52675. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52676. */
  52677. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52678. }
  52679. }
  52680. declare module BABYLON {
  52681. /** @hidden */
  52682. export var mrtFragmentDeclaration: {
  52683. name: string;
  52684. shader: string;
  52685. };
  52686. }
  52687. declare module BABYLON {
  52688. /** @hidden */
  52689. export var geometryPixelShader: {
  52690. name: string;
  52691. shader: string;
  52692. };
  52693. }
  52694. declare module BABYLON {
  52695. /** @hidden */
  52696. export var geometryVertexShader: {
  52697. name: string;
  52698. shader: string;
  52699. };
  52700. }
  52701. declare module BABYLON {
  52702. /**
  52703. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52704. */
  52705. export class GeometryBufferRenderer {
  52706. /**
  52707. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52708. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52709. */
  52710. static readonly POSITION_TEXTURE_TYPE: number;
  52711. /**
  52712. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52713. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52714. */
  52715. static readonly VELOCITY_TEXTURE_TYPE: number;
  52716. /**
  52717. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52718. * in order to compute objects velocities when enableVelocity is set to "true"
  52719. * @hidden
  52720. */
  52721. _previousTransformationMatrices: {
  52722. [index: number]: Matrix;
  52723. };
  52724. private _scene;
  52725. private _multiRenderTarget;
  52726. private _ratio;
  52727. private _enablePosition;
  52728. private _enableVelocity;
  52729. private _positionIndex;
  52730. private _velocityIndex;
  52731. protected _effect: Effect;
  52732. protected _cachedDefines: string;
  52733. /**
  52734. * Set the render list (meshes to be rendered) used in the G buffer.
  52735. */
  52736. renderList: Mesh[];
  52737. /**
  52738. * Gets wether or not G buffer are supported by the running hardware.
  52739. * This requires draw buffer supports
  52740. */
  52741. readonly isSupported: boolean;
  52742. /**
  52743. * Returns the index of the given texture type in the G-Buffer textures array
  52744. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52745. * @returns the index of the given texture type in the G-Buffer textures array
  52746. */
  52747. getTextureIndex(textureType: number): number;
  52748. /**
  52749. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52750. */
  52751. /**
  52752. * Sets whether or not objects positions are enabled for the G buffer.
  52753. */
  52754. enablePosition: boolean;
  52755. /**
  52756. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52757. */
  52758. /**
  52759. * Sets wether or not objects velocities are enabled for the G buffer.
  52760. */
  52761. enableVelocity: boolean;
  52762. /**
  52763. * Gets the scene associated with the buffer.
  52764. */
  52765. readonly scene: Scene;
  52766. /**
  52767. * Gets the ratio used by the buffer during its creation.
  52768. * How big is the buffer related to the main canvas.
  52769. */
  52770. readonly ratio: number;
  52771. /** @hidden */
  52772. static _SceneComponentInitialization: (scene: Scene) => void;
  52773. /**
  52774. * Creates a new G Buffer for the scene
  52775. * @param scene The scene the buffer belongs to
  52776. * @param ratio How big is the buffer related to the main canvas.
  52777. */
  52778. constructor(scene: Scene, ratio?: number);
  52779. /**
  52780. * Checks wether everything is ready to render a submesh to the G buffer.
  52781. * @param subMesh the submesh to check readiness for
  52782. * @param useInstances is the mesh drawn using instance or not
  52783. * @returns true if ready otherwise false
  52784. */
  52785. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52786. /**
  52787. * Gets the current underlying G Buffer.
  52788. * @returns the buffer
  52789. */
  52790. getGBuffer(): MultiRenderTarget;
  52791. /**
  52792. * Gets the number of samples used to render the buffer (anti aliasing).
  52793. */
  52794. /**
  52795. * Sets the number of samples used to render the buffer (anti aliasing).
  52796. */
  52797. samples: number;
  52798. /**
  52799. * Disposes the renderer and frees up associated resources.
  52800. */
  52801. dispose(): void;
  52802. protected _createRenderTargets(): void;
  52803. }
  52804. }
  52805. declare module BABYLON {
  52806. interface Scene {
  52807. /** @hidden (Backing field) */
  52808. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52809. /**
  52810. * Gets or Sets the current geometry buffer associated to the scene.
  52811. */
  52812. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52813. /**
  52814. * Enables a GeometryBufferRender and associates it with the scene
  52815. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52816. * @returns the GeometryBufferRenderer
  52817. */
  52818. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52819. /**
  52820. * Disables the GeometryBufferRender associated with the scene
  52821. */
  52822. disableGeometryBufferRenderer(): void;
  52823. }
  52824. /**
  52825. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52826. * in several rendering techniques.
  52827. */
  52828. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52829. /**
  52830. * The component name helpful to identify the component in the list of scene components.
  52831. */
  52832. readonly name: string;
  52833. /**
  52834. * The scene the component belongs to.
  52835. */
  52836. scene: Scene;
  52837. /**
  52838. * Creates a new instance of the component for the given scene
  52839. * @param scene Defines the scene to register the component in
  52840. */
  52841. constructor(scene: Scene);
  52842. /**
  52843. * Registers the component in a given scene
  52844. */
  52845. register(): void;
  52846. /**
  52847. * Rebuilds the elements related to this component in case of
  52848. * context lost for instance.
  52849. */
  52850. rebuild(): void;
  52851. /**
  52852. * Disposes the component and the associated ressources
  52853. */
  52854. dispose(): void;
  52855. private _gatherRenderTargets;
  52856. }
  52857. }
  52858. declare module BABYLON {
  52859. /** @hidden */
  52860. export var motionBlurPixelShader: {
  52861. name: string;
  52862. shader: string;
  52863. };
  52864. }
  52865. declare module BABYLON {
  52866. /**
  52867. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52868. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52869. * As an example, all you have to do is to create the post-process:
  52870. * var mb = new BABYLON.MotionBlurPostProcess(
  52871. * 'mb', // The name of the effect.
  52872. * scene, // The scene containing the objects to blur according to their velocity.
  52873. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52874. * camera // The camera to apply the render pass to.
  52875. * );
  52876. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52877. */
  52878. export class MotionBlurPostProcess extends PostProcess {
  52879. /**
  52880. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52881. */
  52882. motionStrength: number;
  52883. /**
  52884. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52885. */
  52886. /**
  52887. * Sets the number of iterations to be used for motion blur quality
  52888. */
  52889. motionBlurSamples: number;
  52890. private _motionBlurSamples;
  52891. private _geometryBufferRenderer;
  52892. /**
  52893. * Creates a new instance MotionBlurPostProcess
  52894. * @param name The name of the effect.
  52895. * @param scene The scene containing the objects to blur according to their velocity.
  52896. * @param options The required width/height ratio to downsize to before computing the render pass.
  52897. * @param camera The camera to apply the render pass to.
  52898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52899. * @param engine The engine which the post process will be applied. (default: current engine)
  52900. * @param reusable If the post process can be reused on the same frame. (default: false)
  52901. * @param textureType Type of textures used when performing the post process. (default: 0)
  52902. * @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)
  52903. */
  52904. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52905. /**
  52906. * Disposes the post process.
  52907. * @param camera The camera to dispose the post process on.
  52908. */
  52909. dispose(camera?: Camera): void;
  52910. }
  52911. }
  52912. declare module BABYLON {
  52913. /** @hidden */
  52914. export var refractionPixelShader: {
  52915. name: string;
  52916. shader: string;
  52917. };
  52918. }
  52919. declare module BABYLON {
  52920. /**
  52921. * Post process which applies a refractin texture
  52922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52923. */
  52924. export class RefractionPostProcess extends PostProcess {
  52925. /** the base color of the refraction (used to taint the rendering) */
  52926. color: Color3;
  52927. /** simulated refraction depth */
  52928. depth: number;
  52929. /** the coefficient of the base color (0 to remove base color tainting) */
  52930. colorLevel: number;
  52931. private _refTexture;
  52932. private _ownRefractionTexture;
  52933. /**
  52934. * Gets or sets the refraction texture
  52935. * Please note that you are responsible for disposing the texture if you set it manually
  52936. */
  52937. refractionTexture: Texture;
  52938. /**
  52939. * Initializes the RefractionPostProcess
  52940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52941. * @param name The name of the effect.
  52942. * @param refractionTextureUrl Url of the refraction texture to use
  52943. * @param color the base color of the refraction (used to taint the rendering)
  52944. * @param depth simulated refraction depth
  52945. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52946. * @param camera The camera to apply the render pass to.
  52947. * @param options The required width/height ratio to downsize to before computing the render pass.
  52948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52949. * @param engine The engine which the post process will be applied. (default: current engine)
  52950. * @param reusable If the post process can be reused on the same frame. (default: false)
  52951. */
  52952. constructor(name: string, refractionTextureUrl: string,
  52953. /** the base color of the refraction (used to taint the rendering) */
  52954. color: Color3,
  52955. /** simulated refraction depth */
  52956. depth: number,
  52957. /** the coefficient of the base color (0 to remove base color tainting) */
  52958. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52959. /**
  52960. * Disposes of the post process
  52961. * @param camera Camera to dispose post process on
  52962. */
  52963. dispose(camera: Camera): void;
  52964. }
  52965. }
  52966. declare module BABYLON {
  52967. /** @hidden */
  52968. export var sharpenPixelShader: {
  52969. name: string;
  52970. shader: string;
  52971. };
  52972. }
  52973. declare module BABYLON {
  52974. /**
  52975. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52976. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52977. */
  52978. export class SharpenPostProcess extends PostProcess {
  52979. /**
  52980. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52981. */
  52982. colorAmount: number;
  52983. /**
  52984. * How much sharpness should be applied (default: 0.3)
  52985. */
  52986. edgeAmount: number;
  52987. /**
  52988. * Creates a new instance ConvolutionPostProcess
  52989. * @param name The name of the effect.
  52990. * @param options The required width/height ratio to downsize to before computing the render pass.
  52991. * @param camera The camera to apply the render pass to.
  52992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52993. * @param engine The engine which the post process will be applied. (default: current engine)
  52994. * @param reusable If the post process can be reused on the same frame. (default: false)
  52995. * @param textureType Type of textures used when performing the post process. (default: 0)
  52996. * @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)
  52997. */
  52998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52999. }
  53000. }
  53001. declare module BABYLON {
  53002. /**
  53003. * PostProcessRenderPipeline
  53004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53005. */
  53006. export class PostProcessRenderPipeline {
  53007. private engine;
  53008. private _renderEffects;
  53009. private _renderEffectsForIsolatedPass;
  53010. /**
  53011. * List of inspectable custom properties (used by the Inspector)
  53012. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53013. */
  53014. inspectableCustomProperties: IInspectable[];
  53015. /**
  53016. * @hidden
  53017. */
  53018. protected _cameras: Camera[];
  53019. /** @hidden */
  53020. _name: string;
  53021. /**
  53022. * Gets pipeline name
  53023. */
  53024. readonly name: string;
  53025. /**
  53026. * Initializes a PostProcessRenderPipeline
  53027. * @param engine engine to add the pipeline to
  53028. * @param name name of the pipeline
  53029. */
  53030. constructor(engine: Engine, name: string);
  53031. /**
  53032. * Gets the class name
  53033. * @returns "PostProcessRenderPipeline"
  53034. */
  53035. getClassName(): string;
  53036. /**
  53037. * If all the render effects in the pipeline are supported
  53038. */
  53039. readonly isSupported: boolean;
  53040. /**
  53041. * Adds an effect to the pipeline
  53042. * @param renderEffect the effect to add
  53043. */
  53044. addEffect(renderEffect: PostProcessRenderEffect): void;
  53045. /** @hidden */
  53046. _rebuild(): void;
  53047. /** @hidden */
  53048. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53049. /** @hidden */
  53050. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53051. /** @hidden */
  53052. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53053. /** @hidden */
  53054. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53055. /** @hidden */
  53056. _attachCameras(cameras: Camera, unique: boolean): void;
  53057. /** @hidden */
  53058. _attachCameras(cameras: Camera[], unique: boolean): void;
  53059. /** @hidden */
  53060. _detachCameras(cameras: Camera): void;
  53061. /** @hidden */
  53062. _detachCameras(cameras: Nullable<Camera[]>): void;
  53063. /** @hidden */
  53064. _update(): void;
  53065. /** @hidden */
  53066. _reset(): void;
  53067. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53068. /**
  53069. * Disposes of the pipeline
  53070. */
  53071. dispose(): void;
  53072. }
  53073. }
  53074. declare module BABYLON {
  53075. /**
  53076. * PostProcessRenderPipelineManager class
  53077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53078. */
  53079. export class PostProcessRenderPipelineManager {
  53080. private _renderPipelines;
  53081. /**
  53082. * Initializes a PostProcessRenderPipelineManager
  53083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53084. */
  53085. constructor();
  53086. /**
  53087. * Gets the list of supported render pipelines
  53088. */
  53089. readonly supportedPipelines: PostProcessRenderPipeline[];
  53090. /**
  53091. * Adds a pipeline to the manager
  53092. * @param renderPipeline The pipeline to add
  53093. */
  53094. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53095. /**
  53096. * Attaches a camera to the pipeline
  53097. * @param renderPipelineName The name of the pipeline to attach to
  53098. * @param cameras the camera to attach
  53099. * @param unique if the camera can be attached multiple times to the pipeline
  53100. */
  53101. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53102. /**
  53103. * Detaches a camera from the pipeline
  53104. * @param renderPipelineName The name of the pipeline to detach from
  53105. * @param cameras the camera to detach
  53106. */
  53107. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53108. /**
  53109. * Enables an effect by name on a pipeline
  53110. * @param renderPipelineName the name of the pipeline to enable the effect in
  53111. * @param renderEffectName the name of the effect to enable
  53112. * @param cameras the cameras that the effect should be enabled on
  53113. */
  53114. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53115. /**
  53116. * Disables an effect by name on a pipeline
  53117. * @param renderPipelineName the name of the pipeline to disable the effect in
  53118. * @param renderEffectName the name of the effect to disable
  53119. * @param cameras the cameras that the effect should be disabled on
  53120. */
  53121. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53122. /**
  53123. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53124. */
  53125. update(): void;
  53126. /** @hidden */
  53127. _rebuild(): void;
  53128. /**
  53129. * Disposes of the manager and pipelines
  53130. */
  53131. dispose(): void;
  53132. }
  53133. }
  53134. declare module BABYLON {
  53135. interface Scene {
  53136. /** @hidden (Backing field) */
  53137. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53138. /**
  53139. * Gets the postprocess render pipeline manager
  53140. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53141. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53142. */
  53143. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53144. }
  53145. /**
  53146. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53147. */
  53148. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53149. /**
  53150. * The component name helpfull to identify the component in the list of scene components.
  53151. */
  53152. readonly name: string;
  53153. /**
  53154. * The scene the component belongs to.
  53155. */
  53156. scene: Scene;
  53157. /**
  53158. * Creates a new instance of the component for the given scene
  53159. * @param scene Defines the scene to register the component in
  53160. */
  53161. constructor(scene: Scene);
  53162. /**
  53163. * Registers the component in a given scene
  53164. */
  53165. register(): void;
  53166. /**
  53167. * Rebuilds the elements related to this component in case of
  53168. * context lost for instance.
  53169. */
  53170. rebuild(): void;
  53171. /**
  53172. * Disposes the component and the associated ressources
  53173. */
  53174. dispose(): void;
  53175. private _gatherRenderTargets;
  53176. }
  53177. }
  53178. declare module BABYLON {
  53179. /**
  53180. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53181. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53182. */
  53183. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53184. private _scene;
  53185. private _camerasToBeAttached;
  53186. /**
  53187. * ID of the sharpen post process,
  53188. */
  53189. private readonly SharpenPostProcessId;
  53190. /**
  53191. * @ignore
  53192. * ID of the image processing post process;
  53193. */
  53194. readonly ImageProcessingPostProcessId: string;
  53195. /**
  53196. * @ignore
  53197. * ID of the Fast Approximate Anti-Aliasing post process;
  53198. */
  53199. readonly FxaaPostProcessId: string;
  53200. /**
  53201. * ID of the chromatic aberration post process,
  53202. */
  53203. private readonly ChromaticAberrationPostProcessId;
  53204. /**
  53205. * ID of the grain post process
  53206. */
  53207. private readonly GrainPostProcessId;
  53208. /**
  53209. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53210. */
  53211. sharpen: SharpenPostProcess;
  53212. private _sharpenEffect;
  53213. private bloom;
  53214. /**
  53215. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53216. */
  53217. depthOfField: DepthOfFieldEffect;
  53218. /**
  53219. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53220. */
  53221. fxaa: FxaaPostProcess;
  53222. /**
  53223. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53224. */
  53225. imageProcessing: ImageProcessingPostProcess;
  53226. /**
  53227. * Chromatic aberration post process which will shift rgb colors in the image
  53228. */
  53229. chromaticAberration: ChromaticAberrationPostProcess;
  53230. private _chromaticAberrationEffect;
  53231. /**
  53232. * Grain post process which add noise to the image
  53233. */
  53234. grain: GrainPostProcess;
  53235. private _grainEffect;
  53236. /**
  53237. * Glow post process which adds a glow to emissive areas of the image
  53238. */
  53239. private _glowLayer;
  53240. /**
  53241. * Animations which can be used to tweak settings over a period of time
  53242. */
  53243. animations: Animation[];
  53244. private _imageProcessingConfigurationObserver;
  53245. private _sharpenEnabled;
  53246. private _bloomEnabled;
  53247. private _depthOfFieldEnabled;
  53248. private _depthOfFieldBlurLevel;
  53249. private _fxaaEnabled;
  53250. private _imageProcessingEnabled;
  53251. private _defaultPipelineTextureType;
  53252. private _bloomScale;
  53253. private _chromaticAberrationEnabled;
  53254. private _grainEnabled;
  53255. private _buildAllowed;
  53256. /**
  53257. * Gets active scene
  53258. */
  53259. readonly scene: Scene;
  53260. /**
  53261. * Enable or disable the sharpen process from the pipeline
  53262. */
  53263. sharpenEnabled: boolean;
  53264. private _resizeObserver;
  53265. private _hardwareScaleLevel;
  53266. private _bloomKernel;
  53267. /**
  53268. * Specifies the size of the bloom blur kernel, relative to the final output size
  53269. */
  53270. bloomKernel: number;
  53271. /**
  53272. * Specifies the weight of the bloom in the final rendering
  53273. */
  53274. private _bloomWeight;
  53275. /**
  53276. * Specifies the luma threshold for the area that will be blurred by the bloom
  53277. */
  53278. private _bloomThreshold;
  53279. private _hdr;
  53280. /**
  53281. * The strength of the bloom.
  53282. */
  53283. bloomWeight: number;
  53284. /**
  53285. * The strength of the bloom.
  53286. */
  53287. bloomThreshold: number;
  53288. /**
  53289. * The scale of the bloom, lower value will provide better performance.
  53290. */
  53291. bloomScale: number;
  53292. /**
  53293. * Enable or disable the bloom from the pipeline
  53294. */
  53295. bloomEnabled: boolean;
  53296. private _rebuildBloom;
  53297. /**
  53298. * If the depth of field is enabled.
  53299. */
  53300. depthOfFieldEnabled: boolean;
  53301. /**
  53302. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53303. */
  53304. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53305. /**
  53306. * If the anti aliasing is enabled.
  53307. */
  53308. fxaaEnabled: boolean;
  53309. private _samples;
  53310. /**
  53311. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53312. */
  53313. samples: number;
  53314. /**
  53315. * If image processing is enabled.
  53316. */
  53317. imageProcessingEnabled: boolean;
  53318. /**
  53319. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53320. */
  53321. glowLayerEnabled: boolean;
  53322. /**
  53323. * Enable or disable the chromaticAberration process from the pipeline
  53324. */
  53325. chromaticAberrationEnabled: boolean;
  53326. /**
  53327. * Enable or disable the grain process from the pipeline
  53328. */
  53329. grainEnabled: boolean;
  53330. /**
  53331. * @constructor
  53332. * @param name - The rendering pipeline name (default: "")
  53333. * @param hdr - If high dynamic range textures should be used (default: true)
  53334. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53335. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53336. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53337. */
  53338. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53339. /**
  53340. * Get the class name
  53341. * @returns "DefaultRenderingPipeline"
  53342. */
  53343. getClassName(): string;
  53344. /**
  53345. * Force the compilation of the entire pipeline.
  53346. */
  53347. prepare(): void;
  53348. private _hasCleared;
  53349. private _prevPostProcess;
  53350. private _prevPrevPostProcess;
  53351. private _setAutoClearAndTextureSharing;
  53352. private _depthOfFieldSceneObserver;
  53353. private _buildPipeline;
  53354. private _disposePostProcesses;
  53355. /**
  53356. * Adds a camera to the pipeline
  53357. * @param camera the camera to be added
  53358. */
  53359. addCamera(camera: Camera): void;
  53360. /**
  53361. * Removes a camera from the pipeline
  53362. * @param camera the camera to remove
  53363. */
  53364. removeCamera(camera: Camera): void;
  53365. /**
  53366. * Dispose of the pipeline and stop all post processes
  53367. */
  53368. dispose(): void;
  53369. /**
  53370. * Serialize the rendering pipeline (Used when exporting)
  53371. * @returns the serialized object
  53372. */
  53373. serialize(): any;
  53374. /**
  53375. * Parse the serialized pipeline
  53376. * @param source Source pipeline.
  53377. * @param scene The scene to load the pipeline to.
  53378. * @param rootUrl The URL of the serialized pipeline.
  53379. * @returns An instantiated pipeline from the serialized object.
  53380. */
  53381. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53382. }
  53383. }
  53384. declare module BABYLON {
  53385. /** @hidden */
  53386. export var lensHighlightsPixelShader: {
  53387. name: string;
  53388. shader: string;
  53389. };
  53390. }
  53391. declare module BABYLON {
  53392. /** @hidden */
  53393. export var depthOfFieldPixelShader: {
  53394. name: string;
  53395. shader: string;
  53396. };
  53397. }
  53398. declare module BABYLON {
  53399. /**
  53400. * BABYLON.JS Chromatic Aberration GLSL Shader
  53401. * Author: Olivier Guyot
  53402. * Separates very slightly R, G and B colors on the edges of the screen
  53403. * Inspired by Francois Tarlier & Martins Upitis
  53404. */
  53405. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53406. /**
  53407. * @ignore
  53408. * The chromatic aberration PostProcess id in the pipeline
  53409. */
  53410. LensChromaticAberrationEffect: string;
  53411. /**
  53412. * @ignore
  53413. * The highlights enhancing PostProcess id in the pipeline
  53414. */
  53415. HighlightsEnhancingEffect: string;
  53416. /**
  53417. * @ignore
  53418. * The depth-of-field PostProcess id in the pipeline
  53419. */
  53420. LensDepthOfFieldEffect: string;
  53421. private _scene;
  53422. private _depthTexture;
  53423. private _grainTexture;
  53424. private _chromaticAberrationPostProcess;
  53425. private _highlightsPostProcess;
  53426. private _depthOfFieldPostProcess;
  53427. private _edgeBlur;
  53428. private _grainAmount;
  53429. private _chromaticAberration;
  53430. private _distortion;
  53431. private _highlightsGain;
  53432. private _highlightsThreshold;
  53433. private _dofDistance;
  53434. private _dofAperture;
  53435. private _dofDarken;
  53436. private _dofPentagon;
  53437. private _blurNoise;
  53438. /**
  53439. * @constructor
  53440. *
  53441. * Effect parameters are as follow:
  53442. * {
  53443. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53444. * edge_blur: number; // from 0 to x (1 for realism)
  53445. * distortion: number; // from 0 to x (1 for realism)
  53446. * grain_amount: number; // from 0 to 1
  53447. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53448. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53449. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53450. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53451. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53452. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53453. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53454. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53455. * }
  53456. * Note: if an effect parameter is unset, effect is disabled
  53457. *
  53458. * @param name The rendering pipeline name
  53459. * @param parameters - An object containing all parameters (see above)
  53460. * @param scene The scene linked to this pipeline
  53461. * @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)
  53462. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53463. */
  53464. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53465. /**
  53466. * Get the class name
  53467. * @returns "LensRenderingPipeline"
  53468. */
  53469. getClassName(): string;
  53470. /**
  53471. * Gets associated scene
  53472. */
  53473. readonly scene: Scene;
  53474. /**
  53475. * Gets or sets the edge blur
  53476. */
  53477. edgeBlur: number;
  53478. /**
  53479. * Gets or sets the grain amount
  53480. */
  53481. grainAmount: number;
  53482. /**
  53483. * Gets or sets the chromatic aberration amount
  53484. */
  53485. chromaticAberration: number;
  53486. /**
  53487. * Gets or sets the depth of field aperture
  53488. */
  53489. dofAperture: number;
  53490. /**
  53491. * Gets or sets the edge distortion
  53492. */
  53493. edgeDistortion: number;
  53494. /**
  53495. * Gets or sets the depth of field distortion
  53496. */
  53497. dofDistortion: number;
  53498. /**
  53499. * Gets or sets the darken out of focus amount
  53500. */
  53501. darkenOutOfFocus: number;
  53502. /**
  53503. * Gets or sets a boolean indicating if blur noise is enabled
  53504. */
  53505. blurNoise: boolean;
  53506. /**
  53507. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53508. */
  53509. pentagonBokeh: boolean;
  53510. /**
  53511. * Gets or sets the highlight grain amount
  53512. */
  53513. highlightsGain: number;
  53514. /**
  53515. * Gets or sets the highlight threshold
  53516. */
  53517. highlightsThreshold: number;
  53518. /**
  53519. * Sets the amount of blur at the edges
  53520. * @param amount blur amount
  53521. */
  53522. setEdgeBlur(amount: number): void;
  53523. /**
  53524. * Sets edge blur to 0
  53525. */
  53526. disableEdgeBlur(): void;
  53527. /**
  53528. * Sets the amout of grain
  53529. * @param amount Amount of grain
  53530. */
  53531. setGrainAmount(amount: number): void;
  53532. /**
  53533. * Set grain amount to 0
  53534. */
  53535. disableGrain(): void;
  53536. /**
  53537. * Sets the chromatic aberration amount
  53538. * @param amount amount of chromatic aberration
  53539. */
  53540. setChromaticAberration(amount: number): void;
  53541. /**
  53542. * Sets chromatic aberration amount to 0
  53543. */
  53544. disableChromaticAberration(): void;
  53545. /**
  53546. * Sets the EdgeDistortion amount
  53547. * @param amount amount of EdgeDistortion
  53548. */
  53549. setEdgeDistortion(amount: number): void;
  53550. /**
  53551. * Sets edge distortion to 0
  53552. */
  53553. disableEdgeDistortion(): void;
  53554. /**
  53555. * Sets the FocusDistance amount
  53556. * @param amount amount of FocusDistance
  53557. */
  53558. setFocusDistance(amount: number): void;
  53559. /**
  53560. * Disables depth of field
  53561. */
  53562. disableDepthOfField(): void;
  53563. /**
  53564. * Sets the Aperture amount
  53565. * @param amount amount of Aperture
  53566. */
  53567. setAperture(amount: number): void;
  53568. /**
  53569. * Sets the DarkenOutOfFocus amount
  53570. * @param amount amount of DarkenOutOfFocus
  53571. */
  53572. setDarkenOutOfFocus(amount: number): void;
  53573. private _pentagonBokehIsEnabled;
  53574. /**
  53575. * Creates a pentagon bokeh effect
  53576. */
  53577. enablePentagonBokeh(): void;
  53578. /**
  53579. * Disables the pentagon bokeh effect
  53580. */
  53581. disablePentagonBokeh(): void;
  53582. /**
  53583. * Enables noise blur
  53584. */
  53585. enableNoiseBlur(): void;
  53586. /**
  53587. * Disables noise blur
  53588. */
  53589. disableNoiseBlur(): void;
  53590. /**
  53591. * Sets the HighlightsGain amount
  53592. * @param amount amount of HighlightsGain
  53593. */
  53594. setHighlightsGain(amount: number): void;
  53595. /**
  53596. * Sets the HighlightsThreshold amount
  53597. * @param amount amount of HighlightsThreshold
  53598. */
  53599. setHighlightsThreshold(amount: number): void;
  53600. /**
  53601. * Disables highlights
  53602. */
  53603. disableHighlights(): void;
  53604. /**
  53605. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53606. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53607. */
  53608. dispose(disableDepthRender?: boolean): void;
  53609. private _createChromaticAberrationPostProcess;
  53610. private _createHighlightsPostProcess;
  53611. private _createDepthOfFieldPostProcess;
  53612. private _createGrainTexture;
  53613. }
  53614. }
  53615. declare module BABYLON {
  53616. /** @hidden */
  53617. export var ssao2PixelShader: {
  53618. name: string;
  53619. shader: string;
  53620. };
  53621. }
  53622. declare module BABYLON {
  53623. /** @hidden */
  53624. export var ssaoCombinePixelShader: {
  53625. name: string;
  53626. shader: string;
  53627. };
  53628. }
  53629. declare module BABYLON {
  53630. /**
  53631. * Render pipeline to produce ssao effect
  53632. */
  53633. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53634. /**
  53635. * @ignore
  53636. * The PassPostProcess id in the pipeline that contains the original scene color
  53637. */
  53638. SSAOOriginalSceneColorEffect: string;
  53639. /**
  53640. * @ignore
  53641. * The SSAO PostProcess id in the pipeline
  53642. */
  53643. SSAORenderEffect: string;
  53644. /**
  53645. * @ignore
  53646. * The horizontal blur PostProcess id in the pipeline
  53647. */
  53648. SSAOBlurHRenderEffect: string;
  53649. /**
  53650. * @ignore
  53651. * The vertical blur PostProcess id in the pipeline
  53652. */
  53653. SSAOBlurVRenderEffect: string;
  53654. /**
  53655. * @ignore
  53656. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53657. */
  53658. SSAOCombineRenderEffect: string;
  53659. /**
  53660. * The output strength of the SSAO post-process. Default value is 1.0.
  53661. */
  53662. totalStrength: number;
  53663. /**
  53664. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53665. */
  53666. maxZ: number;
  53667. /**
  53668. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53669. */
  53670. minZAspect: number;
  53671. private _samples;
  53672. /**
  53673. * Number of samples used for the SSAO calculations. Default value is 8
  53674. */
  53675. samples: number;
  53676. private _textureSamples;
  53677. /**
  53678. * Number of samples to use for antialiasing
  53679. */
  53680. textureSamples: number;
  53681. /**
  53682. * Ratio object used for SSAO ratio and blur ratio
  53683. */
  53684. private _ratio;
  53685. /**
  53686. * Dynamically generated sphere sampler.
  53687. */
  53688. private _sampleSphere;
  53689. /**
  53690. * Blur filter offsets
  53691. */
  53692. private _samplerOffsets;
  53693. private _expensiveBlur;
  53694. /**
  53695. * If bilateral blur should be used
  53696. */
  53697. expensiveBlur: boolean;
  53698. /**
  53699. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53700. */
  53701. radius: number;
  53702. /**
  53703. * The base color of the SSAO post-process
  53704. * The final result is "base + ssao" between [0, 1]
  53705. */
  53706. base: number;
  53707. /**
  53708. * Support test.
  53709. */
  53710. static readonly IsSupported: boolean;
  53711. private _scene;
  53712. private _depthTexture;
  53713. private _normalTexture;
  53714. private _randomTexture;
  53715. private _originalColorPostProcess;
  53716. private _ssaoPostProcess;
  53717. private _blurHPostProcess;
  53718. private _blurVPostProcess;
  53719. private _ssaoCombinePostProcess;
  53720. private _firstUpdate;
  53721. /**
  53722. * Gets active scene
  53723. */
  53724. readonly scene: Scene;
  53725. /**
  53726. * @constructor
  53727. * @param name The rendering pipeline name
  53728. * @param scene The scene linked to this pipeline
  53729. * @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 }
  53730. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53731. */
  53732. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53733. /**
  53734. * Get the class name
  53735. * @returns "SSAO2RenderingPipeline"
  53736. */
  53737. getClassName(): string;
  53738. /**
  53739. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53740. */
  53741. dispose(disableGeometryBufferRenderer?: boolean): void;
  53742. private _createBlurPostProcess;
  53743. /** @hidden */
  53744. _rebuild(): void;
  53745. private _bits;
  53746. private _radicalInverse_VdC;
  53747. private _hammersley;
  53748. private _hemisphereSample_uniform;
  53749. private _generateHemisphere;
  53750. private _createSSAOPostProcess;
  53751. private _createSSAOCombinePostProcess;
  53752. private _createRandomTexture;
  53753. /**
  53754. * Serialize the rendering pipeline (Used when exporting)
  53755. * @returns the serialized object
  53756. */
  53757. serialize(): any;
  53758. /**
  53759. * Parse the serialized pipeline
  53760. * @param source Source pipeline.
  53761. * @param scene The scene to load the pipeline to.
  53762. * @param rootUrl The URL of the serialized pipeline.
  53763. * @returns An instantiated pipeline from the serialized object.
  53764. */
  53765. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /** @hidden */
  53770. export var ssaoPixelShader: {
  53771. name: string;
  53772. shader: string;
  53773. };
  53774. }
  53775. declare module BABYLON {
  53776. /**
  53777. * Render pipeline to produce ssao effect
  53778. */
  53779. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53780. /**
  53781. * @ignore
  53782. * The PassPostProcess id in the pipeline that contains the original scene color
  53783. */
  53784. SSAOOriginalSceneColorEffect: string;
  53785. /**
  53786. * @ignore
  53787. * The SSAO PostProcess id in the pipeline
  53788. */
  53789. SSAORenderEffect: string;
  53790. /**
  53791. * @ignore
  53792. * The horizontal blur PostProcess id in the pipeline
  53793. */
  53794. SSAOBlurHRenderEffect: string;
  53795. /**
  53796. * @ignore
  53797. * The vertical blur PostProcess id in the pipeline
  53798. */
  53799. SSAOBlurVRenderEffect: string;
  53800. /**
  53801. * @ignore
  53802. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53803. */
  53804. SSAOCombineRenderEffect: string;
  53805. /**
  53806. * The output strength of the SSAO post-process. Default value is 1.0.
  53807. */
  53808. totalStrength: number;
  53809. /**
  53810. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53811. */
  53812. radius: number;
  53813. /**
  53814. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53815. * Must not be equal to fallOff and superior to fallOff.
  53816. * Default value is 0.0075
  53817. */
  53818. area: number;
  53819. /**
  53820. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53821. * Must not be equal to area and inferior to area.
  53822. * Default value is 0.000001
  53823. */
  53824. fallOff: number;
  53825. /**
  53826. * The base color of the SSAO post-process
  53827. * The final result is "base + ssao" between [0, 1]
  53828. */
  53829. base: number;
  53830. private _scene;
  53831. private _depthTexture;
  53832. private _randomTexture;
  53833. private _originalColorPostProcess;
  53834. private _ssaoPostProcess;
  53835. private _blurHPostProcess;
  53836. private _blurVPostProcess;
  53837. private _ssaoCombinePostProcess;
  53838. private _firstUpdate;
  53839. /**
  53840. * Gets active scene
  53841. */
  53842. readonly scene: Scene;
  53843. /**
  53844. * @constructor
  53845. * @param name - The rendering pipeline name
  53846. * @param scene - The scene linked to this pipeline
  53847. * @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 }
  53848. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53849. */
  53850. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53851. /**
  53852. * Get the class name
  53853. * @returns "SSAORenderingPipeline"
  53854. */
  53855. getClassName(): string;
  53856. /**
  53857. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53858. */
  53859. dispose(disableDepthRender?: boolean): void;
  53860. private _createBlurPostProcess;
  53861. /** @hidden */
  53862. _rebuild(): void;
  53863. private _createSSAOPostProcess;
  53864. private _createSSAOCombinePostProcess;
  53865. private _createRandomTexture;
  53866. }
  53867. }
  53868. declare module BABYLON {
  53869. /** @hidden */
  53870. export var standardPixelShader: {
  53871. name: string;
  53872. shader: string;
  53873. };
  53874. }
  53875. declare module BABYLON {
  53876. /**
  53877. * Standard rendering pipeline
  53878. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53879. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53880. */
  53881. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53882. /**
  53883. * Public members
  53884. */
  53885. /**
  53886. * Post-process which contains the original scene color before the pipeline applies all the effects
  53887. */
  53888. originalPostProcess: Nullable<PostProcess>;
  53889. /**
  53890. * Post-process used to down scale an image x4
  53891. */
  53892. downSampleX4PostProcess: Nullable<PostProcess>;
  53893. /**
  53894. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53895. */
  53896. brightPassPostProcess: Nullable<PostProcess>;
  53897. /**
  53898. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53899. */
  53900. blurHPostProcesses: PostProcess[];
  53901. /**
  53902. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53903. */
  53904. blurVPostProcesses: PostProcess[];
  53905. /**
  53906. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53907. */
  53908. textureAdderPostProcess: Nullable<PostProcess>;
  53909. /**
  53910. * Post-process used to create volumetric lighting effect
  53911. */
  53912. volumetricLightPostProcess: Nullable<PostProcess>;
  53913. /**
  53914. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53915. */
  53916. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53917. /**
  53918. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53919. */
  53920. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53921. /**
  53922. * Post-process used to merge the volumetric light effect and the real scene color
  53923. */
  53924. volumetricLightMergePostProces: Nullable<PostProcess>;
  53925. /**
  53926. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53927. */
  53928. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53929. /**
  53930. * Base post-process used to calculate the average luminance of the final image for HDR
  53931. */
  53932. luminancePostProcess: Nullable<PostProcess>;
  53933. /**
  53934. * Post-processes used to create down sample post-processes in order to get
  53935. * the average luminance of the final image for HDR
  53936. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53937. */
  53938. luminanceDownSamplePostProcesses: PostProcess[];
  53939. /**
  53940. * Post-process used to create a HDR effect (light adaptation)
  53941. */
  53942. hdrPostProcess: Nullable<PostProcess>;
  53943. /**
  53944. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53945. */
  53946. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53947. /**
  53948. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53949. */
  53950. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53951. /**
  53952. * Post-process used to merge the final HDR post-process and the real scene color
  53953. */
  53954. hdrFinalPostProcess: Nullable<PostProcess>;
  53955. /**
  53956. * Post-process used to create a lens flare effect
  53957. */
  53958. lensFlarePostProcess: Nullable<PostProcess>;
  53959. /**
  53960. * Post-process that merges the result of the lens flare post-process and the real scene color
  53961. */
  53962. lensFlareComposePostProcess: Nullable<PostProcess>;
  53963. /**
  53964. * Post-process used to create a motion blur effect
  53965. */
  53966. motionBlurPostProcess: Nullable<PostProcess>;
  53967. /**
  53968. * Post-process used to create a depth of field effect
  53969. */
  53970. depthOfFieldPostProcess: Nullable<PostProcess>;
  53971. /**
  53972. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53973. */
  53974. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53975. /**
  53976. * Represents the brightness threshold in order to configure the illuminated surfaces
  53977. */
  53978. brightThreshold: number;
  53979. /**
  53980. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53981. */
  53982. blurWidth: number;
  53983. /**
  53984. * Sets if the blur for highlighted surfaces must be only horizontal
  53985. */
  53986. horizontalBlur: boolean;
  53987. /**
  53988. * Gets the overall exposure used by the pipeline
  53989. */
  53990. /**
  53991. * Sets the overall exposure used by the pipeline
  53992. */
  53993. exposure: number;
  53994. /**
  53995. * Texture used typically to simulate "dirty" on camera lens
  53996. */
  53997. lensTexture: Nullable<Texture>;
  53998. /**
  53999. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54000. */
  54001. volumetricLightCoefficient: number;
  54002. /**
  54003. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54004. */
  54005. volumetricLightPower: number;
  54006. /**
  54007. * Used the set the blur intensity to smooth the volumetric lights
  54008. */
  54009. volumetricLightBlurScale: number;
  54010. /**
  54011. * Light (spot or directional) used to generate the volumetric lights rays
  54012. * The source light must have a shadow generate so the pipeline can get its
  54013. * depth map
  54014. */
  54015. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54016. /**
  54017. * For eye adaptation, represents the minimum luminance the eye can see
  54018. */
  54019. hdrMinimumLuminance: number;
  54020. /**
  54021. * For eye adaptation, represents the decrease luminance speed
  54022. */
  54023. hdrDecreaseRate: number;
  54024. /**
  54025. * For eye adaptation, represents the increase luminance speed
  54026. */
  54027. hdrIncreaseRate: number;
  54028. /**
  54029. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54030. */
  54031. /**
  54032. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54033. */
  54034. hdrAutoExposure: boolean;
  54035. /**
  54036. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54037. */
  54038. lensColorTexture: Nullable<Texture>;
  54039. /**
  54040. * The overall strengh for the lens flare effect
  54041. */
  54042. lensFlareStrength: number;
  54043. /**
  54044. * Dispersion coefficient for lens flare ghosts
  54045. */
  54046. lensFlareGhostDispersal: number;
  54047. /**
  54048. * Main lens flare halo width
  54049. */
  54050. lensFlareHaloWidth: number;
  54051. /**
  54052. * Based on the lens distortion effect, defines how much the lens flare result
  54053. * is distorted
  54054. */
  54055. lensFlareDistortionStrength: number;
  54056. /**
  54057. * Lens star texture must be used to simulate rays on the flares and is available
  54058. * in the documentation
  54059. */
  54060. lensStarTexture: Nullable<Texture>;
  54061. /**
  54062. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54063. * flare effect by taking account of the dirt texture
  54064. */
  54065. lensFlareDirtTexture: Nullable<Texture>;
  54066. /**
  54067. * Represents the focal length for the depth of field effect
  54068. */
  54069. depthOfFieldDistance: number;
  54070. /**
  54071. * Represents the blur intensity for the blurred part of the depth of field effect
  54072. */
  54073. depthOfFieldBlurWidth: number;
  54074. /**
  54075. * For motion blur, defines how much the image is blurred by the movement
  54076. */
  54077. motionStrength: number;
  54078. /**
  54079. * List of animations for the pipeline (IAnimatable implementation)
  54080. */
  54081. animations: Animation[];
  54082. /**
  54083. * Private members
  54084. */
  54085. private _scene;
  54086. private _currentDepthOfFieldSource;
  54087. private _basePostProcess;
  54088. private _fixedExposure;
  54089. private _currentExposure;
  54090. private _hdrAutoExposure;
  54091. private _hdrCurrentLuminance;
  54092. private _floatTextureType;
  54093. private _ratio;
  54094. private _bloomEnabled;
  54095. private _depthOfFieldEnabled;
  54096. private _vlsEnabled;
  54097. private _lensFlareEnabled;
  54098. private _hdrEnabled;
  54099. private _motionBlurEnabled;
  54100. private _fxaaEnabled;
  54101. private _motionBlurSamples;
  54102. private _volumetricLightStepsCount;
  54103. private _samples;
  54104. /**
  54105. * @ignore
  54106. * Specifies if the bloom pipeline is enabled
  54107. */
  54108. BloomEnabled: boolean;
  54109. /**
  54110. * @ignore
  54111. * Specifies if the depth of field pipeline is enabed
  54112. */
  54113. DepthOfFieldEnabled: boolean;
  54114. /**
  54115. * @ignore
  54116. * Specifies if the lens flare pipeline is enabed
  54117. */
  54118. LensFlareEnabled: boolean;
  54119. /**
  54120. * @ignore
  54121. * Specifies if the HDR pipeline is enabled
  54122. */
  54123. HDREnabled: boolean;
  54124. /**
  54125. * @ignore
  54126. * Specifies if the volumetric lights scattering effect is enabled
  54127. */
  54128. VLSEnabled: boolean;
  54129. /**
  54130. * @ignore
  54131. * Specifies if the motion blur effect is enabled
  54132. */
  54133. MotionBlurEnabled: boolean;
  54134. /**
  54135. * Specifies if anti-aliasing is enabled
  54136. */
  54137. fxaaEnabled: boolean;
  54138. /**
  54139. * Specifies the number of steps used to calculate the volumetric lights
  54140. * Typically in interval [50, 200]
  54141. */
  54142. volumetricLightStepsCount: number;
  54143. /**
  54144. * Specifies the number of samples used for the motion blur effect
  54145. * Typically in interval [16, 64]
  54146. */
  54147. motionBlurSamples: number;
  54148. /**
  54149. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54150. */
  54151. samples: number;
  54152. /**
  54153. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54154. * @constructor
  54155. * @param name The rendering pipeline name
  54156. * @param scene The scene linked to this pipeline
  54157. * @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)
  54158. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54159. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54160. */
  54161. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54162. private _buildPipeline;
  54163. private _createDownSampleX4PostProcess;
  54164. private _createBrightPassPostProcess;
  54165. private _createBlurPostProcesses;
  54166. private _createTextureAdderPostProcess;
  54167. private _createVolumetricLightPostProcess;
  54168. private _createLuminancePostProcesses;
  54169. private _createHdrPostProcess;
  54170. private _createLensFlarePostProcess;
  54171. private _createDepthOfFieldPostProcess;
  54172. private _createMotionBlurPostProcess;
  54173. private _getDepthTexture;
  54174. private _disposePostProcesses;
  54175. /**
  54176. * Dispose of the pipeline and stop all post processes
  54177. */
  54178. dispose(): void;
  54179. /**
  54180. * Serialize the rendering pipeline (Used when exporting)
  54181. * @returns the serialized object
  54182. */
  54183. serialize(): any;
  54184. /**
  54185. * Parse the serialized pipeline
  54186. * @param source Source pipeline.
  54187. * @param scene The scene to load the pipeline to.
  54188. * @param rootUrl The URL of the serialized pipeline.
  54189. * @returns An instantiated pipeline from the serialized object.
  54190. */
  54191. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54192. /**
  54193. * Luminance steps
  54194. */
  54195. static LuminanceSteps: number;
  54196. }
  54197. }
  54198. declare module BABYLON {
  54199. /** @hidden */
  54200. export var tonemapPixelShader: {
  54201. name: string;
  54202. shader: string;
  54203. };
  54204. }
  54205. declare module BABYLON {
  54206. /** Defines operator used for tonemapping */
  54207. export enum TonemappingOperator {
  54208. /** Hable */
  54209. Hable = 0,
  54210. /** Reinhard */
  54211. Reinhard = 1,
  54212. /** HejiDawson */
  54213. HejiDawson = 2,
  54214. /** Photographic */
  54215. Photographic = 3
  54216. }
  54217. /**
  54218. * Defines a post process to apply tone mapping
  54219. */
  54220. export class TonemapPostProcess extends PostProcess {
  54221. private _operator;
  54222. /** Defines the required exposure adjustement */
  54223. exposureAdjustment: number;
  54224. /**
  54225. * Creates a new TonemapPostProcess
  54226. * @param name defines the name of the postprocess
  54227. * @param _operator defines the operator to use
  54228. * @param exposureAdjustment defines the required exposure adjustement
  54229. * @param camera defines the camera to use (can be null)
  54230. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54231. * @param engine defines the hosting engine (can be ignore if camera is set)
  54232. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54233. */
  54234. constructor(name: string, _operator: TonemappingOperator,
  54235. /** Defines the required exposure adjustement */
  54236. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /** @hidden */
  54241. export var depthVertexShader: {
  54242. name: string;
  54243. shader: string;
  54244. };
  54245. }
  54246. declare module BABYLON {
  54247. /** @hidden */
  54248. export var volumetricLightScatteringPixelShader: {
  54249. name: string;
  54250. shader: string;
  54251. };
  54252. }
  54253. declare module BABYLON {
  54254. /** @hidden */
  54255. export var volumetricLightScatteringPassPixelShader: {
  54256. name: string;
  54257. shader: string;
  54258. };
  54259. }
  54260. declare module BABYLON {
  54261. /**
  54262. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54263. */
  54264. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54265. private _volumetricLightScatteringPass;
  54266. private _volumetricLightScatteringRTT;
  54267. private _viewPort;
  54268. private _screenCoordinates;
  54269. private _cachedDefines;
  54270. /**
  54271. * If not undefined, the mesh position is computed from the attached node position
  54272. */
  54273. attachedNode: {
  54274. position: Vector3;
  54275. };
  54276. /**
  54277. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54278. */
  54279. customMeshPosition: Vector3;
  54280. /**
  54281. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54282. */
  54283. useCustomMeshPosition: boolean;
  54284. /**
  54285. * If the post-process should inverse the light scattering direction
  54286. */
  54287. invert: boolean;
  54288. /**
  54289. * The internal mesh used by the post-process
  54290. */
  54291. mesh: Mesh;
  54292. /**
  54293. * @hidden
  54294. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54295. */
  54296. useDiffuseColor: boolean;
  54297. /**
  54298. * Array containing the excluded meshes not rendered in the internal pass
  54299. */
  54300. excludedMeshes: AbstractMesh[];
  54301. /**
  54302. * Controls the overall intensity of the post-process
  54303. */
  54304. exposure: number;
  54305. /**
  54306. * Dissipates each sample's contribution in range [0, 1]
  54307. */
  54308. decay: number;
  54309. /**
  54310. * Controls the overall intensity of each sample
  54311. */
  54312. weight: number;
  54313. /**
  54314. * Controls the density of each sample
  54315. */
  54316. density: number;
  54317. /**
  54318. * @constructor
  54319. * @param name The post-process name
  54320. * @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)
  54321. * @param camera The camera that the post-process will be attached to
  54322. * @param mesh The mesh used to create the light scattering
  54323. * @param samples The post-process quality, default 100
  54324. * @param samplingModeThe post-process filtering mode
  54325. * @param engine The babylon engine
  54326. * @param reusable If the post-process is reusable
  54327. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54328. */
  54329. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54330. /**
  54331. * Returns the string "VolumetricLightScatteringPostProcess"
  54332. * @returns "VolumetricLightScatteringPostProcess"
  54333. */
  54334. getClassName(): string;
  54335. private _isReady;
  54336. /**
  54337. * Sets the new light position for light scattering effect
  54338. * @param position The new custom light position
  54339. */
  54340. setCustomMeshPosition(position: Vector3): void;
  54341. /**
  54342. * Returns the light position for light scattering effect
  54343. * @return Vector3 The custom light position
  54344. */
  54345. getCustomMeshPosition(): Vector3;
  54346. /**
  54347. * Disposes the internal assets and detaches the post-process from the camera
  54348. */
  54349. dispose(camera: Camera): void;
  54350. /**
  54351. * Returns the render target texture used by the post-process
  54352. * @return the render target texture used by the post-process
  54353. */
  54354. getPass(): RenderTargetTexture;
  54355. private _meshExcluded;
  54356. private _createPass;
  54357. private _updateMeshScreenCoordinates;
  54358. /**
  54359. * Creates a default mesh for the Volumeric Light Scattering post-process
  54360. * @param name The mesh name
  54361. * @param scene The scene where to create the mesh
  54362. * @return the default mesh
  54363. */
  54364. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54365. }
  54366. }
  54367. declare module BABYLON {
  54368. interface Scene {
  54369. /** @hidden (Backing field) */
  54370. _boundingBoxRenderer: BoundingBoxRenderer;
  54371. /** @hidden (Backing field) */
  54372. _forceShowBoundingBoxes: boolean;
  54373. /**
  54374. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54375. */
  54376. forceShowBoundingBoxes: boolean;
  54377. /**
  54378. * Gets the bounding box renderer associated with the scene
  54379. * @returns a BoundingBoxRenderer
  54380. */
  54381. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54382. }
  54383. interface AbstractMesh {
  54384. /** @hidden (Backing field) */
  54385. _showBoundingBox: boolean;
  54386. /**
  54387. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54388. */
  54389. showBoundingBox: boolean;
  54390. }
  54391. /**
  54392. * Component responsible of rendering the bounding box of the meshes in a scene.
  54393. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54394. */
  54395. export class BoundingBoxRenderer implements ISceneComponent {
  54396. /**
  54397. * The component name helpfull to identify the component in the list of scene components.
  54398. */
  54399. readonly name: string;
  54400. /**
  54401. * The scene the component belongs to.
  54402. */
  54403. scene: Scene;
  54404. /**
  54405. * Color of the bounding box lines placed in front of an object
  54406. */
  54407. frontColor: Color3;
  54408. /**
  54409. * Color of the bounding box lines placed behind an object
  54410. */
  54411. backColor: Color3;
  54412. /**
  54413. * Defines if the renderer should show the back lines or not
  54414. */
  54415. showBackLines: boolean;
  54416. /**
  54417. * @hidden
  54418. */
  54419. renderList: SmartArray<BoundingBox>;
  54420. private _colorShader;
  54421. private _vertexBuffers;
  54422. private _indexBuffer;
  54423. /**
  54424. * Instantiates a new bounding box renderer in a scene.
  54425. * @param scene the scene the renderer renders in
  54426. */
  54427. constructor(scene: Scene);
  54428. /**
  54429. * Registers the component in a given scene
  54430. */
  54431. register(): void;
  54432. private _evaluateSubMesh;
  54433. private _activeMesh;
  54434. private _prepareRessources;
  54435. private _createIndexBuffer;
  54436. /**
  54437. * Rebuilds the elements related to this component in case of
  54438. * context lost for instance.
  54439. */
  54440. rebuild(): void;
  54441. /**
  54442. * @hidden
  54443. */
  54444. reset(): void;
  54445. /**
  54446. * Render the bounding boxes of a specific rendering group
  54447. * @param renderingGroupId defines the rendering group to render
  54448. */
  54449. render(renderingGroupId: number): void;
  54450. /**
  54451. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54452. * @param mesh Define the mesh to render the occlusion bounding box for
  54453. */
  54454. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54455. /**
  54456. * Dispose and release the resources attached to this renderer.
  54457. */
  54458. dispose(): void;
  54459. }
  54460. }
  54461. declare module BABYLON {
  54462. /** @hidden */
  54463. export var depthPixelShader: {
  54464. name: string;
  54465. shader: string;
  54466. };
  54467. }
  54468. declare module BABYLON {
  54469. /**
  54470. * This represents a depth renderer in Babylon.
  54471. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54472. */
  54473. export class DepthRenderer {
  54474. private _scene;
  54475. private _depthMap;
  54476. private _effect;
  54477. private _cachedDefines;
  54478. private _camera;
  54479. /**
  54480. * Specifiess that the depth renderer will only be used within
  54481. * the camera it is created for.
  54482. * This can help forcing its rendering during the camera processing.
  54483. */
  54484. useOnlyInActiveCamera: boolean;
  54485. /** @hidden */
  54486. static _SceneComponentInitialization: (scene: Scene) => void;
  54487. /**
  54488. * Instantiates a depth renderer
  54489. * @param scene The scene the renderer belongs to
  54490. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54491. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54492. */
  54493. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54494. /**
  54495. * Creates the depth rendering effect and checks if the effect is ready.
  54496. * @param subMesh The submesh to be used to render the depth map of
  54497. * @param useInstances If multiple world instances should be used
  54498. * @returns if the depth renderer is ready to render the depth map
  54499. */
  54500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54501. /**
  54502. * Gets the texture which the depth map will be written to.
  54503. * @returns The depth map texture
  54504. */
  54505. getDepthMap(): RenderTargetTexture;
  54506. /**
  54507. * Disposes of the depth renderer.
  54508. */
  54509. dispose(): void;
  54510. }
  54511. }
  54512. declare module BABYLON {
  54513. interface Scene {
  54514. /** @hidden (Backing field) */
  54515. _depthRenderer: {
  54516. [id: string]: DepthRenderer;
  54517. };
  54518. /**
  54519. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54520. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54521. * @returns the created depth renderer
  54522. */
  54523. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54524. /**
  54525. * Disables a depth renderer for a given camera
  54526. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54527. */
  54528. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54529. }
  54530. /**
  54531. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54532. * in several rendering techniques.
  54533. */
  54534. export class DepthRendererSceneComponent implements ISceneComponent {
  54535. /**
  54536. * The component name helpfull to identify the component in the list of scene components.
  54537. */
  54538. readonly name: string;
  54539. /**
  54540. * The scene the component belongs to.
  54541. */
  54542. scene: Scene;
  54543. /**
  54544. * Creates a new instance of the component for the given scene
  54545. * @param scene Defines the scene to register the component in
  54546. */
  54547. constructor(scene: Scene);
  54548. /**
  54549. * Registers the component in a given scene
  54550. */
  54551. register(): void;
  54552. /**
  54553. * Rebuilds the elements related to this component in case of
  54554. * context lost for instance.
  54555. */
  54556. rebuild(): void;
  54557. /**
  54558. * Disposes the component and the associated ressources
  54559. */
  54560. dispose(): void;
  54561. private _gatherRenderTargets;
  54562. private _gatherActiveCameraRenderTargets;
  54563. }
  54564. }
  54565. declare module BABYLON {
  54566. /** @hidden */
  54567. export var outlinePixelShader: {
  54568. name: string;
  54569. shader: string;
  54570. };
  54571. }
  54572. declare module BABYLON {
  54573. /** @hidden */
  54574. export var outlineVertexShader: {
  54575. name: string;
  54576. shader: string;
  54577. };
  54578. }
  54579. declare module BABYLON {
  54580. interface Scene {
  54581. /** @hidden */
  54582. _outlineRenderer: OutlineRenderer;
  54583. /**
  54584. * Gets the outline renderer associated with the scene
  54585. * @returns a OutlineRenderer
  54586. */
  54587. getOutlineRenderer(): OutlineRenderer;
  54588. }
  54589. interface AbstractMesh {
  54590. /** @hidden (Backing field) */
  54591. _renderOutline: boolean;
  54592. /**
  54593. * Gets or sets a boolean indicating if the outline must be rendered as well
  54594. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54595. */
  54596. renderOutline: boolean;
  54597. /** @hidden (Backing field) */
  54598. _renderOverlay: boolean;
  54599. /**
  54600. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54601. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54602. */
  54603. renderOverlay: boolean;
  54604. }
  54605. /**
  54606. * This class is responsible to draw bothe outline/overlay of meshes.
  54607. * It should not be used directly but through the available method on mesh.
  54608. */
  54609. export class OutlineRenderer implements ISceneComponent {
  54610. /**
  54611. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54612. */
  54613. private static _StencilReference;
  54614. /**
  54615. * The name of the component. Each component must have a unique name.
  54616. */
  54617. name: string;
  54618. /**
  54619. * The scene the component belongs to.
  54620. */
  54621. scene: Scene;
  54622. /**
  54623. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54624. */
  54625. zOffset: number;
  54626. private _engine;
  54627. private _effect;
  54628. private _cachedDefines;
  54629. private _savedDepthWrite;
  54630. /**
  54631. * Instantiates a new outline renderer. (There could be only one per scene).
  54632. * @param scene Defines the scene it belongs to
  54633. */
  54634. constructor(scene: Scene);
  54635. /**
  54636. * Register the component to one instance of a scene.
  54637. */
  54638. register(): void;
  54639. /**
  54640. * Rebuilds the elements related to this component in case of
  54641. * context lost for instance.
  54642. */
  54643. rebuild(): void;
  54644. /**
  54645. * Disposes the component and the associated ressources.
  54646. */
  54647. dispose(): void;
  54648. /**
  54649. * Renders the outline in the canvas.
  54650. * @param subMesh Defines the sumesh to render
  54651. * @param batch Defines the batch of meshes in case of instances
  54652. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54653. */
  54654. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54655. /**
  54656. * Returns whether or not the outline renderer is ready for a given submesh.
  54657. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54658. * @param subMesh Defines the submesh to check readyness for
  54659. * @param useInstances Defines wheter wee are trying to render instances or not
  54660. * @returns true if ready otherwise false
  54661. */
  54662. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54663. private _beforeRenderingMesh;
  54664. private _afterRenderingMesh;
  54665. }
  54666. }
  54667. declare module BABYLON {
  54668. /**
  54669. * Defines the list of states available for a task inside a AssetsManager
  54670. */
  54671. export enum AssetTaskState {
  54672. /**
  54673. * Initialization
  54674. */
  54675. INIT = 0,
  54676. /**
  54677. * Running
  54678. */
  54679. RUNNING = 1,
  54680. /**
  54681. * Done
  54682. */
  54683. DONE = 2,
  54684. /**
  54685. * Error
  54686. */
  54687. ERROR = 3
  54688. }
  54689. /**
  54690. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54691. */
  54692. export abstract class AbstractAssetTask {
  54693. /**
  54694. * Task name
  54695. */ name: string;
  54696. /**
  54697. * Callback called when the task is successful
  54698. */
  54699. onSuccess: (task: any) => void;
  54700. /**
  54701. * Callback called when the task is not successful
  54702. */
  54703. onError: (task: any, message?: string, exception?: any) => void;
  54704. /**
  54705. * Creates a new AssetsManager
  54706. * @param name defines the name of the task
  54707. */
  54708. constructor(
  54709. /**
  54710. * Task name
  54711. */ name: string);
  54712. private _isCompleted;
  54713. private _taskState;
  54714. private _errorObject;
  54715. /**
  54716. * Get if the task is completed
  54717. */
  54718. readonly isCompleted: boolean;
  54719. /**
  54720. * Gets the current state of the task
  54721. */
  54722. readonly taskState: AssetTaskState;
  54723. /**
  54724. * Gets the current error object (if task is in error)
  54725. */
  54726. readonly errorObject: {
  54727. message?: string;
  54728. exception?: any;
  54729. };
  54730. /**
  54731. * Internal only
  54732. * @hidden
  54733. */
  54734. _setErrorObject(message?: string, exception?: any): void;
  54735. /**
  54736. * Execute the current task
  54737. * @param scene defines the scene where you want your assets to be loaded
  54738. * @param onSuccess is a callback called when the task is successfully executed
  54739. * @param onError is a callback called if an error occurs
  54740. */
  54741. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54742. /**
  54743. * Execute the current task
  54744. * @param scene defines the scene where you want your assets to be loaded
  54745. * @param onSuccess is a callback called when the task is successfully executed
  54746. * @param onError is a callback called if an error occurs
  54747. */
  54748. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54749. /**
  54750. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54751. * This can be used with failed tasks that have the reason for failure fixed.
  54752. */
  54753. reset(): void;
  54754. private onErrorCallback;
  54755. private onDoneCallback;
  54756. }
  54757. /**
  54758. * Define the interface used by progress events raised during assets loading
  54759. */
  54760. export interface IAssetsProgressEvent {
  54761. /**
  54762. * Defines the number of remaining tasks to process
  54763. */
  54764. remainingCount: number;
  54765. /**
  54766. * Defines the total number of tasks
  54767. */
  54768. totalCount: number;
  54769. /**
  54770. * Defines the task that was just processed
  54771. */
  54772. task: AbstractAssetTask;
  54773. }
  54774. /**
  54775. * Class used to share progress information about assets loading
  54776. */
  54777. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54778. /**
  54779. * Defines the number of remaining tasks to process
  54780. */
  54781. remainingCount: number;
  54782. /**
  54783. * Defines the total number of tasks
  54784. */
  54785. totalCount: number;
  54786. /**
  54787. * Defines the task that was just processed
  54788. */
  54789. task: AbstractAssetTask;
  54790. /**
  54791. * Creates a AssetsProgressEvent
  54792. * @param remainingCount defines the number of remaining tasks to process
  54793. * @param totalCount defines the total number of tasks
  54794. * @param task defines the task that was just processed
  54795. */
  54796. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54797. }
  54798. /**
  54799. * Define a task used by AssetsManager to load meshes
  54800. */
  54801. export class MeshAssetTask extends AbstractAssetTask {
  54802. /**
  54803. * Defines the name of the task
  54804. */
  54805. name: string;
  54806. /**
  54807. * Defines the list of mesh's names you want to load
  54808. */
  54809. meshesNames: any;
  54810. /**
  54811. * Defines the root url to use as a base to load your meshes and associated resources
  54812. */
  54813. rootUrl: string;
  54814. /**
  54815. * Defines the filename of the scene to load from
  54816. */
  54817. sceneFilename: string;
  54818. /**
  54819. * Gets the list of loaded meshes
  54820. */
  54821. loadedMeshes: Array<AbstractMesh>;
  54822. /**
  54823. * Gets the list of loaded particle systems
  54824. */
  54825. loadedParticleSystems: Array<IParticleSystem>;
  54826. /**
  54827. * Gets the list of loaded skeletons
  54828. */
  54829. loadedSkeletons: Array<Skeleton>;
  54830. /**
  54831. * Gets the list of loaded animation groups
  54832. */
  54833. loadedAnimationGroups: Array<AnimationGroup>;
  54834. /**
  54835. * Callback called when the task is successful
  54836. */
  54837. onSuccess: (task: MeshAssetTask) => void;
  54838. /**
  54839. * Callback called when the task is successful
  54840. */
  54841. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54842. /**
  54843. * Creates a new MeshAssetTask
  54844. * @param name defines the name of the task
  54845. * @param meshesNames defines the list of mesh's names you want to load
  54846. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54847. * @param sceneFilename defines the filename of the scene to load from
  54848. */
  54849. constructor(
  54850. /**
  54851. * Defines the name of the task
  54852. */
  54853. name: string,
  54854. /**
  54855. * Defines the list of mesh's names you want to load
  54856. */
  54857. meshesNames: any,
  54858. /**
  54859. * Defines the root url to use as a base to load your meshes and associated resources
  54860. */
  54861. rootUrl: string,
  54862. /**
  54863. * Defines the filename of the scene to load from
  54864. */
  54865. sceneFilename: string);
  54866. /**
  54867. * Execute the current task
  54868. * @param scene defines the scene where you want your assets to be loaded
  54869. * @param onSuccess is a callback called when the task is successfully executed
  54870. * @param onError is a callback called if an error occurs
  54871. */
  54872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54873. }
  54874. /**
  54875. * Define a task used by AssetsManager to load text content
  54876. */
  54877. export class TextFileAssetTask extends AbstractAssetTask {
  54878. /**
  54879. * Defines the name of the task
  54880. */
  54881. name: string;
  54882. /**
  54883. * Defines the location of the file to load
  54884. */
  54885. url: string;
  54886. /**
  54887. * Gets the loaded text string
  54888. */
  54889. text: string;
  54890. /**
  54891. * Callback called when the task is successful
  54892. */
  54893. onSuccess: (task: TextFileAssetTask) => void;
  54894. /**
  54895. * Callback called when the task is successful
  54896. */
  54897. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54898. /**
  54899. * Creates a new TextFileAssetTask object
  54900. * @param name defines the name of the task
  54901. * @param url defines the location of the file to load
  54902. */
  54903. constructor(
  54904. /**
  54905. * Defines the name of the task
  54906. */
  54907. name: string,
  54908. /**
  54909. * Defines the location of the file to load
  54910. */
  54911. url: string);
  54912. /**
  54913. * Execute the current task
  54914. * @param scene defines the scene where you want your assets to be loaded
  54915. * @param onSuccess is a callback called when the task is successfully executed
  54916. * @param onError is a callback called if an error occurs
  54917. */
  54918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54919. }
  54920. /**
  54921. * Define a task used by AssetsManager to load binary data
  54922. */
  54923. export class BinaryFileAssetTask extends AbstractAssetTask {
  54924. /**
  54925. * Defines the name of the task
  54926. */
  54927. name: string;
  54928. /**
  54929. * Defines the location of the file to load
  54930. */
  54931. url: string;
  54932. /**
  54933. * Gets the lodaded data (as an array buffer)
  54934. */
  54935. data: ArrayBuffer;
  54936. /**
  54937. * Callback called when the task is successful
  54938. */
  54939. onSuccess: (task: BinaryFileAssetTask) => void;
  54940. /**
  54941. * Callback called when the task is successful
  54942. */
  54943. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54944. /**
  54945. * Creates a new BinaryFileAssetTask object
  54946. * @param name defines the name of the new task
  54947. * @param url defines the location of the file to load
  54948. */
  54949. constructor(
  54950. /**
  54951. * Defines the name of the task
  54952. */
  54953. name: string,
  54954. /**
  54955. * Defines the location of the file to load
  54956. */
  54957. url: string);
  54958. /**
  54959. * Execute the current task
  54960. * @param scene defines the scene where you want your assets to be loaded
  54961. * @param onSuccess is a callback called when the task is successfully executed
  54962. * @param onError is a callback called if an error occurs
  54963. */
  54964. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54965. }
  54966. /**
  54967. * Define a task used by AssetsManager to load images
  54968. */
  54969. export class ImageAssetTask extends AbstractAssetTask {
  54970. /**
  54971. * Defines the name of the task
  54972. */
  54973. name: string;
  54974. /**
  54975. * Defines the location of the image to load
  54976. */
  54977. url: string;
  54978. /**
  54979. * Gets the loaded images
  54980. */
  54981. image: HTMLImageElement;
  54982. /**
  54983. * Callback called when the task is successful
  54984. */
  54985. onSuccess: (task: ImageAssetTask) => void;
  54986. /**
  54987. * Callback called when the task is successful
  54988. */
  54989. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54990. /**
  54991. * Creates a new ImageAssetTask
  54992. * @param name defines the name of the task
  54993. * @param url defines the location of the image to load
  54994. */
  54995. constructor(
  54996. /**
  54997. * Defines the name of the task
  54998. */
  54999. name: string,
  55000. /**
  55001. * Defines the location of the image to load
  55002. */
  55003. url: string);
  55004. /**
  55005. * Execute the current task
  55006. * @param scene defines the scene where you want your assets to be loaded
  55007. * @param onSuccess is a callback called when the task is successfully executed
  55008. * @param onError is a callback called if an error occurs
  55009. */
  55010. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55011. }
  55012. /**
  55013. * Defines the interface used by texture loading tasks
  55014. */
  55015. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55016. /**
  55017. * Gets the loaded texture
  55018. */
  55019. texture: TEX;
  55020. }
  55021. /**
  55022. * Define a task used by AssetsManager to load 2D textures
  55023. */
  55024. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55025. /**
  55026. * Defines the name of the task
  55027. */
  55028. name: string;
  55029. /**
  55030. * Defines the location of the file to load
  55031. */
  55032. url: string;
  55033. /**
  55034. * Defines if mipmap should not be generated (default is false)
  55035. */
  55036. noMipmap?: boolean | undefined;
  55037. /**
  55038. * Defines if texture must be inverted on Y axis (default is false)
  55039. */
  55040. invertY?: boolean | undefined;
  55041. /**
  55042. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55043. */
  55044. samplingMode: number;
  55045. /**
  55046. * Gets the loaded texture
  55047. */
  55048. texture: Texture;
  55049. /**
  55050. * Callback called when the task is successful
  55051. */
  55052. onSuccess: (task: TextureAssetTask) => void;
  55053. /**
  55054. * Callback called when the task is successful
  55055. */
  55056. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55057. /**
  55058. * Creates a new TextureAssetTask object
  55059. * @param name defines the name of the task
  55060. * @param url defines the location of the file to load
  55061. * @param noMipmap defines if mipmap should not be generated (default is false)
  55062. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55063. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55064. */
  55065. constructor(
  55066. /**
  55067. * Defines the name of the task
  55068. */
  55069. name: string,
  55070. /**
  55071. * Defines the location of the file to load
  55072. */
  55073. url: string,
  55074. /**
  55075. * Defines if mipmap should not be generated (default is false)
  55076. */
  55077. noMipmap?: boolean | undefined,
  55078. /**
  55079. * Defines if texture must be inverted on Y axis (default is false)
  55080. */
  55081. invertY?: boolean | undefined,
  55082. /**
  55083. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55084. */
  55085. samplingMode?: number);
  55086. /**
  55087. * Execute the current task
  55088. * @param scene defines the scene where you want your assets to be loaded
  55089. * @param onSuccess is a callback called when the task is successfully executed
  55090. * @param onError is a callback called if an error occurs
  55091. */
  55092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55093. }
  55094. /**
  55095. * Define a task used by AssetsManager to load cube textures
  55096. */
  55097. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55098. /**
  55099. * Defines the name of the task
  55100. */
  55101. name: string;
  55102. /**
  55103. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55104. */
  55105. url: string;
  55106. /**
  55107. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55108. */
  55109. extensions?: string[] | undefined;
  55110. /**
  55111. * Defines if mipmaps should not be generated (default is false)
  55112. */
  55113. noMipmap?: boolean | undefined;
  55114. /**
  55115. * Defines the explicit list of files (undefined by default)
  55116. */
  55117. files?: string[] | undefined;
  55118. /**
  55119. * Gets the loaded texture
  55120. */
  55121. texture: CubeTexture;
  55122. /**
  55123. * Callback called when the task is successful
  55124. */
  55125. onSuccess: (task: CubeTextureAssetTask) => void;
  55126. /**
  55127. * Callback called when the task is successful
  55128. */
  55129. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55130. /**
  55131. * Creates a new CubeTextureAssetTask
  55132. * @param name defines the name of the task
  55133. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55134. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55135. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55136. * @param files defines the explicit list of files (undefined by default)
  55137. */
  55138. constructor(
  55139. /**
  55140. * Defines the name of the task
  55141. */
  55142. name: string,
  55143. /**
  55144. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55145. */
  55146. url: string,
  55147. /**
  55148. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55149. */
  55150. extensions?: string[] | undefined,
  55151. /**
  55152. * Defines if mipmaps should not be generated (default is false)
  55153. */
  55154. noMipmap?: boolean | undefined,
  55155. /**
  55156. * Defines the explicit list of files (undefined by default)
  55157. */
  55158. files?: string[] | undefined);
  55159. /**
  55160. * Execute the current task
  55161. * @param scene defines the scene where you want your assets to be loaded
  55162. * @param onSuccess is a callback called when the task is successfully executed
  55163. * @param onError is a callback called if an error occurs
  55164. */
  55165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55166. }
  55167. /**
  55168. * Define a task used by AssetsManager to load HDR cube textures
  55169. */
  55170. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55171. /**
  55172. * Defines the name of the task
  55173. */
  55174. name: string;
  55175. /**
  55176. * Defines the location of the file to load
  55177. */
  55178. url: string;
  55179. /**
  55180. * Defines the desired size (the more it increases the longer the generation will be)
  55181. */
  55182. size: number;
  55183. /**
  55184. * Defines if mipmaps should not be generated (default is false)
  55185. */
  55186. noMipmap: boolean;
  55187. /**
  55188. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55189. */
  55190. generateHarmonics: boolean;
  55191. /**
  55192. * 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)
  55193. */
  55194. gammaSpace: boolean;
  55195. /**
  55196. * Internal Use Only
  55197. */
  55198. reserved: boolean;
  55199. /**
  55200. * Gets the loaded texture
  55201. */
  55202. texture: HDRCubeTexture;
  55203. /**
  55204. * Callback called when the task is successful
  55205. */
  55206. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55207. /**
  55208. * Callback called when the task is successful
  55209. */
  55210. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55211. /**
  55212. * Creates a new HDRCubeTextureAssetTask object
  55213. * @param name defines the name of the task
  55214. * @param url defines the location of the file to load
  55215. * @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.
  55216. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55217. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55218. * @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)
  55219. * @param reserved Internal use only
  55220. */
  55221. constructor(
  55222. /**
  55223. * Defines the name of the task
  55224. */
  55225. name: string,
  55226. /**
  55227. * Defines the location of the file to load
  55228. */
  55229. url: string,
  55230. /**
  55231. * Defines the desired size (the more it increases the longer the generation will be)
  55232. */
  55233. size: number,
  55234. /**
  55235. * Defines if mipmaps should not be generated (default is false)
  55236. */
  55237. noMipmap?: boolean,
  55238. /**
  55239. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55240. */
  55241. generateHarmonics?: boolean,
  55242. /**
  55243. * 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)
  55244. */
  55245. gammaSpace?: boolean,
  55246. /**
  55247. * Internal Use Only
  55248. */
  55249. reserved?: boolean);
  55250. /**
  55251. * Execute the current task
  55252. * @param scene defines the scene where you want your assets to be loaded
  55253. * @param onSuccess is a callback called when the task is successfully executed
  55254. * @param onError is a callback called if an error occurs
  55255. */
  55256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55257. }
  55258. /**
  55259. * Define a task used by AssetsManager to load Equirectangular cube textures
  55260. */
  55261. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55262. /**
  55263. * Defines the name of the task
  55264. */
  55265. name: string;
  55266. /**
  55267. * Defines the location of the file to load
  55268. */
  55269. url: string;
  55270. /**
  55271. * Defines the desired size (the more it increases the longer the generation will be)
  55272. */
  55273. size: number;
  55274. /**
  55275. * Defines if mipmaps should not be generated (default is false)
  55276. */
  55277. noMipmap: boolean;
  55278. /**
  55279. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55280. * but the standard material would require them in Gamma space) (default is true)
  55281. */
  55282. gammaSpace: boolean;
  55283. /**
  55284. * Gets the loaded texture
  55285. */
  55286. texture: EquiRectangularCubeTexture;
  55287. /**
  55288. * Callback called when the task is successful
  55289. */
  55290. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55291. /**
  55292. * Callback called when the task is successful
  55293. */
  55294. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55295. /**
  55296. * Creates a new EquiRectangularCubeTextureAssetTask object
  55297. * @param name defines the name of the task
  55298. * @param url defines the location of the file to load
  55299. * @param size defines the desired size (the more it increases the longer the generation will be)
  55300. * If the size is omitted this implies you are using a preprocessed cubemap.
  55301. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55302. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55303. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55304. * (default is true)
  55305. */
  55306. constructor(
  55307. /**
  55308. * Defines the name of the task
  55309. */
  55310. name: string,
  55311. /**
  55312. * Defines the location of the file to load
  55313. */
  55314. url: string,
  55315. /**
  55316. * Defines the desired size (the more it increases the longer the generation will be)
  55317. */
  55318. size: number,
  55319. /**
  55320. * Defines if mipmaps should not be generated (default is false)
  55321. */
  55322. noMipmap?: boolean,
  55323. /**
  55324. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55325. * but the standard material would require them in Gamma space) (default is true)
  55326. */
  55327. gammaSpace?: boolean);
  55328. /**
  55329. * Execute the current task
  55330. * @param scene defines the scene where you want your assets to be loaded
  55331. * @param onSuccess is a callback called when the task is successfully executed
  55332. * @param onError is a callback called if an error occurs
  55333. */
  55334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55335. }
  55336. /**
  55337. * This class can be used to easily import assets into a scene
  55338. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55339. */
  55340. export class AssetsManager {
  55341. private _scene;
  55342. private _isLoading;
  55343. protected _tasks: AbstractAssetTask[];
  55344. protected _waitingTasksCount: number;
  55345. protected _totalTasksCount: number;
  55346. /**
  55347. * Callback called when all tasks are processed
  55348. */
  55349. onFinish: (tasks: AbstractAssetTask[]) => void;
  55350. /**
  55351. * Callback called when a task is successful
  55352. */
  55353. onTaskSuccess: (task: AbstractAssetTask) => void;
  55354. /**
  55355. * Callback called when a task had an error
  55356. */
  55357. onTaskError: (task: AbstractAssetTask) => void;
  55358. /**
  55359. * Callback called when a task is done (whatever the result is)
  55360. */
  55361. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55362. /**
  55363. * Observable called when all tasks are processed
  55364. */
  55365. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55366. /**
  55367. * Observable called when a task had an error
  55368. */
  55369. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55370. /**
  55371. * Observable called when all tasks were executed
  55372. */
  55373. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55374. /**
  55375. * Observable called when a task is done (whatever the result is)
  55376. */
  55377. onProgressObservable: Observable<IAssetsProgressEvent>;
  55378. /**
  55379. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55381. */
  55382. useDefaultLoadingScreen: boolean;
  55383. /**
  55384. * Creates a new AssetsManager
  55385. * @param scene defines the scene to work on
  55386. */
  55387. constructor(scene: Scene);
  55388. /**
  55389. * Add a MeshAssetTask to the list of active tasks
  55390. * @param taskName defines the name of the new task
  55391. * @param meshesNames defines the name of meshes to load
  55392. * @param rootUrl defines the root url to use to locate files
  55393. * @param sceneFilename defines the filename of the scene file
  55394. * @returns a new MeshAssetTask object
  55395. */
  55396. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55397. /**
  55398. * Add a TextFileAssetTask to the list of active tasks
  55399. * @param taskName defines the name of the new task
  55400. * @param url defines the url of the file to load
  55401. * @returns a new TextFileAssetTask object
  55402. */
  55403. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55404. /**
  55405. * Add a BinaryFileAssetTask to the list of active tasks
  55406. * @param taskName defines the name of the new task
  55407. * @param url defines the url of the file to load
  55408. * @returns a new BinaryFileAssetTask object
  55409. */
  55410. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55411. /**
  55412. * Add a ImageAssetTask to the list of active tasks
  55413. * @param taskName defines the name of the new task
  55414. * @param url defines the url of the file to load
  55415. * @returns a new ImageAssetTask object
  55416. */
  55417. addImageTask(taskName: string, url: string): ImageAssetTask;
  55418. /**
  55419. * Add a TextureAssetTask to the list of active tasks
  55420. * @param taskName defines the name of the new task
  55421. * @param url defines the url of the file to load
  55422. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55423. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55424. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55425. * @returns a new TextureAssetTask object
  55426. */
  55427. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55428. /**
  55429. * Add a CubeTextureAssetTask to the list of active tasks
  55430. * @param taskName defines the name of the new task
  55431. * @param url defines the url of the file to load
  55432. * @param extensions defines the extension to use to load the cube map (can be null)
  55433. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55434. * @param files defines the list of files to load (can be null)
  55435. * @returns a new CubeTextureAssetTask object
  55436. */
  55437. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55438. /**
  55439. *
  55440. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55441. * @param taskName defines the name of the new task
  55442. * @param url defines the url of the file to load
  55443. * @param size defines the size you want for the cubemap (can be null)
  55444. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55445. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55446. * @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)
  55447. * @param reserved Internal use only
  55448. * @returns a new HDRCubeTextureAssetTask object
  55449. */
  55450. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55451. /**
  55452. *
  55453. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55454. * @param taskName defines the name of the new task
  55455. * @param url defines the url of the file to load
  55456. * @param size defines the size you want for the cubemap (can be null)
  55457. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55458. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55459. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55460. * @returns a new EquiRectangularCubeTextureAssetTask object
  55461. */
  55462. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55463. /**
  55464. * Remove a task from the assets manager.
  55465. * @param task the task to remove
  55466. */
  55467. removeTask(task: AbstractAssetTask): void;
  55468. private _decreaseWaitingTasksCount;
  55469. private _runTask;
  55470. /**
  55471. * Reset the AssetsManager and remove all tasks
  55472. * @return the current instance of the AssetsManager
  55473. */
  55474. reset(): AssetsManager;
  55475. /**
  55476. * Start the loading process
  55477. * @return the current instance of the AssetsManager
  55478. */
  55479. load(): AssetsManager;
  55480. /**
  55481. * Start the loading process as an async operation
  55482. * @return a promise returning the list of failed tasks
  55483. */
  55484. loadAsync(): Promise<void>;
  55485. }
  55486. }
  55487. declare module BABYLON {
  55488. /**
  55489. * Wrapper class for promise with external resolve and reject.
  55490. */
  55491. export class Deferred<T> {
  55492. /**
  55493. * The promise associated with this deferred object.
  55494. */
  55495. readonly promise: Promise<T>;
  55496. private _resolve;
  55497. private _reject;
  55498. /**
  55499. * The resolve method of the promise associated with this deferred object.
  55500. */
  55501. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55502. /**
  55503. * The reject method of the promise associated with this deferred object.
  55504. */
  55505. readonly reject: (reason?: any) => void;
  55506. /**
  55507. * Constructor for this deferred object.
  55508. */
  55509. constructor();
  55510. }
  55511. }
  55512. declare module BABYLON {
  55513. /**
  55514. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55515. */
  55516. export class MeshExploder {
  55517. private _centerMesh;
  55518. private _meshes;
  55519. private _meshesOrigins;
  55520. private _toCenterVectors;
  55521. private _scaledDirection;
  55522. private _newPosition;
  55523. private _centerPosition;
  55524. /**
  55525. * Explodes meshes from a center mesh.
  55526. * @param meshes The meshes to explode.
  55527. * @param centerMesh The mesh to be center of explosion.
  55528. */
  55529. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55530. private _setCenterMesh;
  55531. /**
  55532. * Get class name
  55533. * @returns "MeshExploder"
  55534. */
  55535. getClassName(): string;
  55536. /**
  55537. * "Exploded meshes"
  55538. * @returns Array of meshes with the centerMesh at index 0.
  55539. */
  55540. getMeshes(): Array<Mesh>;
  55541. /**
  55542. * Explodes meshes giving a specific direction
  55543. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55544. */
  55545. explode(direction?: number): void;
  55546. }
  55547. }
  55548. declare module BABYLON {
  55549. /**
  55550. * Class used to help managing file picking and drag'n'drop
  55551. */
  55552. export class FilesInput {
  55553. /**
  55554. * List of files ready to be loaded
  55555. */
  55556. static readonly FilesToLoad: {
  55557. [key: string]: File;
  55558. };
  55559. /**
  55560. * Callback called when a file is processed
  55561. */
  55562. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55563. private _engine;
  55564. private _currentScene;
  55565. private _sceneLoadedCallback;
  55566. private _progressCallback;
  55567. private _additionalRenderLoopLogicCallback;
  55568. private _textureLoadingCallback;
  55569. private _startingProcessingFilesCallback;
  55570. private _onReloadCallback;
  55571. private _errorCallback;
  55572. private _elementToMonitor;
  55573. private _sceneFileToLoad;
  55574. private _filesToLoad;
  55575. /**
  55576. * Creates a new FilesInput
  55577. * @param engine defines the rendering engine
  55578. * @param scene defines the hosting scene
  55579. * @param sceneLoadedCallback callback called when scene is loaded
  55580. * @param progressCallback callback called to track progress
  55581. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55582. * @param textureLoadingCallback callback called when a texture is loading
  55583. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55584. * @param onReloadCallback callback called when a reload is requested
  55585. * @param errorCallback callback call if an error occurs
  55586. */
  55587. 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);
  55588. private _dragEnterHandler;
  55589. private _dragOverHandler;
  55590. private _dropHandler;
  55591. /**
  55592. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55593. * @param elementToMonitor defines the DOM element to track
  55594. */
  55595. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55596. /**
  55597. * Release all associated resources
  55598. */
  55599. dispose(): void;
  55600. private renderFunction;
  55601. private drag;
  55602. private drop;
  55603. private _traverseFolder;
  55604. private _processFiles;
  55605. /**
  55606. * Load files from a drop event
  55607. * @param event defines the drop event to use as source
  55608. */
  55609. loadFiles(event: any): void;
  55610. private _processReload;
  55611. /**
  55612. * Reload the current scene from the loaded files
  55613. */
  55614. reload(): void;
  55615. }
  55616. }
  55617. declare module BABYLON {
  55618. /**
  55619. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55621. */
  55622. export class SceneOptimization {
  55623. /**
  55624. * Defines the priority of this optimization (0 by default which means first in the list)
  55625. */
  55626. priority: number;
  55627. /**
  55628. * Gets a string describing the action executed by the current optimization
  55629. * @returns description string
  55630. */
  55631. getDescription(): string;
  55632. /**
  55633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55634. * @param scene defines the current scene where to apply this optimization
  55635. * @param optimizer defines the current optimizer
  55636. * @returns true if everything that can be done was applied
  55637. */
  55638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55639. /**
  55640. * Creates the SceneOptimization object
  55641. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55642. * @param desc defines the description associated with the optimization
  55643. */
  55644. constructor(
  55645. /**
  55646. * Defines the priority of this optimization (0 by default which means first in the list)
  55647. */
  55648. priority?: number);
  55649. }
  55650. /**
  55651. * Defines an optimization used to reduce the size of render target textures
  55652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55653. */
  55654. export class TextureOptimization extends SceneOptimization {
  55655. /**
  55656. * Defines the priority of this optimization (0 by default which means first in the list)
  55657. */
  55658. priority: number;
  55659. /**
  55660. * 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
  55661. */
  55662. maximumSize: number;
  55663. /**
  55664. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55665. */
  55666. step: number;
  55667. /**
  55668. * Gets a string describing the action executed by the current optimization
  55669. * @returns description string
  55670. */
  55671. getDescription(): string;
  55672. /**
  55673. * Creates the TextureOptimization object
  55674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55675. * @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
  55676. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55677. */
  55678. constructor(
  55679. /**
  55680. * Defines the priority of this optimization (0 by default which means first in the list)
  55681. */
  55682. priority?: number,
  55683. /**
  55684. * 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
  55685. */
  55686. maximumSize?: number,
  55687. /**
  55688. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55689. */
  55690. step?: number);
  55691. /**
  55692. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55693. * @param scene defines the current scene where to apply this optimization
  55694. * @param optimizer defines the current optimizer
  55695. * @returns true if everything that can be done was applied
  55696. */
  55697. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55698. }
  55699. /**
  55700. * Defines an optimization used to increase or decrease the rendering resolution
  55701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55702. */
  55703. export class HardwareScalingOptimization extends SceneOptimization {
  55704. /**
  55705. * Defines the priority of this optimization (0 by default which means first in the list)
  55706. */
  55707. priority: number;
  55708. /**
  55709. * Defines the maximum scale to use (2 by default)
  55710. */
  55711. maximumScale: number;
  55712. /**
  55713. * Defines the step to use between two passes (0.5 by default)
  55714. */
  55715. step: number;
  55716. private _currentScale;
  55717. private _directionOffset;
  55718. /**
  55719. * Gets a string describing the action executed by the current optimization
  55720. * @return description string
  55721. */
  55722. getDescription(): string;
  55723. /**
  55724. * Creates the HardwareScalingOptimization object
  55725. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55726. * @param maximumScale defines the maximum scale to use (2 by default)
  55727. * @param step defines the step to use between two passes (0.5 by default)
  55728. */
  55729. constructor(
  55730. /**
  55731. * Defines the priority of this optimization (0 by default which means first in the list)
  55732. */
  55733. priority?: number,
  55734. /**
  55735. * Defines the maximum scale to use (2 by default)
  55736. */
  55737. maximumScale?: number,
  55738. /**
  55739. * Defines the step to use between two passes (0.5 by default)
  55740. */
  55741. step?: number);
  55742. /**
  55743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55744. * @param scene defines the current scene where to apply this optimization
  55745. * @param optimizer defines the current optimizer
  55746. * @returns true if everything that can be done was applied
  55747. */
  55748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55749. }
  55750. /**
  55751. * Defines an optimization used to remove shadows
  55752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55753. */
  55754. export class ShadowsOptimization extends SceneOptimization {
  55755. /**
  55756. * Gets a string describing the action executed by the current optimization
  55757. * @return description string
  55758. */
  55759. getDescription(): string;
  55760. /**
  55761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55762. * @param scene defines the current scene where to apply this optimization
  55763. * @param optimizer defines the current optimizer
  55764. * @returns true if everything that can be done was applied
  55765. */
  55766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55767. }
  55768. /**
  55769. * Defines an optimization used to turn post-processes off
  55770. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55771. */
  55772. export class PostProcessesOptimization extends SceneOptimization {
  55773. /**
  55774. * Gets a string describing the action executed by the current optimization
  55775. * @return description string
  55776. */
  55777. getDescription(): string;
  55778. /**
  55779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55780. * @param scene defines the current scene where to apply this optimization
  55781. * @param optimizer defines the current optimizer
  55782. * @returns true if everything that can be done was applied
  55783. */
  55784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55785. }
  55786. /**
  55787. * Defines an optimization used to turn lens flares off
  55788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55789. */
  55790. export class LensFlaresOptimization extends SceneOptimization {
  55791. /**
  55792. * Gets a string describing the action executed by the current optimization
  55793. * @return description string
  55794. */
  55795. getDescription(): string;
  55796. /**
  55797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55798. * @param scene defines the current scene where to apply this optimization
  55799. * @param optimizer defines the current optimizer
  55800. * @returns true if everything that can be done was applied
  55801. */
  55802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55803. }
  55804. /**
  55805. * Defines an optimization based on user defined callback.
  55806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55807. */
  55808. export class CustomOptimization extends SceneOptimization {
  55809. /**
  55810. * Callback called to apply the custom optimization.
  55811. */
  55812. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55813. /**
  55814. * Callback called to get custom description
  55815. */
  55816. onGetDescription: () => string;
  55817. /**
  55818. * Gets a string describing the action executed by the current optimization
  55819. * @returns description string
  55820. */
  55821. getDescription(): string;
  55822. /**
  55823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55824. * @param scene defines the current scene where to apply this optimization
  55825. * @param optimizer defines the current optimizer
  55826. * @returns true if everything that can be done was applied
  55827. */
  55828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55829. }
  55830. /**
  55831. * Defines an optimization used to turn particles off
  55832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55833. */
  55834. export class ParticlesOptimization extends SceneOptimization {
  55835. /**
  55836. * Gets a string describing the action executed by the current optimization
  55837. * @return description string
  55838. */
  55839. getDescription(): string;
  55840. /**
  55841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55842. * @param scene defines the current scene where to apply this optimization
  55843. * @param optimizer defines the current optimizer
  55844. * @returns true if everything that can be done was applied
  55845. */
  55846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55847. }
  55848. /**
  55849. * Defines an optimization used to turn render targets off
  55850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55851. */
  55852. export class RenderTargetsOptimization extends SceneOptimization {
  55853. /**
  55854. * Gets a string describing the action executed by the current optimization
  55855. * @return description string
  55856. */
  55857. getDescription(): string;
  55858. /**
  55859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55860. * @param scene defines the current scene where to apply this optimization
  55861. * @param optimizer defines the current optimizer
  55862. * @returns true if everything that can be done was applied
  55863. */
  55864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55865. }
  55866. /**
  55867. * Defines an optimization used to merge meshes with compatible materials
  55868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55869. */
  55870. export class MergeMeshesOptimization extends SceneOptimization {
  55871. private static _UpdateSelectionTree;
  55872. /**
  55873. * Gets or sets a boolean which defines if optimization octree has to be updated
  55874. */
  55875. /**
  55876. * Gets or sets a boolean which defines if optimization octree has to be updated
  55877. */
  55878. static UpdateSelectionTree: boolean;
  55879. /**
  55880. * Gets a string describing the action executed by the current optimization
  55881. * @return description string
  55882. */
  55883. getDescription(): string;
  55884. private _canBeMerged;
  55885. /**
  55886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55887. * @param scene defines the current scene where to apply this optimization
  55888. * @param optimizer defines the current optimizer
  55889. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55890. * @returns true if everything that can be done was applied
  55891. */
  55892. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55893. }
  55894. /**
  55895. * Defines a list of options used by SceneOptimizer
  55896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55897. */
  55898. export class SceneOptimizerOptions {
  55899. /**
  55900. * Defines the target frame rate to reach (60 by default)
  55901. */
  55902. targetFrameRate: number;
  55903. /**
  55904. * Defines the interval between two checkes (2000ms by default)
  55905. */
  55906. trackerDuration: number;
  55907. /**
  55908. * Gets the list of optimizations to apply
  55909. */
  55910. optimizations: SceneOptimization[];
  55911. /**
  55912. * Creates a new list of options used by SceneOptimizer
  55913. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55914. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55915. */
  55916. constructor(
  55917. /**
  55918. * Defines the target frame rate to reach (60 by default)
  55919. */
  55920. targetFrameRate?: number,
  55921. /**
  55922. * Defines the interval between two checkes (2000ms by default)
  55923. */
  55924. trackerDuration?: number);
  55925. /**
  55926. * Add a new optimization
  55927. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55928. * @returns the current SceneOptimizerOptions
  55929. */
  55930. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55931. /**
  55932. * Add a new custom optimization
  55933. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55934. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55935. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55936. * @returns the current SceneOptimizerOptions
  55937. */
  55938. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55939. /**
  55940. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55941. * @param targetFrameRate defines the target frame rate (60 by default)
  55942. * @returns a SceneOptimizerOptions object
  55943. */
  55944. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55945. /**
  55946. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55947. * @param targetFrameRate defines the target frame rate (60 by default)
  55948. * @returns a SceneOptimizerOptions object
  55949. */
  55950. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55951. /**
  55952. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55953. * @param targetFrameRate defines the target frame rate (60 by default)
  55954. * @returns a SceneOptimizerOptions object
  55955. */
  55956. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55957. }
  55958. /**
  55959. * Class used to run optimizations in order to reach a target frame rate
  55960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55961. */
  55962. export class SceneOptimizer implements IDisposable {
  55963. private _isRunning;
  55964. private _options;
  55965. private _scene;
  55966. private _currentPriorityLevel;
  55967. private _targetFrameRate;
  55968. private _trackerDuration;
  55969. private _currentFrameRate;
  55970. private _sceneDisposeObserver;
  55971. private _improvementMode;
  55972. /**
  55973. * Defines an observable called when the optimizer reaches the target frame rate
  55974. */
  55975. onSuccessObservable: Observable<SceneOptimizer>;
  55976. /**
  55977. * Defines an observable called when the optimizer enables an optimization
  55978. */
  55979. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55980. /**
  55981. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55982. */
  55983. onFailureObservable: Observable<SceneOptimizer>;
  55984. /**
  55985. * Gets a boolean indicating if the optimizer is in improvement mode
  55986. */
  55987. readonly isInImprovementMode: boolean;
  55988. /**
  55989. * Gets the current priority level (0 at start)
  55990. */
  55991. readonly currentPriorityLevel: number;
  55992. /**
  55993. * Gets the current frame rate checked by the SceneOptimizer
  55994. */
  55995. readonly currentFrameRate: number;
  55996. /**
  55997. * Gets or sets the current target frame rate (60 by default)
  55998. */
  55999. /**
  56000. * Gets or sets the current target frame rate (60 by default)
  56001. */
  56002. targetFrameRate: number;
  56003. /**
  56004. * Gets or sets the current interval between two checks (every 2000ms by default)
  56005. */
  56006. /**
  56007. * Gets or sets the current interval between two checks (every 2000ms by default)
  56008. */
  56009. trackerDuration: number;
  56010. /**
  56011. * Gets the list of active optimizations
  56012. */
  56013. readonly optimizations: SceneOptimization[];
  56014. /**
  56015. * Creates a new SceneOptimizer
  56016. * @param scene defines the scene to work on
  56017. * @param options defines the options to use with the SceneOptimizer
  56018. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56019. * @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)
  56020. */
  56021. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56022. /**
  56023. * Stops the current optimizer
  56024. */
  56025. stop(): void;
  56026. /**
  56027. * Reset the optimizer to initial step (current priority level = 0)
  56028. */
  56029. reset(): void;
  56030. /**
  56031. * Start the optimizer. By default it will try to reach a specific framerate
  56032. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56033. */
  56034. start(): void;
  56035. private _checkCurrentState;
  56036. /**
  56037. * Release all resources
  56038. */
  56039. dispose(): void;
  56040. /**
  56041. * Helper function to create a SceneOptimizer with one single line of code
  56042. * @param scene defines the scene to work on
  56043. * @param options defines the options to use with the SceneOptimizer
  56044. * @param onSuccess defines a callback to call on success
  56045. * @param onFailure defines a callback to call on failure
  56046. * @returns the new SceneOptimizer object
  56047. */
  56048. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56049. }
  56050. }
  56051. declare module BABYLON {
  56052. /**
  56053. * Class used to serialize a scene into a string
  56054. */
  56055. export class SceneSerializer {
  56056. /**
  56057. * Clear cache used by a previous serialization
  56058. */
  56059. static ClearCache(): void;
  56060. /**
  56061. * Serialize a scene into a JSON compatible object
  56062. * @param scene defines the scene to serialize
  56063. * @returns a JSON compatible object
  56064. */
  56065. static Serialize(scene: Scene): any;
  56066. /**
  56067. * Serialize a mesh into a JSON compatible object
  56068. * @param toSerialize defines the mesh to serialize
  56069. * @param withParents defines if parents must be serialized as well
  56070. * @param withChildren defines if children must be serialized as well
  56071. * @returns a JSON compatible object
  56072. */
  56073. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56074. }
  56075. }
  56076. declare module BABYLON {
  56077. /**
  56078. * Class used to host texture specific utilities
  56079. */
  56080. export class TextureTools {
  56081. /**
  56082. * Uses the GPU to create a copy texture rescaled at a given size
  56083. * @param texture Texture to copy from
  56084. * @param width defines the desired width
  56085. * @param height defines the desired height
  56086. * @param useBilinearMode defines if bilinear mode has to be used
  56087. * @return the generated texture
  56088. */
  56089. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56090. }
  56091. }
  56092. declare module BABYLON {
  56093. /**
  56094. * This represents the different options avilable for the video capture.
  56095. */
  56096. export interface VideoRecorderOptions {
  56097. /** Defines the mime type of the video */
  56098. mimeType: string;
  56099. /** Defines the video the video should be recorded at */
  56100. fps: number;
  56101. /** Defines the chunk size for the recording data */
  56102. recordChunckSize: number;
  56103. /** The audio tracks to attach to the record */
  56104. audioTracks?: MediaStreamTrack[];
  56105. }
  56106. /**
  56107. * This can helps recording videos from BabylonJS.
  56108. * This is based on the available WebRTC functionalities of the browser.
  56109. *
  56110. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56111. */
  56112. export class VideoRecorder {
  56113. private static readonly _defaultOptions;
  56114. /**
  56115. * Returns wehther or not the VideoRecorder is available in your browser.
  56116. * @param engine Defines the Babylon Engine to check the support for
  56117. * @returns true if supported otherwise false
  56118. */
  56119. static IsSupported(engine: Engine): boolean;
  56120. private readonly _options;
  56121. private _canvas;
  56122. private _mediaRecorder;
  56123. private _recordedChunks;
  56124. private _fileName;
  56125. private _resolve;
  56126. private _reject;
  56127. /**
  56128. * True wether a recording is already in progress.
  56129. */
  56130. readonly isRecording: boolean;
  56131. /**
  56132. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56133. * a video file.
  56134. * @param engine Defines the BabylonJS Engine you wish to record
  56135. * @param options Defines options that can be used to customized the capture
  56136. */
  56137. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56138. /**
  56139. * Stops the current recording before the default capture timeout passed in the startRecording
  56140. * functions.
  56141. */
  56142. stopRecording(): void;
  56143. /**
  56144. * Starts recording the canvas for a max duration specified in parameters.
  56145. * @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.
  56146. * @param maxDuration Defines the maximum recording time in seconds.
  56147. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56148. * @return a promise callback at the end of the recording with the video data in Blob.
  56149. */
  56150. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56151. /**
  56152. * Releases internal resources used during the recording.
  56153. */
  56154. dispose(): void;
  56155. private _handleDataAvailable;
  56156. private _handleError;
  56157. private _handleStop;
  56158. }
  56159. }
  56160. declare module BABYLON {
  56161. /**
  56162. * Class containing a set of static utilities functions for screenshots
  56163. */
  56164. export class ScreenshotTools {
  56165. /**
  56166. * Captures a screenshot of the current rendering
  56167. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56168. * @param engine defines the rendering engine
  56169. * @param camera defines the source camera
  56170. * @param size This parameter can be set to a single number or to an object with the
  56171. * following (optional) properties: precision, width, height. If a single number is passed,
  56172. * it will be used for both width and height. If an object is passed, the screenshot size
  56173. * will be derived from the parameters. The precision property is a multiplier allowing
  56174. * rendering at a higher or lower resolution
  56175. * @param successCallback defines the callback receives a single parameter which contains the
  56176. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56177. * src parameter of an <img> to display it
  56178. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56179. * Check your browser for supported MIME types
  56180. */
  56181. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56182. /**
  56183. * Generates an image screenshot from the specified camera.
  56184. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56185. * @param engine The engine to use for rendering
  56186. * @param camera The camera to use for rendering
  56187. * @param size This parameter can be set to a single number or to an object with the
  56188. * following (optional) properties: precision, width, height. If a single number is passed,
  56189. * it will be used for both width and height. If an object is passed, the screenshot size
  56190. * will be derived from the parameters. The precision property is a multiplier allowing
  56191. * rendering at a higher or lower resolution
  56192. * @param successCallback The callback receives a single parameter which contains the
  56193. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56194. * src parameter of an <img> to display it
  56195. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56196. * Check your browser for supported MIME types
  56197. * @param samples Texture samples (default: 1)
  56198. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56199. * @param fileName A name for for the downloaded file.
  56200. */
  56201. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56202. }
  56203. }
  56204. declare module BABYLON {
  56205. /**
  56206. * A cursor which tracks a point on a path
  56207. */
  56208. export class PathCursor {
  56209. private path;
  56210. /**
  56211. * Stores path cursor callbacks for when an onchange event is triggered
  56212. */
  56213. private _onchange;
  56214. /**
  56215. * The value of the path cursor
  56216. */
  56217. value: number;
  56218. /**
  56219. * The animation array of the path cursor
  56220. */
  56221. animations: Animation[];
  56222. /**
  56223. * Initializes the path cursor
  56224. * @param path The path to track
  56225. */
  56226. constructor(path: Path2);
  56227. /**
  56228. * Gets the cursor point on the path
  56229. * @returns A point on the path cursor at the cursor location
  56230. */
  56231. getPoint(): Vector3;
  56232. /**
  56233. * Moves the cursor ahead by the step amount
  56234. * @param step The amount to move the cursor forward
  56235. * @returns This path cursor
  56236. */
  56237. moveAhead(step?: number): PathCursor;
  56238. /**
  56239. * Moves the cursor behind by the step amount
  56240. * @param step The amount to move the cursor back
  56241. * @returns This path cursor
  56242. */
  56243. moveBack(step?: number): PathCursor;
  56244. /**
  56245. * Moves the cursor by the step amount
  56246. * If the step amount is greater than one, an exception is thrown
  56247. * @param step The amount to move the cursor
  56248. * @returns This path cursor
  56249. */
  56250. move(step: number): PathCursor;
  56251. /**
  56252. * Ensures that the value is limited between zero and one
  56253. * @returns This path cursor
  56254. */
  56255. private ensureLimits;
  56256. /**
  56257. * Runs onchange callbacks on change (used by the animation engine)
  56258. * @returns This path cursor
  56259. */
  56260. private raiseOnChange;
  56261. /**
  56262. * Executes a function on change
  56263. * @param f A path cursor onchange callback
  56264. * @returns This path cursor
  56265. */
  56266. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56267. }
  56268. }
  56269. declare module BABYLON {
  56270. /** @hidden */
  56271. export var blurPixelShader: {
  56272. name: string;
  56273. shader: string;
  56274. };
  56275. }
  56276. declare module BABYLON {
  56277. /** @hidden */
  56278. export var bones300Declaration: {
  56279. name: string;
  56280. shader: string;
  56281. };
  56282. }
  56283. declare module BABYLON {
  56284. /** @hidden */
  56285. export var instances300Declaration: {
  56286. name: string;
  56287. shader: string;
  56288. };
  56289. }
  56290. declare module BABYLON {
  56291. /** @hidden */
  56292. export var pointCloudVertexDeclaration: {
  56293. name: string;
  56294. shader: string;
  56295. };
  56296. }
  56297. // Mixins
  56298. interface Window {
  56299. mozIndexedDB: IDBFactory;
  56300. webkitIndexedDB: IDBFactory;
  56301. msIndexedDB: IDBFactory;
  56302. webkitURL: typeof URL;
  56303. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56304. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56305. WebGLRenderingContext: WebGLRenderingContext;
  56306. MSGesture: MSGesture;
  56307. CANNON: any;
  56308. AudioContext: AudioContext;
  56309. webkitAudioContext: AudioContext;
  56310. PointerEvent: any;
  56311. Math: Math;
  56312. Uint8Array: Uint8ArrayConstructor;
  56313. Float32Array: Float32ArrayConstructor;
  56314. mozURL: typeof URL;
  56315. msURL: typeof URL;
  56316. VRFrameData: any; // WebVR, from specs 1.1
  56317. DracoDecoderModule: any;
  56318. setImmediate(handler: (...args: any[]) => void): number;
  56319. }
  56320. interface HTMLCanvasElement {
  56321. requestPointerLock(): void;
  56322. msRequestPointerLock?(): void;
  56323. mozRequestPointerLock?(): void;
  56324. webkitRequestPointerLock?(): void;
  56325. /** Track wether a record is in progress */
  56326. isRecording: boolean;
  56327. /** Capture Stream method defined by some browsers */
  56328. captureStream(fps?: number): MediaStream;
  56329. }
  56330. interface CanvasRenderingContext2D {
  56331. msImageSmoothingEnabled: boolean;
  56332. }
  56333. interface MouseEvent {
  56334. mozMovementX: number;
  56335. mozMovementY: number;
  56336. webkitMovementX: number;
  56337. webkitMovementY: number;
  56338. msMovementX: number;
  56339. msMovementY: number;
  56340. }
  56341. interface Navigator {
  56342. mozGetVRDevices: (any: any) => any;
  56343. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56344. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56345. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56346. webkitGetGamepads(): Gamepad[];
  56347. msGetGamepads(): Gamepad[];
  56348. webkitGamepads(): Gamepad[];
  56349. }
  56350. interface HTMLVideoElement {
  56351. mozSrcObject: any;
  56352. }
  56353. interface Math {
  56354. fround(x: number): number;
  56355. imul(a: number, b: number): number;
  56356. }
  56357. interface WebGLProgram {
  56358. context?: WebGLRenderingContext;
  56359. vertexShader?: WebGLShader;
  56360. fragmentShader?: WebGLShader;
  56361. isParallelCompiled: boolean;
  56362. onCompiled?: () => void;
  56363. }
  56364. interface WebGLRenderingContext {
  56365. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56366. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56367. vertexAttribDivisor(index: number, divisor: number): void;
  56368. createVertexArray(): any;
  56369. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56370. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56371. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56372. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56373. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56374. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56375. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56376. // Queries
  56377. createQuery(): WebGLQuery;
  56378. deleteQuery(query: WebGLQuery): void;
  56379. beginQuery(target: number, query: WebGLQuery): void;
  56380. endQuery(target: number): void;
  56381. getQueryParameter(query: WebGLQuery, pname: number): any;
  56382. getQuery(target: number, pname: number): any;
  56383. MAX_SAMPLES: number;
  56384. RGBA8: number;
  56385. READ_FRAMEBUFFER: number;
  56386. DRAW_FRAMEBUFFER: number;
  56387. UNIFORM_BUFFER: number;
  56388. HALF_FLOAT_OES: number;
  56389. RGBA16F: number;
  56390. RGBA32F: number;
  56391. R32F: number;
  56392. RG32F: number;
  56393. RGB32F: number;
  56394. R16F: number;
  56395. RG16F: number;
  56396. RGB16F: number;
  56397. RED: number;
  56398. RG: number;
  56399. R8: number;
  56400. RG8: number;
  56401. UNSIGNED_INT_24_8: number;
  56402. DEPTH24_STENCIL8: number;
  56403. /* Multiple Render Targets */
  56404. drawBuffers(buffers: number[]): void;
  56405. readBuffer(src: number): void;
  56406. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56407. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56408. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56409. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56410. // Occlusion Query
  56411. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56412. ANY_SAMPLES_PASSED: number;
  56413. QUERY_RESULT_AVAILABLE: number;
  56414. QUERY_RESULT: number;
  56415. }
  56416. interface WebGLBuffer {
  56417. references: number;
  56418. capacity: number;
  56419. is32Bits: boolean;
  56420. }
  56421. interface WebGLProgram {
  56422. transformFeedback?: WebGLTransformFeedback | null;
  56423. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56424. }
  56425. interface EXT_disjoint_timer_query {
  56426. QUERY_COUNTER_BITS_EXT: number;
  56427. TIME_ELAPSED_EXT: number;
  56428. TIMESTAMP_EXT: number;
  56429. GPU_DISJOINT_EXT: number;
  56430. QUERY_RESULT_EXT: number;
  56431. QUERY_RESULT_AVAILABLE_EXT: number;
  56432. queryCounterEXT(query: WebGLQuery, target: number): void;
  56433. createQueryEXT(): WebGLQuery;
  56434. beginQueryEXT(target: number, query: WebGLQuery): void;
  56435. endQueryEXT(target: number): void;
  56436. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56437. deleteQueryEXT(query: WebGLQuery): void;
  56438. }
  56439. interface WebGLUniformLocation {
  56440. _currentState: any;
  56441. }
  56442. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56443. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56444. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56445. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56446. interface WebGLRenderingContext {
  56447. readonly RASTERIZER_DISCARD: number;
  56448. readonly DEPTH_COMPONENT24: number;
  56449. readonly TEXTURE_3D: number;
  56450. readonly TEXTURE_2D_ARRAY: number;
  56451. readonly TEXTURE_COMPARE_FUNC: number;
  56452. readonly TEXTURE_COMPARE_MODE: number;
  56453. readonly COMPARE_REF_TO_TEXTURE: number;
  56454. readonly TEXTURE_WRAP_R: number;
  56455. readonly HALF_FLOAT: number;
  56456. readonly RGB8: number;
  56457. readonly RED_INTEGER: number;
  56458. readonly RG_INTEGER: number;
  56459. readonly RGB_INTEGER: number;
  56460. readonly RGBA_INTEGER: number;
  56461. readonly R8_SNORM: number;
  56462. readonly RG8_SNORM: number;
  56463. readonly RGB8_SNORM: number;
  56464. readonly RGBA8_SNORM: number;
  56465. readonly R8I: number;
  56466. readonly RG8I: number;
  56467. readonly RGB8I: number;
  56468. readonly RGBA8I: number;
  56469. readonly R8UI: number;
  56470. readonly RG8UI: number;
  56471. readonly RGB8UI: number;
  56472. readonly RGBA8UI: number;
  56473. readonly R16I: number;
  56474. readonly RG16I: number;
  56475. readonly RGB16I: number;
  56476. readonly RGBA16I: number;
  56477. readonly R16UI: number;
  56478. readonly RG16UI: number;
  56479. readonly RGB16UI: number;
  56480. readonly RGBA16UI: number;
  56481. readonly R32I: number;
  56482. readonly RG32I: number;
  56483. readonly RGB32I: number;
  56484. readonly RGBA32I: number;
  56485. readonly R32UI: number;
  56486. readonly RG32UI: number;
  56487. readonly RGB32UI: number;
  56488. readonly RGBA32UI: number;
  56489. readonly RGB10_A2UI: number;
  56490. readonly R11F_G11F_B10F: number;
  56491. readonly RGB9_E5: number;
  56492. readonly RGB10_A2: number;
  56493. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56494. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56495. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56496. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56497. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56498. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56499. 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;
  56500. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56501. readonly TRANSFORM_FEEDBACK: number;
  56502. readonly INTERLEAVED_ATTRIBS: number;
  56503. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56504. createTransformFeedback(): WebGLTransformFeedback;
  56505. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56506. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56507. beginTransformFeedback(primitiveMode: number): void;
  56508. endTransformFeedback(): void;
  56509. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56510. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56511. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56512. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56513. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56514. }
  56515. interface ImageBitmap {
  56516. readonly width: number;
  56517. readonly height: number;
  56518. close(): void;
  56519. }
  56520. interface WebGLQuery extends WebGLObject {
  56521. }
  56522. declare var WebGLQuery: {
  56523. prototype: WebGLQuery;
  56524. new(): WebGLQuery;
  56525. };
  56526. interface WebGLSampler extends WebGLObject {
  56527. }
  56528. declare var WebGLSampler: {
  56529. prototype: WebGLSampler;
  56530. new(): WebGLSampler;
  56531. };
  56532. interface WebGLSync extends WebGLObject {
  56533. }
  56534. declare var WebGLSync: {
  56535. prototype: WebGLSync;
  56536. new(): WebGLSync;
  56537. };
  56538. interface WebGLTransformFeedback extends WebGLObject {
  56539. }
  56540. declare var WebGLTransformFeedback: {
  56541. prototype: WebGLTransformFeedback;
  56542. new(): WebGLTransformFeedback;
  56543. };
  56544. interface WebGLVertexArrayObject extends WebGLObject {
  56545. }
  56546. declare var WebGLVertexArrayObject: {
  56547. prototype: WebGLVertexArrayObject;
  56548. new(): WebGLVertexArrayObject;
  56549. };
  56550. // Type definitions for WebVR API
  56551. // Project: https://w3c.github.io/webvr/
  56552. // Definitions by: six a <https://github.com/lostfictions>
  56553. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56554. interface VRDisplay extends EventTarget {
  56555. /**
  56556. * Dictionary of capabilities describing the VRDisplay.
  56557. */
  56558. readonly capabilities: VRDisplayCapabilities;
  56559. /**
  56560. * z-depth defining the far plane of the eye view frustum
  56561. * enables mapping of values in the render target depth
  56562. * attachment to scene coordinates. Initially set to 10000.0.
  56563. */
  56564. depthFar: number;
  56565. /**
  56566. * z-depth defining the near plane of the eye view frustum
  56567. * enables mapping of values in the render target depth
  56568. * attachment to scene coordinates. Initially set to 0.01.
  56569. */
  56570. depthNear: number;
  56571. /**
  56572. * An identifier for this distinct VRDisplay. Used as an
  56573. * association point in the Gamepad API.
  56574. */
  56575. readonly displayId: number;
  56576. /**
  56577. * A display name, a user-readable name identifying it.
  56578. */
  56579. readonly displayName: string;
  56580. readonly isConnected: boolean;
  56581. readonly isPresenting: boolean;
  56582. /**
  56583. * If this VRDisplay supports room-scale experiences, the optional
  56584. * stage attribute contains details on the room-scale parameters.
  56585. */
  56586. readonly stageParameters: VRStageParameters | null;
  56587. /**
  56588. * Passing the value returned by `requestAnimationFrame` to
  56589. * `cancelAnimationFrame` will unregister the callback.
  56590. * @param handle Define the hanle of the request to cancel
  56591. */
  56592. cancelAnimationFrame(handle: number): void;
  56593. /**
  56594. * Stops presenting to the VRDisplay.
  56595. * @returns a promise to know when it stopped
  56596. */
  56597. exitPresent(): Promise<void>;
  56598. /**
  56599. * Return the current VREyeParameters for the given eye.
  56600. * @param whichEye Define the eye we want the parameter for
  56601. * @returns the eye parameters
  56602. */
  56603. getEyeParameters(whichEye: string): VREyeParameters;
  56604. /**
  56605. * Populates the passed VRFrameData with the information required to render
  56606. * the current frame.
  56607. * @param frameData Define the data structure to populate
  56608. * @returns true if ok otherwise false
  56609. */
  56610. getFrameData(frameData: VRFrameData): boolean;
  56611. /**
  56612. * Get the layers currently being presented.
  56613. * @returns the list of VR layers
  56614. */
  56615. getLayers(): VRLayer[];
  56616. /**
  56617. * Return a VRPose containing the future predicted pose of the VRDisplay
  56618. * when the current frame will be presented. The value returned will not
  56619. * change until JavaScript has returned control to the browser.
  56620. *
  56621. * The VRPose will contain the position, orientation, velocity,
  56622. * and acceleration of each of these properties.
  56623. * @returns the pose object
  56624. */
  56625. getPose(): VRPose;
  56626. /**
  56627. * Return the current instantaneous pose of the VRDisplay, with no
  56628. * prediction applied.
  56629. * @returns the current instantaneous pose
  56630. */
  56631. getImmediatePose(): VRPose;
  56632. /**
  56633. * The callback passed to `requestAnimationFrame` will be called
  56634. * any time a new frame should be rendered. When the VRDisplay is
  56635. * presenting the callback will be called at the native refresh
  56636. * rate of the HMD. When not presenting this function acts
  56637. * identically to how window.requestAnimationFrame acts. Content should
  56638. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56639. * asynchronously from other displays and at differing refresh rates.
  56640. * @param callback Define the eaction to run next frame
  56641. * @returns the request handle it
  56642. */
  56643. requestAnimationFrame(callback: FrameRequestCallback): number;
  56644. /**
  56645. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56646. * Repeat calls while already presenting will update the VRLayers being displayed.
  56647. * @param layers Define the list of layer to present
  56648. * @returns a promise to know when the request has been fulfilled
  56649. */
  56650. requestPresent(layers: VRLayer[]): Promise<void>;
  56651. /**
  56652. * Reset the pose for this display, treating its current position and
  56653. * orientation as the "origin/zero" values. VRPose.position,
  56654. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56655. * updated when calling resetPose(). This should be called in only
  56656. * sitting-space experiences.
  56657. */
  56658. resetPose(): void;
  56659. /**
  56660. * The VRLayer provided to the VRDisplay will be captured and presented
  56661. * in the HMD. Calling this function has the same effect on the source
  56662. * canvas as any other operation that uses its source image, and canvases
  56663. * created without preserveDrawingBuffer set to true will be cleared.
  56664. * @param pose Define the pose to submit
  56665. */
  56666. submitFrame(pose?: VRPose): void;
  56667. }
  56668. declare var VRDisplay: {
  56669. prototype: VRDisplay;
  56670. new(): VRDisplay;
  56671. };
  56672. interface VRLayer {
  56673. leftBounds?: number[] | Float32Array | null;
  56674. rightBounds?: number[] | Float32Array | null;
  56675. source?: HTMLCanvasElement | null;
  56676. }
  56677. interface VRDisplayCapabilities {
  56678. readonly canPresent: boolean;
  56679. readonly hasExternalDisplay: boolean;
  56680. readonly hasOrientation: boolean;
  56681. readonly hasPosition: boolean;
  56682. readonly maxLayers: number;
  56683. }
  56684. interface VREyeParameters {
  56685. /** @deprecated */
  56686. readonly fieldOfView: VRFieldOfView;
  56687. readonly offset: Float32Array;
  56688. readonly renderHeight: number;
  56689. readonly renderWidth: number;
  56690. }
  56691. interface VRFieldOfView {
  56692. readonly downDegrees: number;
  56693. readonly leftDegrees: number;
  56694. readonly rightDegrees: number;
  56695. readonly upDegrees: number;
  56696. }
  56697. interface VRFrameData {
  56698. readonly leftProjectionMatrix: Float32Array;
  56699. readonly leftViewMatrix: Float32Array;
  56700. readonly pose: VRPose;
  56701. readonly rightProjectionMatrix: Float32Array;
  56702. readonly rightViewMatrix: Float32Array;
  56703. readonly timestamp: number;
  56704. }
  56705. interface VRPose {
  56706. readonly angularAcceleration: Float32Array | null;
  56707. readonly angularVelocity: Float32Array | null;
  56708. readonly linearAcceleration: Float32Array | null;
  56709. readonly linearVelocity: Float32Array | null;
  56710. readonly orientation: Float32Array | null;
  56711. readonly position: Float32Array | null;
  56712. readonly timestamp: number;
  56713. }
  56714. interface VRStageParameters {
  56715. sittingToStandingTransform?: Float32Array;
  56716. sizeX?: number;
  56717. sizeY?: number;
  56718. }
  56719. interface Navigator {
  56720. getVRDisplays(): Promise<VRDisplay[]>;
  56721. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56722. }
  56723. interface Window {
  56724. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56725. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56726. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56727. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56728. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56729. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56730. }
  56731. interface Gamepad {
  56732. readonly displayId: number;
  56733. }
  56734. interface XRDevice {
  56735. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56736. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56737. }
  56738. interface XRSession {
  56739. getInputSources(): Array<any>;
  56740. baseLayer: XRWebGLLayer;
  56741. requestFrameOfReference(type: string): Promise<void>;
  56742. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56743. end(): Promise<void>;
  56744. requestAnimationFrame: Function;
  56745. addEventListener: Function;
  56746. }
  56747. interface XRSessionCreationOptions {
  56748. outputContext?: WebGLRenderingContext | null;
  56749. immersive?: boolean;
  56750. environmentIntegration?: boolean;
  56751. }
  56752. interface XRLayer {
  56753. getViewport: Function;
  56754. framebufferWidth: number;
  56755. framebufferHeight: number;
  56756. }
  56757. interface XRView {
  56758. projectionMatrix: Float32Array;
  56759. }
  56760. interface XRFrame {
  56761. getDevicePose: Function;
  56762. getInputPose: Function;
  56763. views: Array<XRView>;
  56764. baseLayer: XRLayer;
  56765. }
  56766. interface XRFrameOfReference {
  56767. }
  56768. interface XRWebGLLayer extends XRLayer {
  56769. framebuffer: WebGLFramebuffer;
  56770. }
  56771. declare var XRWebGLLayer: {
  56772. prototype: XRWebGLLayer;
  56773. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56774. };