babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. private _moveAssets;
  165. /**
  166. * Removes all the assets contained in the scene and adds them to the container.
  167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  168. */
  169. moveAllFromScene(keepAssets?: KeepAssets): void;
  170. /**
  171. * 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.
  172. * @returns the root mesh
  173. */
  174. createRootMesh(): Mesh;
  175. }
  176. }
  177. interface Window {
  178. mozIndexedDB: IDBFactory;
  179. webkitIndexedDB: IDBFactory;
  180. msIndexedDB: IDBFactory;
  181. webkitURL: typeof URL;
  182. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  183. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  184. WebGLRenderingContext: WebGLRenderingContext;
  185. MSGesture: MSGesture;
  186. CANNON: any;
  187. AudioContext: AudioContext;
  188. webkitAudioContext: AudioContext;
  189. PointerEvent: any;
  190. Math: Math;
  191. Uint8Array: Uint8ArrayConstructor;
  192. Float32Array: Float32ArrayConstructor;
  193. mozURL: typeof URL;
  194. msURL: typeof URL;
  195. VRFrameData: any;
  196. DracoDecoderModule: any;
  197. setImmediate(handler: (...args: any[]) => void): number;
  198. }
  199. interface WebGLProgram {
  200. context?: WebGLRenderingContext;
  201. vertexShader?: WebGLShader;
  202. fragmentShader?: WebGLShader;
  203. isParallelCompiled: boolean;
  204. onCompiled?: () => void;
  205. }
  206. interface WebGLRenderingContext {
  207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  209. vertexAttribDivisor(index: number, divisor: number): void;
  210. createVertexArray(): any;
  211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  218. createQuery(): WebGLQuery;
  219. deleteQuery(query: WebGLQuery): void;
  220. beginQuery(target: number, query: WebGLQuery): void;
  221. endQuery(target: number): void;
  222. getQueryParameter(query: WebGLQuery, pname: number): any;
  223. getQuery(target: number, pname: number): any;
  224. MAX_SAMPLES: number;
  225. RGBA8: number;
  226. READ_FRAMEBUFFER: number;
  227. DRAW_FRAMEBUFFER: number;
  228. UNIFORM_BUFFER: number;
  229. HALF_FLOAT_OES: number;
  230. RGBA16F: number;
  231. RGBA32F: number;
  232. R32F: number;
  233. RG32F: number;
  234. RGB32F: number;
  235. R16F: number;
  236. RG16F: number;
  237. RGB16F: number;
  238. RED: number;
  239. RG: number;
  240. R8: number;
  241. RG8: number;
  242. UNSIGNED_INT_24_8: number;
  243. DEPTH24_STENCIL8: number;
  244. drawBuffers(buffers: number[]): void;
  245. readBuffer(src: number): void;
  246. readonly COLOR_ATTACHMENT0: number;
  247. readonly COLOR_ATTACHMENT1: number;
  248. readonly COLOR_ATTACHMENT2: number;
  249. readonly COLOR_ATTACHMENT3: number;
  250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  251. ANY_SAMPLES_PASSED: number;
  252. QUERY_RESULT_AVAILABLE: number;
  253. QUERY_RESULT: number;
  254. }
  255. interface Document {
  256. mozCancelFullScreen(): void;
  257. msCancelFullScreen(): void;
  258. webkitCancelFullScreen(): void;
  259. requestPointerLock(): void;
  260. exitPointerLock(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. readonly webkitIsFullScreen: boolean;
  264. readonly pointerLockElement: Element;
  265. mozPointerLockElement: HTMLElement;
  266. msPointerLockElement: HTMLElement;
  267. webkitPointerLockElement: HTMLElement;
  268. }
  269. interface HTMLCanvasElement {
  270. requestPointerLock(): void;
  271. msRequestPointerLock?(): void;
  272. mozRequestPointerLock?(): void;
  273. webkitRequestPointerLock?(): void;
  274. }
  275. interface CanvasRenderingContext2D {
  276. msImageSmoothingEnabled: boolean;
  277. }
  278. interface WebGLBuffer {
  279. references: number;
  280. capacity: number;
  281. is32Bits: boolean;
  282. }
  283. interface WebGLProgram {
  284. transformFeedback?: WebGLTransformFeedback | null;
  285. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  286. }
  287. interface MouseEvent {
  288. mozMovementX: number;
  289. mozMovementY: number;
  290. webkitMovementX: number;
  291. webkitMovementY: number;
  292. msMovementX: number;
  293. msMovementY: number;
  294. }
  295. interface Navigator {
  296. mozGetVRDevices: (any: any) => any;
  297. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. webkitGetGamepads(): Gamepad[];
  301. msGetGamepads(): Gamepad[];
  302. webkitGamepads(): Gamepad[];
  303. }
  304. interface HTMLVideoElement {
  305. mozSrcObject: any;
  306. }
  307. interface Math {
  308. fround(x: number): number;
  309. imul(a: number, b: number): number;
  310. }
  311. interface EXT_disjoint_timer_query {
  312. QUERY_COUNTER_BITS_EXT: number;
  313. TIME_ELAPSED_EXT: number;
  314. TIMESTAMP_EXT: number;
  315. GPU_DISJOINT_EXT: number;
  316. QUERY_RESULT_EXT: number;
  317. QUERY_RESULT_AVAILABLE_EXT: number;
  318. queryCounterEXT(query: WebGLQuery, target: number): void;
  319. createQueryEXT(): WebGLQuery;
  320. beginQueryEXT(target: number, query: WebGLQuery): void;
  321. endQueryEXT(target: number): void;
  322. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  323. deleteQueryEXT(query: WebGLQuery): void;
  324. }
  325. interface WebGLUniformLocation {
  326. _currentState: any;
  327. }
  328. interface XRDevice {
  329. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  330. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  331. }
  332. interface XRSession {
  333. getInputSources(): Array<any>;
  334. baseLayer: XRWebGLLayer;
  335. requestFrameOfReference(type: string): Promise<void>;
  336. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  337. end(): Promise<void>;
  338. requestAnimationFrame: Function;
  339. addEventListener: Function;
  340. }
  341. interface XRSessionCreationOptions {
  342. outputContext?: WebGLRenderingContext | null;
  343. immersive?: boolean;
  344. environmentIntegration?: boolean;
  345. }
  346. interface XRLayer {
  347. getViewport: Function;
  348. framebufferWidth: number;
  349. framebufferHeight: number;
  350. }
  351. interface XRView {
  352. projectionMatrix: Float32Array;
  353. }
  354. interface XRFrame {
  355. getDevicePose: Function;
  356. getInputPose: Function;
  357. views: Array<XRView>;
  358. baseLayer: XRLayer;
  359. }
  360. interface XRFrameOfReference {
  361. }
  362. interface XRWebGLLayer extends XRLayer {
  363. framebuffer: WebGLFramebuffer;
  364. }
  365. declare var XRWebGLLayer: {
  366. prototype: XRWebGLLayer;
  367. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  368. };
  369. declare module BABYLON {
  370. /**
  371. * Defines how a node can be built from a string name.
  372. */
  373. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  374. /**
  375. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  376. */
  377. class Node implements IBehaviorAware<Node> {
  378. private static _NodeConstructors;
  379. /**
  380. * Add a new node constructor
  381. * @param type defines the type name of the node to construct
  382. * @param constructorFunc defines the constructor function
  383. */
  384. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  385. /**
  386. * Returns a node constructor based on type name
  387. * @param type defines the type name
  388. * @param name defines the new node name
  389. * @param scene defines the hosting scene
  390. * @param options defines optional options to transmit to constructors
  391. * @returns the new constructor or null
  392. */
  393. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  394. /**
  395. * Gets or sets the name of the node
  396. */
  397. name: string;
  398. /**
  399. * Gets or sets the id of the node
  400. */
  401. id: string;
  402. /**
  403. * Gets or sets the unique id of the node
  404. */
  405. uniqueId: number;
  406. /**
  407. * Gets or sets a string used to store user defined state for the node
  408. */
  409. state: string;
  410. /**
  411. * Gets or sets an object used to store user defined information for the node
  412. */
  413. metadata: any;
  414. /**
  415. * Gets or sets a boolean used to define if the node must be serialized
  416. */
  417. doNotSerialize: boolean;
  418. /** @hidden */
  419. _isDisposed: boolean;
  420. /**
  421. * Gets a list of Animations associated with the node
  422. */
  423. animations: Animation[];
  424. protected _ranges: {
  425. [name: string]: Nullable<AnimationRange>;
  426. };
  427. /**
  428. * Callback raised when the node is ready to be used
  429. */
  430. onReady: (node: Node) => void;
  431. private _isEnabled;
  432. private _isParentEnabled;
  433. private _isReady;
  434. /** @hidden */
  435. _currentRenderId: number;
  436. private _parentRenderId;
  437. protected _childRenderId: number;
  438. /** @hidden */
  439. _waitingParentId: Nullable<string>;
  440. /** @hidden */
  441. _scene: Scene;
  442. /** @hidden */
  443. _cache: any;
  444. private _parentNode;
  445. private _children;
  446. /** @hidden */
  447. _worldMatrix: Matrix;
  448. /** @hidden */
  449. _worldMatrixDeterminant: number;
  450. /** @hidden */
  451. private _sceneRootNodesIndex;
  452. /**
  453. * Gets a boolean indicating if the node has been disposed
  454. * @returns true if the node was disposed
  455. */
  456. isDisposed(): boolean;
  457. /**
  458. * Gets or sets the parent of the node
  459. */
  460. parent: Nullable<Node>;
  461. private addToSceneRootNodes;
  462. private removeFromSceneRootNodes;
  463. private _animationPropertiesOverride;
  464. /**
  465. * Gets or sets the animation properties override
  466. */
  467. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  468. /**
  469. * Gets a string idenfifying the name of the class
  470. * @returns "Node" string
  471. */
  472. getClassName(): string;
  473. /**
  474. * An event triggered when the mesh is disposed
  475. */
  476. onDisposeObservable: Observable<Node>;
  477. private _onDisposeObserver;
  478. /**
  479. * Sets a callback that will be raised when the node will be disposed
  480. */
  481. onDispose: () => void;
  482. /**
  483. * Creates a new Node
  484. * @param name the name and id to be given to this node
  485. * @param scene the scene this node will be added to
  486. * @param addToRootNodes the node will be added to scene.rootNodes
  487. */
  488. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  489. /**
  490. * Gets the scene of the node
  491. * @returns a scene
  492. */
  493. getScene(): Scene;
  494. /**
  495. * Gets the engine of the node
  496. * @returns a Engine
  497. */
  498. getEngine(): Engine;
  499. private _behaviors;
  500. /**
  501. * Attach a behavior to the node
  502. * @see http://doc.babylonjs.com/features/behaviour
  503. * @param behavior defines the behavior to attach
  504. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  505. * @returns the current Node
  506. */
  507. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  508. /**
  509. * Remove an attached behavior
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @returns the current Node
  513. */
  514. removeBehavior(behavior: Behavior<Node>): Node;
  515. /**
  516. * Gets the list of attached behaviors
  517. * @see http://doc.babylonjs.com/features/behaviour
  518. */
  519. readonly behaviors: Behavior<Node>[];
  520. /**
  521. * Gets an attached behavior by name
  522. * @param name defines the name of the behavior to look for
  523. * @see http://doc.babylonjs.com/features/behaviour
  524. * @returns null if behavior was not found else the requested behavior
  525. */
  526. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  527. /**
  528. * Returns the latest update of the World matrix
  529. * @returns a Matrix
  530. */
  531. getWorldMatrix(): Matrix;
  532. /** @hidden */
  533. _getWorldMatrixDeterminant(): number;
  534. /**
  535. * Returns directly the latest state of the mesh World matrix.
  536. * A Matrix is returned.
  537. */
  538. readonly worldMatrixFromCache: Matrix;
  539. /** @hidden */
  540. _initCache(): void;
  541. /** @hidden */
  542. updateCache(force?: boolean): void;
  543. /** @hidden */
  544. _updateCache(ignoreParentClass?: boolean): void;
  545. /** @hidden */
  546. _isSynchronized(): boolean;
  547. /** @hidden */
  548. _markSyncedWithParent(): void;
  549. /** @hidden */
  550. isSynchronizedWithParent(): boolean;
  551. /** @hidden */
  552. isSynchronized(): boolean;
  553. /**
  554. * Is this node ready to be used/rendered
  555. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  556. * @return true if the node is ready
  557. */
  558. isReady(completeCheck?: boolean): boolean;
  559. /**
  560. * Is this node enabled?
  561. * 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
  562. * @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
  563. * @return whether this node (and its parent) is enabled
  564. */
  565. isEnabled(checkAncestors?: boolean): boolean;
  566. /** @hidden */
  567. protected _syncParentEnabledState(): void;
  568. /**
  569. * Set the enabled state of this node
  570. * @param value defines the new enabled state
  571. */
  572. setEnabled(value: boolean): void;
  573. /**
  574. * Is this node a descendant of the given node?
  575. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  576. * @param ancestor defines the parent node to inspect
  577. * @returns a boolean indicating if this node is a descendant of the given node
  578. */
  579. isDescendantOf(ancestor: Node): boolean;
  580. /** @hidden */
  581. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  582. /**
  583. * Will return all nodes that have this node as ascendant
  584. * @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
  585. * @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
  586. * @return all children nodes of all types
  587. */
  588. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  589. /**
  590. * Get all child-meshes of this node
  591. * @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
  592. * @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
  593. * @returns an array of AbstractMesh
  594. */
  595. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  596. /**
  597. * Get all child-transformNodes of this node
  598. * @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
  599. * @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
  600. * @returns an array of TransformNode
  601. */
  602. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  603. /**
  604. * Get all direct children of this node
  605. * @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
  606. * @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)
  607. * @returns an array of Node
  608. */
  609. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  610. /** @hidden */
  611. _setReady(state: boolean): void;
  612. /**
  613. * Get an animation by name
  614. * @param name defines the name of the animation to look for
  615. * @returns null if not found else the requested animation
  616. */
  617. getAnimationByName(name: string): Nullable<Animation>;
  618. /**
  619. * Creates an animation range for this node
  620. * @param name defines the name of the range
  621. * @param from defines the starting key
  622. * @param to defines the end key
  623. */
  624. createAnimationRange(name: string, from: number, to: number): void;
  625. /**
  626. * Delete a specific animation range
  627. * @param name defines the name of the range to delete
  628. * @param deleteFrames defines if animation frames from the range must be deleted as well
  629. */
  630. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  631. /**
  632. * Get an animation range by name
  633. * @param name defines the name of the animation range to look for
  634. * @returns null if not found else the requested animation range
  635. */
  636. getAnimationRange(name: string): Nullable<AnimationRange>;
  637. /**
  638. * Will start the animation sequence
  639. * @param name defines the range frames for animation sequence
  640. * @param loop defines if the animation should loop (false by default)
  641. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  642. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  643. * @returns the object created for this animation. If range does not exist, it will return null
  644. */
  645. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  646. /**
  647. * Serialize animation ranges into a JSON compatible object
  648. * @returns serialization object
  649. */
  650. serializeAnimationRanges(): any;
  651. /**
  652. * Computes the world matrix of the node
  653. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  654. * @returns the world matrix
  655. */
  656. computeWorldMatrix(force?: boolean): Matrix;
  657. /**
  658. * Releases resources associated with this node.
  659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  661. */
  662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  663. /**
  664. * Parse animation range data from a serialization object and store them into a given node
  665. * @param node defines where to store the animation ranges
  666. * @param parsedNode defines the serialization object to read data from
  667. * @param scene defines the hosting scene
  668. */
  669. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  670. }
  671. }
  672. declare module BABYLON {
  673. /**
  674. * Define an interface for all classes that will hold resources
  675. */
  676. interface IDisposable {
  677. /**
  678. * Releases all held resources
  679. */
  680. dispose(): void;
  681. }
  682. /**
  683. * This class is used by the onRenderingGroupObservable
  684. */
  685. class RenderingGroupInfo {
  686. /**
  687. * The Scene that being rendered
  688. */
  689. scene: Scene;
  690. /**
  691. * The camera currently used for the rendering pass
  692. */
  693. camera: Nullable<Camera>;
  694. /**
  695. * The ID of the renderingGroup being processed
  696. */
  697. renderingGroupId: number;
  698. }
  699. /** Interface defining initialization parameters for Scene class */
  700. interface SceneOptions {
  701. /**
  702. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  703. * It will improve performance when the number of geometries becomes important.
  704. */
  705. useGeometryIdsMap?: boolean;
  706. /**
  707. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  708. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  709. */
  710. useMaterialMeshMap?: boolean;
  711. /**
  712. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  713. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  714. */
  715. useClonedMeshhMap?: boolean;
  716. }
  717. /**
  718. * Represents a scene to be rendered by the engine.
  719. * @see http://doc.babylonjs.com/features/scene
  720. */
  721. class Scene extends AbstractScene implements IAnimatable {
  722. private static _uniqueIdCounter;
  723. /** The fog is deactivated */
  724. static readonly FOGMODE_NONE: number;
  725. /** The fog density is following an exponential function */
  726. static readonly FOGMODE_EXP: number;
  727. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  728. static readonly FOGMODE_EXP2: number;
  729. /** The fog density is following a linear function. */
  730. static readonly FOGMODE_LINEAR: number;
  731. /**
  732. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  734. */
  735. static MinDeltaTime: number;
  736. /**
  737. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  739. */
  740. static MaxDeltaTime: number;
  741. /**
  742. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  743. */
  744. autoClear: boolean;
  745. /**
  746. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  747. */
  748. autoClearDepthAndStencil: boolean;
  749. /**
  750. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  751. */
  752. clearColor: Color4;
  753. /**
  754. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  755. */
  756. ambientColor: Color3;
  757. /** @hidden */
  758. _environmentBRDFTexture: BaseTexture;
  759. /** @hidden */
  760. protected _environmentTexture: BaseTexture;
  761. /**
  762. * Texture used in all pbr material as the reflection texture.
  763. * As in the majority of the scene they are the same (exception for multi room and so on),
  764. * this is easier to reference from here than from all the materials.
  765. */
  766. /**
  767. * Texture used in all pbr material as the reflection texture.
  768. * As in the majority of the scene they are the same (exception for multi room and so on),
  769. * this is easier to set here than in all the materials.
  770. */
  771. environmentTexture: BaseTexture;
  772. /** @hidden */
  773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  774. /**
  775. * Default image processing configuration used either in the rendering
  776. * Forward main pass or through the imageProcessingPostProcess if present.
  777. * As in the majority of the scene they are the same (exception for multi camera),
  778. * this is easier to reference from here than from all the materials and post process.
  779. *
  780. * No setter as we it is a shared configuration, you can set the values instead.
  781. */
  782. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  783. private _forceWireframe;
  784. /**
  785. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  786. */
  787. forceWireframe: boolean;
  788. private _forcePointsCloud;
  789. /**
  790. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  791. */
  792. forcePointsCloud: boolean;
  793. /**
  794. * Gets or sets the active clipplane 1
  795. */
  796. clipPlane: Nullable<Plane>;
  797. /**
  798. * Gets or sets the active clipplane 2
  799. */
  800. clipPlane2: Nullable<Plane>;
  801. /**
  802. * Gets or sets the active clipplane 3
  803. */
  804. clipPlane3: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 4
  807. */
  808. clipPlane4: Nullable<Plane>;
  809. /**
  810. * Gets or sets a boolean indicating if animations are enabled
  811. */
  812. animationsEnabled: boolean;
  813. private _animationPropertiesOverride;
  814. /**
  815. * Gets or sets the animation properties override
  816. */
  817. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  818. /**
  819. * Gets or sets a boolean indicating if a constant deltatime has to be used
  820. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  821. */
  822. useConstantAnimationDeltaTime: boolean;
  823. /**
  824. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  825. * Please note that it requires to run a ray cast through the scene on every frame
  826. */
  827. constantlyUpdateMeshUnderPointer: boolean;
  828. /**
  829. * Defines the HTML cursor to use when hovering over interactive elements
  830. */
  831. hoverCursor: string;
  832. /**
  833. * Defines the HTML default cursor to use (empty by default)
  834. */
  835. defaultCursor: string;
  836. /**
  837. * This is used to call preventDefault() on pointer down
  838. * in order to block unwanted artifacts like system double clicks
  839. */
  840. preventDefaultOnPointerDown: boolean;
  841. /**
  842. * This is used to call preventDefault() on pointer up
  843. * in order to block unwanted artifacts like system double clicks
  844. */
  845. preventDefaultOnPointerUp: boolean;
  846. /**
  847. * Gets or sets user defined metadata
  848. */
  849. metadata: any;
  850. /**
  851. * Gets the name of the plugin used to load this scene (null by default)
  852. */
  853. loadingPluginName: string;
  854. /**
  855. * Use this array to add regular expressions used to disable offline support for specific urls
  856. */
  857. disableOfflineSupportExceptionRules: RegExp[];
  858. /**
  859. * An event triggered when the scene is disposed.
  860. */
  861. onDisposeObservable: Observable<Scene>;
  862. private _onDisposeObserver;
  863. /** Sets a function to be executed when this scene is disposed. */
  864. onDispose: () => void;
  865. /**
  866. * An event triggered before rendering the scene (right after animations and physics)
  867. */
  868. onBeforeRenderObservable: Observable<Scene>;
  869. private _onBeforeRenderObserver;
  870. /** Sets a function to be executed before rendering this scene */
  871. beforeRender: Nullable<() => void>;
  872. /**
  873. * An event triggered after rendering the scene
  874. */
  875. onAfterRenderObservable: Observable<Scene>;
  876. private _onAfterRenderObserver;
  877. /** Sets a function to be executed after rendering this scene */
  878. afterRender: Nullable<() => void>;
  879. /**
  880. * An event triggered before animating the scene
  881. */
  882. onBeforeAnimationsObservable: Observable<Scene>;
  883. /**
  884. * An event triggered after animations processing
  885. */
  886. onAfterAnimationsObservable: Observable<Scene>;
  887. /**
  888. * An event triggered before draw calls are ready to be sent
  889. */
  890. onBeforeDrawPhaseObservable: Observable<Scene>;
  891. /**
  892. * An event triggered after draw calls have been sent
  893. */
  894. onAfterDrawPhaseObservable: Observable<Scene>;
  895. /**
  896. * An event triggered when the scene is ready
  897. */
  898. onReadyObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before rendering a camera
  901. */
  902. onBeforeCameraRenderObservable: Observable<Camera>;
  903. private _onBeforeCameraRenderObserver;
  904. /** Sets a function to be executed before rendering a camera*/
  905. beforeCameraRender: () => void;
  906. /**
  907. * An event triggered after rendering a camera
  908. */
  909. onAfterCameraRenderObservable: Observable<Camera>;
  910. private _onAfterCameraRenderObserver;
  911. /** Sets a function to be executed after rendering a camera*/
  912. afterCameraRender: () => void;
  913. /**
  914. * An event triggered when active meshes evaluation is about to start
  915. */
  916. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  917. /**
  918. * An event triggered when active meshes evaluation is done
  919. */
  920. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  921. /**
  922. * An event triggered when particles rendering is about to start
  923. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  924. */
  925. onBeforeParticlesRenderingObservable: Observable<Scene>;
  926. /**
  927. * An event triggered when particles rendering is done
  928. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  929. */
  930. onAfterParticlesRenderingObservable: Observable<Scene>;
  931. /**
  932. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  933. */
  934. onDataLoadedObservable: Observable<Scene>;
  935. /**
  936. * An event triggered when a camera is created
  937. */
  938. onNewCameraAddedObservable: Observable<Camera>;
  939. /**
  940. * An event triggered when a camera is removed
  941. */
  942. onCameraRemovedObservable: Observable<Camera>;
  943. /**
  944. * An event triggered when a light is created
  945. */
  946. onNewLightAddedObservable: Observable<Light>;
  947. /**
  948. * An event triggered when a light is removed
  949. */
  950. onLightRemovedObservable: Observable<Light>;
  951. /**
  952. * An event triggered when a geometry is created
  953. */
  954. onNewGeometryAddedObservable: Observable<Geometry>;
  955. /**
  956. * An event triggered when a geometry is removed
  957. */
  958. onGeometryRemovedObservable: Observable<Geometry>;
  959. /**
  960. * An event triggered when a transform node is created
  961. */
  962. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  963. /**
  964. * An event triggered when a transform node is removed
  965. */
  966. onTransformNodeRemovedObservable: Observable<TransformNode>;
  967. /**
  968. * An event triggered when a mesh is created
  969. */
  970. onNewMeshAddedObservable: Observable<AbstractMesh>;
  971. /**
  972. * An event triggered when a mesh is removed
  973. */
  974. onMeshRemovedObservable: Observable<AbstractMesh>;
  975. /**
  976. * An event triggered when a material is created
  977. */
  978. onNewMaterialAddedObservable: Observable<Material>;
  979. /**
  980. * An event triggered when a material is removed
  981. */
  982. onMaterialRemovedObservable: Observable<Material>;
  983. /**
  984. * An event triggered when a texture is created
  985. */
  986. onNewTextureAddedObservable: Observable<BaseTexture>;
  987. /**
  988. * An event triggered when a texture is removed
  989. */
  990. onTextureRemovedObservable: Observable<BaseTexture>;
  991. /**
  992. * An event triggered when render targets are about to be rendered
  993. * Can happen multiple times per frame.
  994. */
  995. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  996. /**
  997. * An event triggered when render targets were rendered.
  998. * Can happen multiple times per frame.
  999. */
  1000. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1001. /**
  1002. * An event triggered before calculating deterministic simulation step
  1003. */
  1004. onBeforeStepObservable: Observable<Scene>;
  1005. /**
  1006. * An event triggered after calculating deterministic simulation step
  1007. */
  1008. onAfterStepObservable: Observable<Scene>;
  1009. /**
  1010. * An event triggered when the activeCamera property is updated
  1011. */
  1012. onActiveCameraChanged: Observable<Scene>;
  1013. /**
  1014. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1015. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1016. * 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)
  1017. */
  1018. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1019. /**
  1020. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1021. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1022. * 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)
  1023. */
  1024. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1025. /**
  1026. * This Observable will when a mesh has been imported into the scene.
  1027. */
  1028. onMeshImportedObservable: Observable<AbstractMesh>;
  1029. private _registeredForLateAnimationBindings;
  1030. /**
  1031. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1032. */
  1033. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1034. /**
  1035. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1036. */
  1037. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1038. /**
  1039. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1040. */
  1041. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1042. private _onPointerMove;
  1043. private _onPointerDown;
  1044. private _onPointerUp;
  1045. /** Callback called when a pointer move is detected */
  1046. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1047. /** Callback called when a pointer down is detected */
  1048. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1049. /** Callback called when a pointer up is detected */
  1050. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1051. /** Callback called when a pointer pick is detected */
  1052. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1053. /**
  1054. * 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).
  1055. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1056. */
  1057. onPrePointerObservable: Observable<PointerInfoPre>;
  1058. /**
  1059. * Observable event triggered each time an input event is received from the rendering canvas
  1060. */
  1061. onPointerObservable: Observable<PointerInfo>;
  1062. /**
  1063. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1064. */
  1065. readonly unTranslatedPointer: Vector2;
  1066. /** The distance in pixel that you have to move to prevent some events */
  1067. static DragMovementThreshold: number;
  1068. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1069. static LongPressDelay: number;
  1070. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1071. static DoubleClickDelay: number;
  1072. /** If you need to check double click without raising a single click at first click, enable this flag */
  1073. static ExclusiveDoubleClickMode: boolean;
  1074. private _initClickEvent;
  1075. private _initActionManager;
  1076. private _delayedSimpleClick;
  1077. private _delayedSimpleClickTimeout;
  1078. private _previousDelayedSimpleClickTimeout;
  1079. private _meshPickProceed;
  1080. private _previousButtonPressed;
  1081. private _currentPickResult;
  1082. private _previousPickResult;
  1083. private _totalPointersPressed;
  1084. private _doubleClickOccured;
  1085. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1086. cameraToUseForPointers: Nullable<Camera>;
  1087. private _pointerX;
  1088. private _pointerY;
  1089. private _unTranslatedPointerX;
  1090. private _unTranslatedPointerY;
  1091. private _startingPointerPosition;
  1092. private _previousStartingPointerPosition;
  1093. private _startingPointerTime;
  1094. private _previousStartingPointerTime;
  1095. private _pointerCaptures;
  1096. private _timeAccumulator;
  1097. private _currentStepId;
  1098. private _currentInternalStep;
  1099. /** @hidden */
  1100. _mirroredCameraPosition: Nullable<Vector3>;
  1101. /**
  1102. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1103. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1104. */
  1105. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1106. /**
  1107. * Observable event triggered each time an keyboard event is received from the hosting window
  1108. */
  1109. onKeyboardObservable: Observable<KeyboardInfo>;
  1110. private _onKeyDown;
  1111. private _onKeyUp;
  1112. private _onCanvasFocusObserver;
  1113. private _onCanvasBlurObserver;
  1114. private _useRightHandedSystem;
  1115. /**
  1116. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1117. */
  1118. useRightHandedSystem: boolean;
  1119. /**
  1120. * Sets the step Id used by deterministic lock step
  1121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1122. * @param newStepId defines the step Id
  1123. */
  1124. setStepId(newStepId: number): void;
  1125. /**
  1126. * Gets the step Id used by deterministic lock step
  1127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1128. * @returns the step Id
  1129. */
  1130. getStepId(): number;
  1131. /**
  1132. * Gets the internal step used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @returns the internal step
  1135. */
  1136. getInternalStep(): number;
  1137. private _fogEnabled;
  1138. /**
  1139. * Gets or sets a boolean indicating if fog is enabled on this scene
  1140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1141. * (Default is true)
  1142. */
  1143. fogEnabled: boolean;
  1144. private _fogMode;
  1145. /**
  1146. * Gets or sets the fog mode to use
  1147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1148. * | mode | value |
  1149. * | --- | --- |
  1150. * | FOGMODE_NONE | 0 |
  1151. * | FOGMODE_EXP | 1 |
  1152. * | FOGMODE_EXP2 | 2 |
  1153. * | FOGMODE_LINEAR | 3 |
  1154. */
  1155. fogMode: number;
  1156. /**
  1157. * Gets or sets the fog color to use
  1158. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1159. * (Default is Color3(0.2, 0.2, 0.3))
  1160. */
  1161. fogColor: Color3;
  1162. /**
  1163. * Gets or sets the fog density to use
  1164. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1165. * (Default is 0.1)
  1166. */
  1167. fogDensity: number;
  1168. /**
  1169. * Gets or sets the fog start distance to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is 0)
  1172. */
  1173. fogStart: number;
  1174. /**
  1175. * Gets or sets the fog end distance to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 1000)
  1178. */
  1179. fogEnd: number;
  1180. private _shadowsEnabled;
  1181. /**
  1182. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1183. */
  1184. shadowsEnabled: boolean;
  1185. private _lightsEnabled;
  1186. /**
  1187. * Gets or sets a boolean indicating if lights are enabled on this scene
  1188. */
  1189. lightsEnabled: boolean;
  1190. /** All of the active cameras added to this scene. */
  1191. activeCameras: Camera[];
  1192. private _activeCamera;
  1193. /** Gets or sets the current active camera */
  1194. activeCamera: Nullable<Camera>;
  1195. private _defaultMaterial;
  1196. /** The default material used on meshes when no material is affected */
  1197. /** The default material used on meshes when no material is affected */
  1198. defaultMaterial: Material;
  1199. private _texturesEnabled;
  1200. /**
  1201. * Gets or sets a boolean indicating if textures are enabled on this scene
  1202. */
  1203. texturesEnabled: boolean;
  1204. /**
  1205. * Gets or sets a boolean indicating if particles are enabled on this scene
  1206. */
  1207. particlesEnabled: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1210. */
  1211. spritesEnabled: boolean;
  1212. private _skeletonsEnabled;
  1213. /**
  1214. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1215. */
  1216. skeletonsEnabled: boolean;
  1217. /**
  1218. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1219. */
  1220. lensFlaresEnabled: boolean;
  1221. /**
  1222. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1224. */
  1225. collisionsEnabled: boolean;
  1226. private _workerCollisions;
  1227. /** @hidden */
  1228. collisionCoordinator: ICollisionCoordinator;
  1229. /**
  1230. * Defines the gravity applied to this scene (used only for collisions)
  1231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1232. */
  1233. gravity: Vector3;
  1234. /**
  1235. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1236. */
  1237. postProcessesEnabled: boolean;
  1238. /**
  1239. * The list of postprocesses added to the scene
  1240. */
  1241. postProcesses: PostProcess[];
  1242. /**
  1243. * Gets the current postprocess manager
  1244. */
  1245. postProcessManager: PostProcessManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * Gets or sets the current offline provider to use to store scene data
  1274. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1275. */
  1276. offlineProvider: IOfflineProvider;
  1277. /**
  1278. * Gets or sets the action manager associated with the scene
  1279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1280. */
  1281. actionManager: ActionManager;
  1282. private _meshesForIntersections;
  1283. /**
  1284. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1285. */
  1286. proceduralTexturesEnabled: boolean;
  1287. private _engine;
  1288. private _totalVertices;
  1289. /** @hidden */
  1290. _activeIndices: PerfCounter;
  1291. /** @hidden */
  1292. _activeParticles: PerfCounter;
  1293. /** @hidden */
  1294. _activeBones: PerfCounter;
  1295. private _animationRatio;
  1296. private _animationTimeLast;
  1297. private _animationTime;
  1298. /**
  1299. * Gets or sets a general scale for animation speed
  1300. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1301. */
  1302. animationTimeScale: number;
  1303. /** @hidden */
  1304. _cachedMaterial: Nullable<Material>;
  1305. /** @hidden */
  1306. _cachedEffect: Nullable<Effect>;
  1307. /** @hidden */
  1308. _cachedVisibility: Nullable<number>;
  1309. private _renderId;
  1310. private _frameId;
  1311. private _executeWhenReadyTimeoutId;
  1312. private _intermediateRendering;
  1313. private _viewUpdateFlag;
  1314. private _projectionUpdateFlag;
  1315. private _alternateViewUpdateFlag;
  1316. private _alternateProjectionUpdateFlag;
  1317. /** @hidden */
  1318. _toBeDisposed: Nullable<IDisposable>[];
  1319. private _activeRequests;
  1320. private _pendingData;
  1321. private _isDisposed;
  1322. /**
  1323. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1324. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1325. */
  1326. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1327. private _activeMeshes;
  1328. private _processedMaterials;
  1329. private _renderTargets;
  1330. /** @hidden */
  1331. _activeParticleSystems: SmartArray<IParticleSystem>;
  1332. private _activeSkeletons;
  1333. private _softwareSkinnedMeshes;
  1334. private _renderingManager;
  1335. /** @hidden */
  1336. _activeAnimatables: Animatable[];
  1337. private _transformMatrix;
  1338. private _sceneUbo;
  1339. private _alternateSceneUbo;
  1340. private _pickWithRayInverseMatrix;
  1341. private _viewMatrix;
  1342. private _projectionMatrix;
  1343. private _alternateViewMatrix;
  1344. private _alternateProjectionMatrix;
  1345. private _alternateTransformMatrix;
  1346. private _useAlternateCameraConfiguration;
  1347. private _alternateRendering;
  1348. private _wheelEventName;
  1349. /** @hidden */
  1350. _forcedViewPosition: Nullable<Vector3>;
  1351. /** @hidden */
  1352. readonly _isAlternateRenderingEnabled: boolean;
  1353. private _frustumPlanes;
  1354. /**
  1355. * Gets the list of frustum planes (built from the active camera)
  1356. */
  1357. readonly frustumPlanes: Plane[];
  1358. /**
  1359. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1360. * This is useful if there are more lights that the maximum simulteanous authorized
  1361. */
  1362. requireLightSorting: boolean;
  1363. /** @hidden */
  1364. readonly useMaterialMeshMap: boolean;
  1365. /** @hidden */
  1366. readonly useClonedMeshhMap: boolean;
  1367. private _pointerOverMesh;
  1368. private _pickedDownMesh;
  1369. private _pickedUpMesh;
  1370. private _externalData;
  1371. private _uid;
  1372. /**
  1373. * @hidden
  1374. * Backing store of defined scene components.
  1375. */
  1376. _components: ISceneComponent[];
  1377. /**
  1378. * @hidden
  1379. * Backing store of defined scene components.
  1380. */
  1381. _serializableComponents: ISceneSerializableComponent[];
  1382. /**
  1383. * List of components to register on the next registration step.
  1384. */
  1385. private _transientComponents;
  1386. /**
  1387. * Registers the transient components if needed.
  1388. */
  1389. private _registerTransientComponents;
  1390. /**
  1391. * @hidden
  1392. * Add a component to the scene.
  1393. * Note that the ccomponent could be registered on th next frame if this is called after
  1394. * the register component stage.
  1395. * @param component Defines the component to add to the scene
  1396. */
  1397. _addComponent(component: ISceneComponent): void;
  1398. /**
  1399. * @hidden
  1400. * Gets a component from the scene.
  1401. * @param name defines the name of the component to retrieve
  1402. * @returns the component or null if not present
  1403. */
  1404. _getComponent(name: string): Nullable<ISceneComponent>;
  1405. /**
  1406. * @hidden
  1407. * Defines the actions happening before camera updates.
  1408. */
  1409. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1410. /**
  1411. * @hidden
  1412. * Defines the actions happening before clear the canvas.
  1413. */
  1414. _beforeClearStage: Stage<SimpleStageAction>;
  1415. /**
  1416. * @hidden
  1417. * Defines the actions when collecting render targets for the frame.
  1418. */
  1419. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1420. /**
  1421. * @hidden
  1422. * Defines the actions happening for one camera in the frame.
  1423. */
  1424. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1425. /**
  1426. * @hidden
  1427. * Defines the actions happening during the per mesh ready checks.
  1428. */
  1429. _isReadyForMeshStage: Stage<MeshStageAction>;
  1430. /**
  1431. * @hidden
  1432. * Defines the actions happening before evaluate active mesh checks.
  1433. */
  1434. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1435. /**
  1436. * @hidden
  1437. * Defines the actions happening during the evaluate sub mesh checks.
  1438. */
  1439. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1440. /**
  1441. * @hidden
  1442. * Defines the actions happening during the active mesh stage.
  1443. */
  1444. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1445. /**
  1446. * @hidden
  1447. * Defines the actions happening during the per camera render target step.
  1448. */
  1449. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1450. /**
  1451. * @hidden
  1452. * Defines the actions happening just before the active camera is drawing.
  1453. */
  1454. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1455. /**
  1456. * @hidden
  1457. * Defines the actions happening just before a rendering group is drawing.
  1458. */
  1459. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1460. /**
  1461. * @hidden
  1462. * Defines the actions happening just before a mesh is drawing.
  1463. */
  1464. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1465. /**
  1466. * @hidden
  1467. * Defines the actions happening just after a mesh has been drawn.
  1468. */
  1469. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1470. /**
  1471. * @hidden
  1472. * Defines the actions happening just after a rendering group has been drawn.
  1473. */
  1474. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1475. /**
  1476. * @hidden
  1477. * Defines the actions happening just after the active camera has been drawn.
  1478. */
  1479. _afterCameraDrawStage: Stage<CameraStageAction>;
  1480. /**
  1481. * @hidden
  1482. * Defines the actions happening just after rendering all cameras and computing intersections.
  1483. */
  1484. _afterRenderStage: Stage<SimpleStageAction>;
  1485. /**
  1486. * @hidden
  1487. * Defines the actions happening when a pointer move event happens.
  1488. */
  1489. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1490. /**
  1491. * @hidden
  1492. * Defines the actions happening when a pointer down event happens.
  1493. */
  1494. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1495. /**
  1496. * @hidden
  1497. * Defines the actions happening when a pointer up event happens.
  1498. */
  1499. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1500. /**
  1501. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1502. */
  1503. private geometriesById;
  1504. /**
  1505. * Creates a new Scene
  1506. * @param engine defines the engine to use to render this scene
  1507. */
  1508. constructor(engine: Engine, options?: SceneOptions);
  1509. private _defaultMeshCandidates;
  1510. /**
  1511. * @hidden
  1512. */
  1513. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1514. private _defaultSubMeshCandidates;
  1515. /**
  1516. * @hidden
  1517. */
  1518. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1519. /**
  1520. * Sets the default candidate providers for the scene.
  1521. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1522. * and getCollidingSubMeshCandidates to their default function
  1523. */
  1524. setDefaultCandidateProviders(): void;
  1525. /**
  1526. * Gets a boolean indicating if collisions are processed on a web worker
  1527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1528. */
  1529. workerCollisions: boolean;
  1530. /**
  1531. * Gets the mesh that is currently under the pointer
  1532. */
  1533. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1534. /**
  1535. * Gets the current on-screen X position of the pointer
  1536. */
  1537. readonly pointerX: number;
  1538. /**
  1539. * Gets the current on-screen Y position of the pointer
  1540. */
  1541. readonly pointerY: number;
  1542. /**
  1543. * Gets the cached material (ie. the latest rendered one)
  1544. * @returns the cached material
  1545. */
  1546. getCachedMaterial(): Nullable<Material>;
  1547. /**
  1548. * Gets the cached effect (ie. the latest rendered one)
  1549. * @returns the cached effect
  1550. */
  1551. getCachedEffect(): Nullable<Effect>;
  1552. /**
  1553. * Gets the cached visibility state (ie. the latest rendered one)
  1554. * @returns the cached visibility state
  1555. */
  1556. getCachedVisibility(): Nullable<number>;
  1557. /**
  1558. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1559. * @param material defines the current material
  1560. * @param effect defines the current effect
  1561. * @param visibility defines the current visibility state
  1562. * @returns true if one parameter is not cached
  1563. */
  1564. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1565. /**
  1566. * Gets the engine associated with the scene
  1567. * @returns an Engine
  1568. */
  1569. getEngine(): Engine;
  1570. /**
  1571. * Gets the total number of vertices rendered per frame
  1572. * @returns the total number of vertices rendered per frame
  1573. */
  1574. getTotalVertices(): number;
  1575. /**
  1576. * Gets the performance counter for total vertices
  1577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1578. */
  1579. readonly totalVerticesPerfCounter: PerfCounter;
  1580. /**
  1581. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1582. * @returns the total number of active indices rendered per frame
  1583. */
  1584. getActiveIndices(): number;
  1585. /**
  1586. * Gets the performance counter for active indices
  1587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1588. */
  1589. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1590. /**
  1591. * Gets the total number of active particles rendered per frame
  1592. * @returns the total number of active particles rendered per frame
  1593. */
  1594. getActiveParticles(): number;
  1595. /**
  1596. * Gets the performance counter for active particles
  1597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1598. */
  1599. readonly activeParticlesPerfCounter: PerfCounter;
  1600. /**
  1601. * Gets the total number of active bones rendered per frame
  1602. * @returns the total number of active bones rendered per frame
  1603. */
  1604. getActiveBones(): number;
  1605. /**
  1606. * Gets the performance counter for active bones
  1607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1608. */
  1609. readonly activeBonesPerfCounter: PerfCounter;
  1610. /**
  1611. * Gets the array of active meshes
  1612. * @returns an array of AbstractMesh
  1613. */
  1614. getActiveMeshes(): SmartArray<AbstractMesh>;
  1615. /**
  1616. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1617. * @returns a number
  1618. */
  1619. getAnimationRatio(): number;
  1620. /**
  1621. * Gets an unique Id for the current render phase
  1622. * @returns a number
  1623. */
  1624. getRenderId(): number;
  1625. /**
  1626. * Gets an unique Id for the current frame
  1627. * @returns a number
  1628. */
  1629. getFrameId(): number;
  1630. /** Call this function if you want to manually increment the render Id*/
  1631. incrementRenderId(): void;
  1632. private _updatePointerPosition;
  1633. private _createUbo;
  1634. private _createAlternateUbo;
  1635. private _setRayOnPointerInfo;
  1636. /**
  1637. * Use this method to simulate a pointer move on a mesh
  1638. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1639. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1640. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1641. * @returns the current scene
  1642. */
  1643. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1644. private _processPointerMove;
  1645. private _checkPrePointerObservable;
  1646. /**
  1647. * Use this method to simulate a pointer down on a mesh
  1648. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1649. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1650. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1651. * @returns the current scene
  1652. */
  1653. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1654. private _processPointerDown;
  1655. /**
  1656. * Use this method to simulate a pointer up on a mesh
  1657. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1658. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1659. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1660. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1661. * @returns the current scene
  1662. */
  1663. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1664. private _processPointerUp;
  1665. /**
  1666. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1667. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1668. * @returns true if the pointer was captured
  1669. */
  1670. isPointerCaptured(pointerId?: number): boolean;
  1671. /** @hidden */
  1672. _isPointerSwiping(): boolean;
  1673. /**
  1674. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1675. * @param attachUp defines if you want to attach events to pointerup
  1676. * @param attachDown defines if you want to attach events to pointerdown
  1677. * @param attachMove defines if you want to attach events to pointermove
  1678. */
  1679. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1680. /** Detaches all event handlers*/
  1681. detachControl(): void;
  1682. /**
  1683. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1684. * Delay loaded resources are not taking in account
  1685. * @return true if all required resources are ready
  1686. */
  1687. isReady(): boolean;
  1688. /** Resets all cached information relative to material (including effect and visibility) */
  1689. resetCachedMaterial(): void;
  1690. /**
  1691. * Registers a function to be called before every frame render
  1692. * @param func defines the function to register
  1693. */
  1694. registerBeforeRender(func: () => void): void;
  1695. /**
  1696. * Unregisters a function called before every frame render
  1697. * @param func defines the function to unregister
  1698. */
  1699. unregisterBeforeRender(func: () => void): void;
  1700. /**
  1701. * Registers a function to be called after every frame render
  1702. * @param func defines the function to register
  1703. */
  1704. registerAfterRender(func: () => void): void;
  1705. /**
  1706. * Unregisters a function called after every frame render
  1707. * @param func defines the function to unregister
  1708. */
  1709. unregisterAfterRender(func: () => void): void;
  1710. private _executeOnceBeforeRender;
  1711. /**
  1712. * The provided function will run before render once and will be disposed afterwards.
  1713. * A timeout delay can be provided so that the function will be executed in N ms.
  1714. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1715. * @param func The function to be executed.
  1716. * @param timeout optional delay in ms
  1717. */
  1718. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1719. /** @hidden */
  1720. _addPendingData(data: any): void;
  1721. /** @hidden */
  1722. _removePendingData(data: any): void;
  1723. /**
  1724. * Returns the number of items waiting to be loaded
  1725. * @returns the number of items waiting to be loaded
  1726. */
  1727. getWaitingItemsCount(): number;
  1728. /**
  1729. * Returns a boolean indicating if the scene is still loading data
  1730. */
  1731. readonly isLoading: boolean;
  1732. /**
  1733. * Registers a function to be executed when the scene is ready
  1734. * @param {Function} func - the function to be executed
  1735. */
  1736. executeWhenReady(func: () => void): void;
  1737. /**
  1738. * Returns a promise that resolves when the scene is ready
  1739. * @returns A promise that resolves when the scene is ready
  1740. */
  1741. whenReadyAsync(): Promise<void>;
  1742. /** @hidden */
  1743. _checkIsReady(): void;
  1744. /**
  1745. * Will start the animation sequence of a given target
  1746. * @param target defines the target
  1747. * @param from defines from which frame should animation start
  1748. * @param to defines until which frame should animation run.
  1749. * @param weight defines the weight to apply to the animation (1.0 by default)
  1750. * @param loop defines if the animation loops
  1751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1752. * @param onAnimationEnd defines the function to be executed when the animation ends
  1753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1754. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1755. * @returns the animatable object created for this animation
  1756. */
  1757. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1758. /**
  1759. * Will start the animation sequence of a given target
  1760. * @param target defines the target
  1761. * @param from defines from which frame should animation start
  1762. * @param to defines until which frame should animation run.
  1763. * @param loop defines if the animation loops
  1764. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1765. * @param onAnimationEnd defines the function to be executed when the animation ends
  1766. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1767. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1769. * @returns the animatable object created for this animation
  1770. */
  1771. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1772. /**
  1773. * Will start the animation sequence of a given target and its hierarchy
  1774. * @param target defines the target
  1775. * @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.
  1776. * @param from defines from which frame should animation start
  1777. * @param to defines until which frame should animation run.
  1778. * @param loop defines if the animation loops
  1779. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1780. * @param onAnimationEnd defines the function to be executed when the animation ends
  1781. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1782. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1783. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1784. * @returns the list of created animatables
  1785. */
  1786. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1787. /**
  1788. * Begin a new animation on a given node
  1789. * @param target defines the target where the animation will take place
  1790. * @param animations defines the list of animations to start
  1791. * @param from defines the initial value
  1792. * @param to defines the final value
  1793. * @param loop defines if you want animation to loop (off by default)
  1794. * @param speedRatio defines the speed ratio to apply to all animations
  1795. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1796. * @returns the list of created animatables
  1797. */
  1798. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1799. /**
  1800. * Begin a new animation on a given node and its hierarchy
  1801. * @param target defines the root node where the animation will take place
  1802. * @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.
  1803. * @param animations defines the list of animations to start
  1804. * @param from defines the initial value
  1805. * @param to defines the final value
  1806. * @param loop defines if you want animation to loop (off by default)
  1807. * @param speedRatio defines the speed ratio to apply to all animations
  1808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1809. * @returns the list of animatables created for all nodes
  1810. */
  1811. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1812. /**
  1813. * Gets the animatable associated with a specific target
  1814. * @param target defines the target of the animatable
  1815. * @returns the required animatable if found
  1816. */
  1817. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1818. /**
  1819. * Gets all animatables associated with a given target
  1820. * @param target defines the target to look animatables for
  1821. * @returns an array of Animatables
  1822. */
  1823. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1824. /**
  1825. * Gets all animatable attached to the scene
  1826. */
  1827. readonly animatables: Animatable[];
  1828. /**
  1829. * Will stop the animation of the given target
  1830. * @param target - the target
  1831. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1832. * @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)
  1833. */
  1834. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1835. /**
  1836. * Stops and removes all animations that have been applied to the scene
  1837. */
  1838. stopAllAnimations(): void;
  1839. private _animate;
  1840. /** @hidden */
  1841. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1842. private _processLateAnimationBindingsForMatrices;
  1843. private _processLateAnimationBindingsForQuaternions;
  1844. private _processLateAnimationBindings;
  1845. /** @hidden */
  1846. _switchToAlternateCameraConfiguration(active: boolean): void;
  1847. /**
  1848. * Gets the current view matrix
  1849. * @returns a Matrix
  1850. */
  1851. getViewMatrix(): Matrix;
  1852. /**
  1853. * Gets the current projection matrix
  1854. * @returns a Matrix
  1855. */
  1856. getProjectionMatrix(): Matrix;
  1857. /**
  1858. * Gets the current transform matrix
  1859. * @returns a Matrix made of View * Projection
  1860. */
  1861. getTransformMatrix(): Matrix;
  1862. /**
  1863. * Sets the current transform matrix
  1864. * @param view defines the View matrix to use
  1865. * @param projection defines the Projection matrix to use
  1866. */
  1867. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1868. /** @hidden */
  1869. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1870. /**
  1871. * Gets the uniform buffer used to store scene data
  1872. * @returns a UniformBuffer
  1873. */
  1874. getSceneUniformBuffer(): UniformBuffer;
  1875. /**
  1876. * Gets an unique (relatively to the current scene) Id
  1877. * @returns an unique number for the scene
  1878. */
  1879. getUniqueId(): number;
  1880. /**
  1881. * Add a mesh to the list of scene's meshes
  1882. * @param newMesh defines the mesh to add
  1883. * @param recursive if all child meshes should also be added to the scene
  1884. */
  1885. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1886. /**
  1887. * Remove a mesh for the list of scene's meshes
  1888. * @param toRemove defines the mesh to remove
  1889. * @param recursive if all child meshes should also be removed from the scene
  1890. * @returns the index where the mesh was in the mesh list
  1891. */
  1892. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1893. /**
  1894. * Add a transform node to the list of scene's transform nodes
  1895. * @param newTransformNode defines the transform node to add
  1896. */
  1897. addTransformNode(newTransformNode: TransformNode): void;
  1898. /**
  1899. * Remove a transform node for the list of scene's transform nodes
  1900. * @param toRemove defines the transform node to remove
  1901. * @returns the index where the transform node was in the transform node list
  1902. */
  1903. removeTransformNode(toRemove: TransformNode): number;
  1904. /**
  1905. * Remove a skeleton for the list of scene's skeletons
  1906. * @param toRemove defines the skeleton to remove
  1907. * @returns the index where the skeleton was in the skeleton list
  1908. */
  1909. removeSkeleton(toRemove: Skeleton): number;
  1910. /**
  1911. * Remove a morph target for the list of scene's morph targets
  1912. * @param toRemove defines the morph target to remove
  1913. * @returns the index where the morph target was in the morph target list
  1914. */
  1915. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1916. /**
  1917. * Remove a light for the list of scene's lights
  1918. * @param toRemove defines the light to remove
  1919. * @returns the index where the light was in the light list
  1920. */
  1921. removeLight(toRemove: Light): number;
  1922. /**
  1923. * Remove a camera for the list of scene's cameras
  1924. * @param toRemove defines the camera to remove
  1925. * @returns the index where the camera was in the camera list
  1926. */
  1927. removeCamera(toRemove: Camera): number;
  1928. /**
  1929. * Remove a particle system for the list of scene's particle systems
  1930. * @param toRemove defines the particle system to remove
  1931. * @returns the index where the particle system was in the particle system list
  1932. */
  1933. removeParticleSystem(toRemove: IParticleSystem): number;
  1934. /**
  1935. * Remove a animation for the list of scene's animations
  1936. * @param toRemove defines the animation to remove
  1937. * @returns the index where the animation was in the animation list
  1938. */
  1939. removeAnimation(toRemove: Animation): number;
  1940. /**
  1941. * Removes the given animation group from this scene.
  1942. * @param toRemove The animation group to remove
  1943. * @returns The index of the removed animation group
  1944. */
  1945. removeAnimationGroup(toRemove: AnimationGroup): number;
  1946. /**
  1947. * Removes the given multi-material from this scene.
  1948. * @param toRemove The multi-material to remove
  1949. * @returns The index of the removed multi-material
  1950. */
  1951. removeMultiMaterial(toRemove: MultiMaterial): number;
  1952. /**
  1953. * Removes the given material from this scene.
  1954. * @param toRemove The material to remove
  1955. * @returns The index of the removed material
  1956. */
  1957. removeMaterial(toRemove: Material): number;
  1958. /**
  1959. * Removes the given action manager from this scene.
  1960. * @param toRemove The action manager to remove
  1961. * @returns The index of the removed action manager
  1962. */
  1963. removeActionManager(toRemove: ActionManager): number;
  1964. /**
  1965. * Removes the given texture from this scene.
  1966. * @param toRemove The texture to remove
  1967. * @returns The index of the removed texture
  1968. */
  1969. removeTexture(toRemove: BaseTexture): number;
  1970. /**
  1971. * Adds the given light to this scene
  1972. * @param newLight The light to add
  1973. */
  1974. addLight(newLight: Light): void;
  1975. /**
  1976. * Sorts the list list based on light priorities
  1977. */
  1978. sortLightsByPriority(): void;
  1979. /**
  1980. * Adds the given camera to this scene
  1981. * @param newCamera The camera to add
  1982. */
  1983. addCamera(newCamera: Camera): void;
  1984. /**
  1985. * Adds the given skeleton to this scene
  1986. * @param newSkeleton The skeleton to add
  1987. */
  1988. addSkeleton(newSkeleton: Skeleton): void;
  1989. /**
  1990. * Adds the given particle system to this scene
  1991. * @param newParticleSystem The particle system to add
  1992. */
  1993. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1994. /**
  1995. * Adds the given animation to this scene
  1996. * @param newAnimation The animation to add
  1997. */
  1998. addAnimation(newAnimation: Animation): void;
  1999. /**
  2000. * Adds the given animation group to this scene.
  2001. * @param newAnimationGroup The animation group to add
  2002. */
  2003. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2004. /**
  2005. * Adds the given multi-material to this scene
  2006. * @param newMultiMaterial The multi-material to add
  2007. */
  2008. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2009. /**
  2010. * Adds the given material to this scene
  2011. * @param newMaterial The material to add
  2012. */
  2013. addMaterial(newMaterial: Material): void;
  2014. /**
  2015. * Adds the given morph target to this scene
  2016. * @param newMorphTargetManager The morph target to add
  2017. */
  2018. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2019. /**
  2020. * Adds the given geometry to this scene
  2021. * @param newGeometry The geometry to add
  2022. */
  2023. addGeometry(newGeometry: Geometry): void;
  2024. /**
  2025. * Adds the given action manager to this scene
  2026. * @param newActionManager The action manager to add
  2027. */
  2028. addActionManager(newActionManager: ActionManager): void;
  2029. /**
  2030. * Adds the given texture to this scene.
  2031. * @param newTexture The texture to add
  2032. */
  2033. addTexture(newTexture: BaseTexture): void;
  2034. /**
  2035. * Switch active camera
  2036. * @param newCamera defines the new active camera
  2037. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2038. */
  2039. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2040. /**
  2041. * sets the active camera of the scene using its ID
  2042. * @param id defines the camera's ID
  2043. * @return the new active camera or null if none found.
  2044. */
  2045. setActiveCameraByID(id: string): Nullable<Camera>;
  2046. /**
  2047. * sets the active camera of the scene using its name
  2048. * @param name defines the camera's name
  2049. * @returns the new active camera or null if none found.
  2050. */
  2051. setActiveCameraByName(name: string): Nullable<Camera>;
  2052. /**
  2053. * get an animation group using its name
  2054. * @param name defines the material's name
  2055. * @return the animation group or null if none found.
  2056. */
  2057. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2058. /**
  2059. * get a material using its id
  2060. * @param id defines the material's ID
  2061. * @return the material or null if none found.
  2062. */
  2063. getMaterialByID(id: string): Nullable<Material>;
  2064. /**
  2065. * Gets a material using its name
  2066. * @param name defines the material's name
  2067. * @return the material or null if none found.
  2068. */
  2069. getMaterialByName(name: string): Nullable<Material>;
  2070. /**
  2071. * Gets a camera using its id
  2072. * @param id defines the id to look for
  2073. * @returns the camera or null if not found
  2074. */
  2075. getCameraByID(id: string): Nullable<Camera>;
  2076. /**
  2077. * Gets a camera using its unique id
  2078. * @param uniqueId defines the unique id to look for
  2079. * @returns the camera or null if not found
  2080. */
  2081. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2082. /**
  2083. * Gets a camera using its name
  2084. * @param name defines the camera's name
  2085. * @return the camera or null if none found.
  2086. */
  2087. getCameraByName(name: string): Nullable<Camera>;
  2088. /**
  2089. * Gets a bone using its id
  2090. * @param id defines the bone's id
  2091. * @return the bone or null if not found
  2092. */
  2093. getBoneByID(id: string): Nullable<Bone>;
  2094. /**
  2095. * Gets a bone using its id
  2096. * @param name defines the bone's name
  2097. * @return the bone or null if not found
  2098. */
  2099. getBoneByName(name: string): Nullable<Bone>;
  2100. /**
  2101. * Gets a light node using its name
  2102. * @param name defines the the light's name
  2103. * @return the light or null if none found.
  2104. */
  2105. getLightByName(name: string): Nullable<Light>;
  2106. /**
  2107. * Gets a light node using its id
  2108. * @param id defines the light's id
  2109. * @return the light or null if none found.
  2110. */
  2111. getLightByID(id: string): Nullable<Light>;
  2112. /**
  2113. * Gets a light node using its scene-generated unique ID
  2114. * @param uniqueId defines the light's unique id
  2115. * @return the light or null if none found.
  2116. */
  2117. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2118. /**
  2119. * Gets a particle system by id
  2120. * @param id defines the particle system id
  2121. * @return the corresponding system or null if none found
  2122. */
  2123. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2124. /**
  2125. * Gets a geometry using its ID
  2126. * @param id defines the geometry's id
  2127. * @return the geometry or null if none found.
  2128. */
  2129. getGeometryByID(id: string): Nullable<Geometry>;
  2130. /**
  2131. * Add a new geometry to this scene
  2132. * @param geometry defines the geometry to be added to the scene.
  2133. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2134. * @return a boolean defining if the geometry was added or not
  2135. */
  2136. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2137. /**
  2138. * Removes an existing geometry
  2139. * @param geometry defines the geometry to be removed from the scene
  2140. * @return a boolean defining if the geometry was removed or not
  2141. */
  2142. removeGeometry(geometry: Geometry): boolean;
  2143. /**
  2144. * Gets the list of geometries attached to the scene
  2145. * @returns an array of Geometry
  2146. */
  2147. getGeometries(): Geometry[];
  2148. /**
  2149. * Gets the first added mesh found of a given ID
  2150. * @param id defines the id to search for
  2151. * @return the mesh found or null if not found at all
  2152. */
  2153. getMeshByID(id: string): Nullable<AbstractMesh>;
  2154. /**
  2155. * Gets a list of meshes using their id
  2156. * @param id defines the id to search for
  2157. * @returns a list of meshes
  2158. */
  2159. getMeshesByID(id: string): Array<AbstractMesh>;
  2160. /**
  2161. * Gets the first added transform node found of a given ID
  2162. * @param id defines the id to search for
  2163. * @return the found transform node or null if not found at all.
  2164. */
  2165. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2166. /**
  2167. * Gets a list of transform nodes using their id
  2168. * @param id defines the id to search for
  2169. * @returns a list of transform nodes
  2170. */
  2171. getTransformNodesByID(id: string): Array<TransformNode>;
  2172. /**
  2173. * Gets a mesh with its auto-generated unique id
  2174. * @param uniqueId defines the unique id to search for
  2175. * @return the found mesh or null if not found at all.
  2176. */
  2177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2178. /**
  2179. * Gets a the last added mesh using a given id
  2180. * @param id defines the id to search for
  2181. * @return the found mesh or null if not found at all.
  2182. */
  2183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2184. /**
  2185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2186. * @param id defines the id to search for
  2187. * @return the found node or null if not found at all
  2188. */
  2189. getLastEntryByID(id: string): Nullable<Node>;
  2190. /**
  2191. * Gets a node (Mesh, Camera, Light) using a given id
  2192. * @param id defines the id to search for
  2193. * @return the found node or null if not found at all
  2194. */
  2195. getNodeByID(id: string): Nullable<Node>;
  2196. /**
  2197. * Gets a node (Mesh, Camera, Light) using a given name
  2198. * @param name defines the name to search for
  2199. * @return the found node or null if not found at all.
  2200. */
  2201. getNodeByName(name: string): Nullable<Node>;
  2202. /**
  2203. * Gets a mesh using a given name
  2204. * @param name defines the name to search for
  2205. * @return the found mesh or null if not found at all.
  2206. */
  2207. getMeshByName(name: string): Nullable<AbstractMesh>;
  2208. /**
  2209. * Gets a transform node using a given name
  2210. * @param name defines the name to search for
  2211. * @return the found transform node or null if not found at all.
  2212. */
  2213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2214. /**
  2215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2216. * @param id defines the id to search for
  2217. * @return the found skeleton or null if not found at all.
  2218. */
  2219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2220. /**
  2221. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2222. * @param id defines the id to search for
  2223. * @return the found skeleton or null if not found at all.
  2224. */
  2225. getSkeletonById(id: string): Nullable<Skeleton>;
  2226. /**
  2227. * Gets a skeleton using a given name
  2228. * @param name defines the name to search for
  2229. * @return the found skeleton or null if not found at all.
  2230. */
  2231. getSkeletonByName(name: string): Nullable<Skeleton>;
  2232. /**
  2233. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2234. * @param id defines the id to search for
  2235. * @return the found morph target manager or null if not found at all.
  2236. */
  2237. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2238. /**
  2239. * Gets a boolean indicating if the given mesh is active
  2240. * @param mesh defines the mesh to look for
  2241. * @returns true if the mesh is in the active list
  2242. */
  2243. isActiveMesh(mesh: AbstractMesh): boolean;
  2244. /**
  2245. * Return a unique id as a string which can serve as an identifier for the scene
  2246. */
  2247. readonly uid: string;
  2248. /**
  2249. * Add an externaly attached data from its key.
  2250. * This method call will fail and return false, if such key already exists.
  2251. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2252. * @param key the unique key that identifies the data
  2253. * @param data the data object to associate to the key for this Engine instance
  2254. * @return true if no such key were already present and the data was added successfully, false otherwise
  2255. */
  2256. addExternalData<T>(key: string, data: T): boolean;
  2257. /**
  2258. * Get an externaly attached data from its key
  2259. * @param key the unique key that identifies the data
  2260. * @return the associated data, if present (can be null), or undefined if not present
  2261. */
  2262. getExternalData<T>(key: string): Nullable<T>;
  2263. /**
  2264. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2265. * @param key the unique key that identifies the data
  2266. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2267. * @return the associated data, can be null if the factory returned null.
  2268. */
  2269. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2270. /**
  2271. * Remove an externaly attached data from the Engine instance
  2272. * @param key the unique key that identifies the data
  2273. * @return true if the data was successfully removed, false if it doesn't exist
  2274. */
  2275. removeExternalData(key: string): boolean;
  2276. private _evaluateSubMesh;
  2277. /**
  2278. * Clear the processed materials smart array preventing retention point in material dispose.
  2279. */
  2280. freeProcessedMaterials(): void;
  2281. private _preventFreeActiveMeshesAndRenderingGroups;
  2282. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2283. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2284. * when disposing several meshes in a row or a hierarchy of meshes.
  2285. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2286. */
  2287. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2288. /**
  2289. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2290. */
  2291. freeActiveMeshes(): void;
  2292. /**
  2293. * Clear the info related to rendering groups preventing retention points during dispose.
  2294. */
  2295. freeRenderingGroups(): void;
  2296. /** @hidden */
  2297. _isInIntermediateRendering(): boolean;
  2298. /**
  2299. * Lambda returning the list of potentially active meshes.
  2300. */
  2301. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2302. /**
  2303. * Lambda returning the list of potentially active sub meshes.
  2304. */
  2305. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2306. /**
  2307. * Lambda returning the list of potentially intersecting sub meshes.
  2308. */
  2309. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2310. /**
  2311. * Lambda returning the list of potentially colliding sub meshes.
  2312. */
  2313. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2314. private _activeMeshesFrozen;
  2315. /**
  2316. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2317. * @returns the current scene
  2318. */
  2319. freezeActiveMeshes(): Scene;
  2320. /**
  2321. * Use this function to restart evaluating active meshes on every frame
  2322. * @returns the current scene
  2323. */
  2324. unfreezeActiveMeshes(): Scene;
  2325. private _evaluateActiveMeshes;
  2326. private _activeMesh;
  2327. /**
  2328. * Update the transform matrix to update from the current active camera
  2329. * @param force defines a boolean used to force the update even if cache is up to date
  2330. */
  2331. updateTransformMatrix(force?: boolean): void;
  2332. /**
  2333. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2334. * @param alternateCamera defines the camera to use
  2335. */
  2336. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2337. /** @hidden */
  2338. _allowPostProcessClearColor: boolean;
  2339. private _renderForCamera;
  2340. private _processSubCameras;
  2341. private _checkIntersections;
  2342. /** @hidden */
  2343. _advancePhysicsEngineStep(step: number): void;
  2344. /**
  2345. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2346. */
  2347. getDeterministicFrameTime: () => number;
  2348. /**
  2349. * Render the scene
  2350. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2351. */
  2352. render(updateCameras?: boolean): void;
  2353. /**
  2354. * Freeze all materials
  2355. * A frozen material will not be updatable but should be faster to render
  2356. */
  2357. freezeMaterials(): void;
  2358. /**
  2359. * Unfreeze all materials
  2360. * A frozen material will not be updatable but should be faster to render
  2361. */
  2362. unfreezeMaterials(): void;
  2363. /**
  2364. * Releases all held ressources
  2365. */
  2366. dispose(): void;
  2367. /**
  2368. * Gets if the scene is already disposed
  2369. */
  2370. readonly isDisposed: boolean;
  2371. /**
  2372. * Call this function to reduce memory footprint of the scene.
  2373. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2374. */
  2375. clearCachedVertexData(): void;
  2376. /**
  2377. * This function will remove the local cached buffer data from texture.
  2378. * It will save memory but will prevent the texture from being rebuilt
  2379. */
  2380. cleanCachedTextureBuffer(): void;
  2381. /**
  2382. * Get the world extend vectors with an optional filter
  2383. *
  2384. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2385. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2386. */
  2387. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2388. min: Vector3;
  2389. max: Vector3;
  2390. };
  2391. /**
  2392. * Creates a ray that can be used to pick in the scene
  2393. * @param x defines the x coordinate of the origin (on-screen)
  2394. * @param y defines the y coordinate of the origin (on-screen)
  2395. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2396. * @param camera defines the camera to use for the picking
  2397. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2398. * @returns a Ray
  2399. */
  2400. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2401. /**
  2402. * Creates a ray that can be used to pick in the scene
  2403. * @param x defines the x coordinate of the origin (on-screen)
  2404. * @param y defines the y coordinate of the origin (on-screen)
  2405. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2406. * @param result defines the ray where to store the picking ray
  2407. * @param camera defines the camera to use for the picking
  2408. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2409. * @returns the current scene
  2410. */
  2411. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2412. /**
  2413. * Creates a ray that can be used to pick in the scene
  2414. * @param x defines the x coordinate of the origin (on-screen)
  2415. * @param y defines the y coordinate of the origin (on-screen)
  2416. * @param camera defines the camera to use for the picking
  2417. * @returns a Ray
  2418. */
  2419. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2420. /**
  2421. * Creates a ray that can be used to pick in the scene
  2422. * @param x defines the x coordinate of the origin (on-screen)
  2423. * @param y defines the y coordinate of the origin (on-screen)
  2424. * @param result defines the ray where to store the picking ray
  2425. * @param camera defines the camera to use for the picking
  2426. * @returns the current scene
  2427. */
  2428. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2429. private _internalPick;
  2430. private _internalMultiPick;
  2431. private _tempPickingRay;
  2432. /** Launch a ray to try to pick a mesh in the scene
  2433. * @param x position on screen
  2434. * @param y position on screen
  2435. * @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
  2436. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2437. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2438. * @returns a PickingInfo
  2439. */
  2440. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2441. private _cachedRayForTransform;
  2442. /** Use the given ray to pick a mesh in the scene
  2443. * @param ray The ray to use to pick meshes
  2444. * @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
  2445. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2446. * @returns a PickingInfo
  2447. */
  2448. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2449. /**
  2450. * Launch a ray to try to pick a mesh in the scene
  2451. * @param x X position on screen
  2452. * @param y Y position on screen
  2453. * @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
  2454. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2455. * @returns an array of PickingInfo
  2456. */
  2457. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2458. /**
  2459. * Launch a ray to try to pick a mesh in the scene
  2460. * @param ray Ray to use
  2461. * @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
  2462. * @returns an array of PickingInfo
  2463. */
  2464. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2465. /**
  2466. * Force the value of meshUnderPointer
  2467. * @param mesh defines the mesh to use
  2468. */
  2469. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2470. /**
  2471. * Gets the mesh under the pointer
  2472. * @returns a Mesh or null if no mesh is under the pointer
  2473. */
  2474. getPointerOverMesh(): Nullable<AbstractMesh>;
  2475. /** @hidden */
  2476. _rebuildGeometries(): void;
  2477. /** @hidden */
  2478. _rebuildTextures(): void;
  2479. private _getByTags;
  2480. /**
  2481. * Get a list of meshes by tags
  2482. * @param tagsQuery defines the tags query to use
  2483. * @param forEach defines a predicate used to filter results
  2484. * @returns an array of Mesh
  2485. */
  2486. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2487. /**
  2488. * Get a list of cameras by tags
  2489. * @param tagsQuery defines the tags query to use
  2490. * @param forEach defines a predicate used to filter results
  2491. * @returns an array of Camera
  2492. */
  2493. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2494. /**
  2495. * Get a list of lights by tags
  2496. * @param tagsQuery defines the tags query to use
  2497. * @param forEach defines a predicate used to filter results
  2498. * @returns an array of Light
  2499. */
  2500. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2501. /**
  2502. * Get a list of materials by tags
  2503. * @param tagsQuery defines the tags query to use
  2504. * @param forEach defines a predicate used to filter results
  2505. * @returns an array of Material
  2506. */
  2507. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2508. /**
  2509. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2510. * This allowed control for front to back rendering or reversly depending of the special needs.
  2511. *
  2512. * @param renderingGroupId The rendering group id corresponding to its index
  2513. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2514. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2515. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2516. */
  2517. 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;
  2518. /**
  2519. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2520. *
  2521. * @param renderingGroupId The rendering group id corresponding to its index
  2522. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2523. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2524. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2525. */
  2526. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2527. /**
  2528. * Gets the current auto clear configuration for one rendering group of the rendering
  2529. * manager.
  2530. * @param index the rendering group index to get the information for
  2531. * @returns The auto clear setup for the requested rendering group
  2532. */
  2533. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2534. private _blockMaterialDirtyMechanism;
  2535. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2536. blockMaterialDirtyMechanism: boolean;
  2537. /**
  2538. * Will flag all materials as dirty to trigger new shader compilation
  2539. * @param flag defines the flag used to specify which material part must be marked as dirty
  2540. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2541. */
  2542. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2543. /** @hidden */
  2544. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2545. /** @hidden */
  2546. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2547. }
  2548. }
  2549. declare module BABYLON {
  2550. /**
  2551. * Groups all the scene component constants in one place to ease maintenance.
  2552. * @hidden
  2553. */
  2554. class SceneComponentConstants {
  2555. static readonly NAME_EFFECTLAYER: string;
  2556. static readonly NAME_LAYER: string;
  2557. static readonly NAME_LENSFLARESYSTEM: string;
  2558. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2559. static readonly NAME_PARTICLESYSTEM: string;
  2560. static readonly NAME_GAMEPAD: string;
  2561. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2562. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2563. static readonly NAME_DEPTHRENDERER: string;
  2564. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2565. static readonly NAME_SPRITE: string;
  2566. static readonly NAME_OUTLINERENDERER: string;
  2567. static readonly NAME_PROCEDURALTEXTURE: string;
  2568. static readonly NAME_SHADOWGENERATOR: string;
  2569. static readonly NAME_OCTREE: string;
  2570. static readonly NAME_PHYSICSENGINE: string;
  2571. static readonly NAME_AUDIO: string;
  2572. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2573. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2574. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2575. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2576. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2577. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2578. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2579. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2580. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2581. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2582. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2583. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2584. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2585. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2586. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2587. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2588. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2589. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2590. static readonly STEP_AFTERRENDER_AUDIO: number;
  2591. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2592. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2593. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2594. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2595. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2596. static readonly STEP_POINTERMOVE_SPRITE: number;
  2597. static readonly STEP_POINTERDOWN_SPRITE: number;
  2598. static readonly STEP_POINTERUP_SPRITE: number;
  2599. }
  2600. /**
  2601. * This represents a scene component.
  2602. *
  2603. * This is used to decouple the dependency the scene is having on the different workloads like
  2604. * layers, post processes...
  2605. */
  2606. interface ISceneComponent {
  2607. /**
  2608. * The name of the component. Each component must have a unique name.
  2609. */
  2610. name: string;
  2611. /**
  2612. * The scene the component belongs to.
  2613. */
  2614. scene: Scene;
  2615. /**
  2616. * Register the component to one instance of a scene.
  2617. */
  2618. register(): void;
  2619. /**
  2620. * Rebuilds the elements related to this component in case of
  2621. * context lost for instance.
  2622. */
  2623. rebuild(): void;
  2624. /**
  2625. * Disposes the component and the associated ressources.
  2626. */
  2627. dispose(): void;
  2628. }
  2629. /**
  2630. * This represents a SERIALIZABLE scene component.
  2631. *
  2632. * This extends Scene Component to add Serialization methods on top.
  2633. */
  2634. interface ISceneSerializableComponent extends ISceneComponent {
  2635. /**
  2636. * Adds all the element from the container to the scene
  2637. * @param container the container holding the elements
  2638. */
  2639. addFromContainer(container: AbstractScene): void;
  2640. /**
  2641. * Removes all the elements in the container from the scene
  2642. * @param container contains the elements to remove
  2643. */
  2644. removeFromContainer(container: AbstractScene): void;
  2645. /**
  2646. * Serializes the component data to the specified json object
  2647. * @param serializationObject The object to serialize to
  2648. */
  2649. serialize(serializationObject: any): void;
  2650. }
  2651. /**
  2652. * Strong typing of a Mesh related stage step action
  2653. */
  2654. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2655. /**
  2656. * Strong typing of a Evaluate Sub Mesh related stage step action
  2657. */
  2658. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2659. /**
  2660. * Strong typing of a Active Mesh related stage step action
  2661. */
  2662. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2663. /**
  2664. * Strong typing of a Camera related stage step action
  2665. */
  2666. type CameraStageAction = (camera: Camera) => void;
  2667. /**
  2668. * Strong typing of a RenderingGroup related stage step action
  2669. */
  2670. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2671. /**
  2672. * Strong typing of a Mesh Render related stage step action
  2673. */
  2674. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2675. /**
  2676. * Strong typing of a simple stage step action
  2677. */
  2678. type SimpleStageAction = () => void;
  2679. /**
  2680. * Strong typing of a render target action.
  2681. */
  2682. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2683. /**
  2684. * Strong typing of a pointer move action.
  2685. */
  2686. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2687. /**
  2688. * Strong typing of a pointer up/down action.
  2689. */
  2690. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2691. /**
  2692. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2693. * @hidden
  2694. */
  2695. class Stage<T extends Function> extends Array<{
  2696. index: number;
  2697. component: ISceneComponent;
  2698. action: T;
  2699. }> {
  2700. /**
  2701. * Hide ctor from the rest of the world.
  2702. * @param items The items to add.
  2703. */
  2704. private constructor();
  2705. /**
  2706. * Creates a new Stage.
  2707. * @returns A new instance of a Stage
  2708. */
  2709. static Create<T extends Function>(): Stage<T>;
  2710. /**
  2711. * Registers a step in an ordered way in the targeted stage.
  2712. * @param index Defines the position to register the step in
  2713. * @param component Defines the component attached to the step
  2714. * @param action Defines the action to launch during the step
  2715. */
  2716. registerStep(index: number, component: ISceneComponent, action: T): void;
  2717. /**
  2718. * Clears all the steps from the stage.
  2719. */
  2720. clear(): void;
  2721. }
  2722. }
  2723. declare module BABYLON {
  2724. /** Alias type for value that can be null */
  2725. type Nullable<T> = T | null;
  2726. /**
  2727. * Alias type for number that are floats
  2728. * @ignorenaming
  2729. */
  2730. type float = number;
  2731. /**
  2732. * Alias type for number that are doubles.
  2733. * @ignorenaming
  2734. */
  2735. type double = number;
  2736. /**
  2737. * Alias type for number that are integer
  2738. * @ignorenaming
  2739. */
  2740. type int = number;
  2741. /** Alias type for number array or Float32Array */
  2742. type FloatArray = number[] | Float32Array;
  2743. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2744. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2745. /**
  2746. * Alias for types that can be used by a Buffer or VertexBuffer.
  2747. */
  2748. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2749. }
  2750. declare module BABYLON {
  2751. /**
  2752. * The action to be carried out following a trigger
  2753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2754. */
  2755. class Action {
  2756. /** the trigger, with or without parameters, for the action */
  2757. triggerOptions: any;
  2758. /**
  2759. * Trigger for the action
  2760. */
  2761. trigger: number;
  2762. /**
  2763. * Internal only - manager for action
  2764. * @hidden
  2765. */
  2766. _actionManager: ActionManager;
  2767. private _nextActiveAction;
  2768. private _child;
  2769. private _condition?;
  2770. private _triggerParameter;
  2771. /**
  2772. * An event triggered prior to action being executed.
  2773. */
  2774. onBeforeExecuteObservable: Observable<Action>;
  2775. /**
  2776. * Creates a new Action
  2777. * @param triggerOptions the trigger, with or without parameters, for the action
  2778. * @param condition an optional determinant of action
  2779. */
  2780. constructor(
  2781. /** the trigger, with or without parameters, for the action */
  2782. triggerOptions: any, condition?: Condition);
  2783. /**
  2784. * Internal only
  2785. * @hidden
  2786. */
  2787. _prepare(): void;
  2788. /**
  2789. * Gets the trigger parameters
  2790. * @returns the trigger parameters
  2791. */
  2792. getTriggerParameter(): any;
  2793. /**
  2794. * Internal only - executes current action event
  2795. * @hidden
  2796. */
  2797. _executeCurrent(evt?: ActionEvent): void;
  2798. /**
  2799. * Execute placeholder for child classes
  2800. * @param evt optional action event
  2801. */
  2802. execute(evt?: ActionEvent): void;
  2803. /**
  2804. * Skips to next active action
  2805. */
  2806. skipToNextActiveAction(): void;
  2807. /**
  2808. * Adds action to chain of actions, may be a DoNothingAction
  2809. * @param action defines the next action to execute
  2810. * @returns The action passed in
  2811. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2812. */
  2813. then(action: Action): Action;
  2814. /**
  2815. * Internal only
  2816. * @hidden
  2817. */
  2818. _getProperty(propertyPath: string): string;
  2819. /**
  2820. * Internal only
  2821. * @hidden
  2822. */
  2823. _getEffectiveTarget(target: any, propertyPath: string): any;
  2824. /**
  2825. * Serialize placeholder for child classes
  2826. * @param parent of child
  2827. * @returns the serialized object
  2828. */
  2829. serialize(parent: any): any;
  2830. /**
  2831. * Internal only called by serialize
  2832. * @hidden
  2833. */
  2834. protected _serialize(serializedAction: any, parent?: any): any;
  2835. /**
  2836. * Internal only
  2837. * @hidden
  2838. */
  2839. static _SerializeValueAsString: (value: any) => string;
  2840. /**
  2841. * Internal only
  2842. * @hidden
  2843. */
  2844. static _GetTargetProperty: (target: Scene | Node) => {
  2845. name: string;
  2846. targetType: string;
  2847. value: string;
  2848. };
  2849. }
  2850. }
  2851. declare module BABYLON {
  2852. /**
  2853. * ActionEvent is the event being sent when an action is triggered.
  2854. */
  2855. class ActionEvent {
  2856. /** The mesh or sprite that triggered the action */
  2857. source: any;
  2858. /** The X mouse cursor position at the time of the event */
  2859. pointerX: number;
  2860. /** The Y mouse cursor position at the time of the event */
  2861. pointerY: number;
  2862. /** The mesh that is currently pointed at (can be null) */
  2863. meshUnderPointer: Nullable<AbstractMesh>;
  2864. /** the original (browser) event that triggered the ActionEvent */
  2865. sourceEvent?: any;
  2866. /** additional data for the event */
  2867. additionalData?: any;
  2868. /**
  2869. * Creates a new ActionEvent
  2870. * @param source The mesh or sprite that triggered the action
  2871. * @param pointerX The X mouse cursor position at the time of the event
  2872. * @param pointerY The Y mouse cursor position at the time of the event
  2873. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2874. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2875. * @param additionalData additional data for the event
  2876. */
  2877. constructor(
  2878. /** The mesh or sprite that triggered the action */
  2879. source: any,
  2880. /** The X mouse cursor position at the time of the event */
  2881. pointerX: number,
  2882. /** The Y mouse cursor position at the time of the event */
  2883. pointerY: number,
  2884. /** The mesh that is currently pointed at (can be null) */
  2885. meshUnderPointer: Nullable<AbstractMesh>,
  2886. /** the original (browser) event that triggered the ActionEvent */
  2887. sourceEvent?: any,
  2888. /** additional data for the event */
  2889. additionalData?: any);
  2890. /**
  2891. * Helper function to auto-create an ActionEvent from a source mesh.
  2892. * @param source The source mesh that triggered the event
  2893. * @param evt The original (browser) event
  2894. * @param additionalData additional data for the event
  2895. * @returns the new ActionEvent
  2896. */
  2897. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2898. /**
  2899. * Helper function to auto-create an ActionEvent from a source sprite
  2900. * @param source The source sprite that triggered the event
  2901. * @param scene Scene associated with the sprite
  2902. * @param evt The original (browser) event
  2903. * @param additionalData additional data for the event
  2904. * @returns the new ActionEvent
  2905. */
  2906. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2907. /**
  2908. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2909. * @param scene the scene where the event occurred
  2910. * @param evt The original (browser) event
  2911. * @returns the new ActionEvent
  2912. */
  2913. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2914. /**
  2915. * Helper function to auto-create an ActionEvent from a primitive
  2916. * @param prim defines the target primitive
  2917. * @param pointerPos defines the pointer position
  2918. * @param evt The original (browser) event
  2919. * @param additionalData additional data for the event
  2920. * @returns the new ActionEvent
  2921. */
  2922. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2923. }
  2924. /**
  2925. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2926. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2928. */
  2929. class ActionManager {
  2930. /**
  2931. * Nothing
  2932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2933. */
  2934. static readonly NothingTrigger: number;
  2935. /**
  2936. * On pick
  2937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2938. */
  2939. static readonly OnPickTrigger: number;
  2940. /**
  2941. * On left pick
  2942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2943. */
  2944. static readonly OnLeftPickTrigger: number;
  2945. /**
  2946. * On right pick
  2947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2948. */
  2949. static readonly OnRightPickTrigger: number;
  2950. /**
  2951. * On center pick
  2952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2953. */
  2954. static readonly OnCenterPickTrigger: number;
  2955. /**
  2956. * On pick down
  2957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2958. */
  2959. static readonly OnPickDownTrigger: number;
  2960. /**
  2961. * On double pick
  2962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2963. */
  2964. static readonly OnDoublePickTrigger: number;
  2965. /**
  2966. * On pick up
  2967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2968. */
  2969. static readonly OnPickUpTrigger: number;
  2970. /**
  2971. * On pick out.
  2972. * This trigger will only be raised if you also declared a OnPickDown
  2973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2974. */
  2975. static readonly OnPickOutTrigger: number;
  2976. /**
  2977. * On long press
  2978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2979. */
  2980. static readonly OnLongPressTrigger: number;
  2981. /**
  2982. * On pointer over
  2983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2984. */
  2985. static readonly OnPointerOverTrigger: number;
  2986. /**
  2987. * On pointer out
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2989. */
  2990. static readonly OnPointerOutTrigger: number;
  2991. /**
  2992. * On every frame
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly OnEveryFrameTrigger: number;
  2996. /**
  2997. * On intersection enter
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnIntersectionEnterTrigger: number;
  3001. /**
  3002. * On intersection exit
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnIntersectionExitTrigger: number;
  3006. /**
  3007. * On key down
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnKeyDownTrigger: number;
  3011. /**
  3012. * On key up
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnKeyUpTrigger: number;
  3016. /** Gets the list of active triggers */
  3017. static Triggers: {
  3018. [key: string]: number;
  3019. };
  3020. /** Gets the list of actions */
  3021. actions: Action[];
  3022. /** Gets the cursor to use when hovering items */
  3023. hoverCursor: string;
  3024. private _scene;
  3025. /**
  3026. * Creates a new action manager
  3027. * @param scene defines the hosting scene
  3028. */
  3029. constructor(scene: Scene);
  3030. /**
  3031. * Releases all associated resources
  3032. */
  3033. dispose(): void;
  3034. /**
  3035. * Gets hosting scene
  3036. * @returns the hosting scene
  3037. */
  3038. getScene(): Scene;
  3039. /**
  3040. * Does this action manager handles actions of any of the given triggers
  3041. * @param triggers defines the triggers to be tested
  3042. * @return a boolean indicating whether one (or more) of the triggers is handled
  3043. */
  3044. hasSpecificTriggers(triggers: number[]): boolean;
  3045. /**
  3046. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3047. * speed.
  3048. * @param triggerA defines the trigger to be tested
  3049. * @param triggerB defines the trigger to be tested
  3050. * @return a boolean indicating whether one (or more) of the triggers is handled
  3051. */
  3052. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3053. /**
  3054. * Does this action manager handles actions of a given trigger
  3055. * @param trigger defines the trigger to be tested
  3056. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3057. * @return whether the trigger is handled
  3058. */
  3059. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3060. /**
  3061. * Does this action manager has pointer triggers
  3062. */
  3063. readonly hasPointerTriggers: boolean;
  3064. /**
  3065. * Does this action manager has pick triggers
  3066. */
  3067. readonly hasPickTriggers: boolean;
  3068. /**
  3069. * Does exist one action manager with at least one trigger
  3070. **/
  3071. static readonly HasTriggers: boolean;
  3072. /**
  3073. * Does exist one action manager with at least one pick trigger
  3074. **/
  3075. static readonly HasPickTriggers: boolean;
  3076. /**
  3077. * Does exist one action manager that handles actions of a given trigger
  3078. * @param trigger defines the trigger to be tested
  3079. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3080. **/
  3081. static HasSpecificTrigger(trigger: number): boolean;
  3082. /**
  3083. * Registers an action to this action manager
  3084. * @param action defines the action to be registered
  3085. * @return the action amended (prepared) after registration
  3086. */
  3087. registerAction(action: Action): Nullable<Action>;
  3088. /**
  3089. * Unregisters an action to this action manager
  3090. * @param action defines the action to be unregistered
  3091. * @return a boolean indicating whether the action has been unregistered
  3092. */
  3093. unregisterAction(action: Action): Boolean;
  3094. /**
  3095. * Process a specific trigger
  3096. * @param trigger defines the trigger to process
  3097. * @param evt defines the event details to be processed
  3098. */
  3099. processTrigger(trigger: number, evt?: ActionEvent): void;
  3100. /** @hidden */
  3101. _getEffectiveTarget(target: any, propertyPath: string): any;
  3102. /** @hidden */
  3103. _getProperty(propertyPath: string): string;
  3104. /**
  3105. * Serialize this manager to a JSON object
  3106. * @param name defines the property name to store this manager
  3107. * @returns a JSON representation of this manager
  3108. */
  3109. serialize(name: string): any;
  3110. /**
  3111. * Creates a new ActionManager from a JSON data
  3112. * @param parsedActions defines the JSON data to read from
  3113. * @param object defines the hosting mesh
  3114. * @param scene defines the hosting scene
  3115. */
  3116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3117. /**
  3118. * Get a trigger name by index
  3119. * @param trigger defines the trigger index
  3120. * @returns a trigger name
  3121. */
  3122. static GetTriggerName(trigger: number): string;
  3123. }
  3124. }
  3125. declare module BABYLON {
  3126. /**
  3127. * A Condition applied to an Action
  3128. */
  3129. class Condition {
  3130. /**
  3131. * Internal only - manager for action
  3132. * @hidden
  3133. */
  3134. _actionManager: ActionManager;
  3135. /**
  3136. * Internal only
  3137. * @hidden
  3138. */
  3139. _evaluationId: number;
  3140. /**
  3141. * Internal only
  3142. * @hidden
  3143. */
  3144. _currentResult: boolean;
  3145. /**
  3146. * Creates a new Condition
  3147. * @param actionManager the manager of the action the condition is applied to
  3148. */
  3149. constructor(actionManager: ActionManager);
  3150. /**
  3151. * Check if the current condition is valid
  3152. * @returns a boolean
  3153. */
  3154. isValid(): boolean;
  3155. /**
  3156. * Internal only
  3157. * @hidden
  3158. */
  3159. _getProperty(propertyPath: string): string;
  3160. /**
  3161. * Internal only
  3162. * @hidden
  3163. */
  3164. _getEffectiveTarget(target: any, propertyPath: string): any;
  3165. /**
  3166. * Serialize placeholder for child classes
  3167. * @returns the serialized object
  3168. */
  3169. serialize(): any;
  3170. /**
  3171. * Internal only
  3172. * @hidden
  3173. */
  3174. protected _serialize(serializedCondition: any): any;
  3175. }
  3176. /**
  3177. * Defines specific conditional operators as extensions of Condition
  3178. */
  3179. class ValueCondition extends Condition {
  3180. /** path to specify the property of the target the conditional operator uses */
  3181. propertyPath: string;
  3182. /** the value compared by the conditional operator against the current value of the property */
  3183. value: any;
  3184. /** the conditional operator, default ValueCondition.IsEqual */
  3185. operator: number;
  3186. /**
  3187. * Internal only
  3188. * @hidden
  3189. */
  3190. private static _IsEqual;
  3191. /**
  3192. * Internal only
  3193. * @hidden
  3194. */
  3195. private static _IsDifferent;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. private static _IsGreater;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. private static _IsLesser;
  3206. /**
  3207. * returns the number for IsEqual
  3208. */
  3209. static readonly IsEqual: number;
  3210. /**
  3211. * Returns the number for IsDifferent
  3212. */
  3213. static readonly IsDifferent: number;
  3214. /**
  3215. * Returns the number for IsGreater
  3216. */
  3217. static readonly IsGreater: number;
  3218. /**
  3219. * Returns the number for IsLesser
  3220. */
  3221. static readonly IsLesser: number;
  3222. /**
  3223. * Internal only The action manager for the condition
  3224. * @hidden
  3225. */
  3226. _actionManager: ActionManager;
  3227. /**
  3228. * Internal only
  3229. * @hidden
  3230. */
  3231. private _target;
  3232. /**
  3233. * Internal only
  3234. * @hidden
  3235. */
  3236. private _effectiveTarget;
  3237. /**
  3238. * Internal only
  3239. * @hidden
  3240. */
  3241. private _property;
  3242. /**
  3243. * Creates a new ValueCondition
  3244. * @param actionManager manager for the action the condition applies to
  3245. * @param target for the action
  3246. * @param propertyPath path to specify the property of the target the conditional operator uses
  3247. * @param value the value compared by the conditional operator against the current value of the property
  3248. * @param operator the conditional operator, default ValueCondition.IsEqual
  3249. */
  3250. constructor(actionManager: ActionManager, target: any,
  3251. /** path to specify the property of the target the conditional operator uses */
  3252. propertyPath: string,
  3253. /** the value compared by the conditional operator against the current value of the property */
  3254. value: any,
  3255. /** the conditional operator, default ValueCondition.IsEqual */
  3256. operator?: number);
  3257. /**
  3258. * Compares the given value with the property value for the specified conditional operator
  3259. * @returns the result of the comparison
  3260. */
  3261. isValid(): boolean;
  3262. /**
  3263. * Serialize the ValueCondition into a JSON compatible object
  3264. * @returns serialization object
  3265. */
  3266. serialize(): any;
  3267. /**
  3268. * Gets the name of the conditional operator for the ValueCondition
  3269. * @param operator the conditional operator
  3270. * @returns the name
  3271. */
  3272. static GetOperatorName(operator: number): string;
  3273. }
  3274. /**
  3275. * Defines a predicate condition as an extension of Condition
  3276. */
  3277. class PredicateCondition extends Condition {
  3278. /** defines the predicate function used to validate the condition */
  3279. predicate: () => boolean;
  3280. /**
  3281. * Internal only - manager for action
  3282. * @hidden
  3283. */
  3284. _actionManager: ActionManager;
  3285. /**
  3286. * Creates a new PredicateCondition
  3287. * @param actionManager manager for the action the condition applies to
  3288. * @param predicate defines the predicate function used to validate the condition
  3289. */
  3290. constructor(actionManager: ActionManager,
  3291. /** defines the predicate function used to validate the condition */
  3292. predicate: () => boolean);
  3293. /**
  3294. * @returns the validity of the predicate condition
  3295. */
  3296. isValid(): boolean;
  3297. }
  3298. /**
  3299. * Defines a state condition as an extension of Condition
  3300. */
  3301. class StateCondition extends Condition {
  3302. /** Value to compare with target state */
  3303. value: string;
  3304. /**
  3305. * Internal only - manager for action
  3306. * @hidden
  3307. */
  3308. _actionManager: ActionManager;
  3309. /**
  3310. * Internal only
  3311. * @hidden
  3312. */
  3313. private _target;
  3314. /**
  3315. * Creates a new StateCondition
  3316. * @param actionManager manager for the action the condition applies to
  3317. * @param target of the condition
  3318. * @param value to compare with target state
  3319. */
  3320. constructor(actionManager: ActionManager, target: any,
  3321. /** Value to compare with target state */
  3322. value: string);
  3323. /**
  3324. * Gets a boolean indicating if the current condition is met
  3325. * @returns the validity of the state
  3326. */
  3327. isValid(): boolean;
  3328. /**
  3329. * Serialize the StateCondition into a JSON compatible object
  3330. * @returns serialization object
  3331. */
  3332. serialize(): any;
  3333. }
  3334. }
  3335. declare module BABYLON {
  3336. /**
  3337. * This defines an action responsible to toggle a boolean once triggered.
  3338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3339. */
  3340. class SwitchBooleanAction extends Action {
  3341. /**
  3342. * The path to the boolean property in the target object
  3343. */
  3344. propertyPath: string;
  3345. private _target;
  3346. private _effectiveTarget;
  3347. private _property;
  3348. /**
  3349. * Instantiate the action
  3350. * @param triggerOptions defines the trigger options
  3351. * @param target defines the object containing the boolean
  3352. * @param propertyPath defines the path to the boolean property in the target object
  3353. * @param condition defines the trigger related conditions
  3354. */
  3355. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3356. /** @hidden */
  3357. _prepare(): void;
  3358. /**
  3359. * Execute the action toggle the boolean value.
  3360. */
  3361. execute(): void;
  3362. /**
  3363. * Serializes the actions and its related information.
  3364. * @param parent defines the object to serialize in
  3365. * @returns the serialized object
  3366. */
  3367. serialize(parent: any): any;
  3368. }
  3369. /**
  3370. * This defines an action responsible to set a the state field of the target
  3371. * to a desired value once triggered.
  3372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3373. */
  3374. class SetStateAction extends Action {
  3375. /**
  3376. * The value to store in the state field.
  3377. */
  3378. value: string;
  3379. private _target;
  3380. /**
  3381. * Instantiate the action
  3382. * @param triggerOptions defines the trigger options
  3383. * @param target defines the object containing the state property
  3384. * @param value defines the value to store in the state field
  3385. * @param condition defines the trigger related conditions
  3386. */
  3387. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3388. /**
  3389. * Execute the action and store the value on the target state property.
  3390. */
  3391. execute(): void;
  3392. /**
  3393. * Serializes the actions and its related information.
  3394. * @param parent defines the object to serialize in
  3395. * @returns the serialized object
  3396. */
  3397. serialize(parent: any): any;
  3398. }
  3399. /**
  3400. * This defines an action responsible to set a property of the target
  3401. * to a desired value once triggered.
  3402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3403. */
  3404. class SetValueAction extends Action {
  3405. /**
  3406. * The path of the property to set in the target.
  3407. */
  3408. propertyPath: string;
  3409. /**
  3410. * The value to set in the property
  3411. */
  3412. value: any;
  3413. private _target;
  3414. private _effectiveTarget;
  3415. private _property;
  3416. /**
  3417. * Instantiate the action
  3418. * @param triggerOptions defines the trigger options
  3419. * @param target defines the object containing the property
  3420. * @param propertyPath defines the path of the property to set in the target
  3421. * @param value defines the value to set in the property
  3422. * @param condition defines the trigger related conditions
  3423. */
  3424. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3425. /** @hidden */
  3426. _prepare(): void;
  3427. /**
  3428. * Execute the action and set the targetted property to the desired value.
  3429. */
  3430. execute(): void;
  3431. /**
  3432. * Serializes the actions and its related information.
  3433. * @param parent defines the object to serialize in
  3434. * @returns the serialized object
  3435. */
  3436. serialize(parent: any): any;
  3437. }
  3438. /**
  3439. * This defines an action responsible to increment the target value
  3440. * to a desired value once triggered.
  3441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3442. */
  3443. class IncrementValueAction extends Action {
  3444. /**
  3445. * The path of the property to increment in the target.
  3446. */
  3447. propertyPath: string;
  3448. /**
  3449. * The value we should increment the property by.
  3450. */
  3451. value: any;
  3452. private _target;
  3453. private _effectiveTarget;
  3454. private _property;
  3455. /**
  3456. * Instantiate the action
  3457. * @param triggerOptions defines the trigger options
  3458. * @param target defines the object containing the property
  3459. * @param propertyPath defines the path of the property to increment in the target
  3460. * @param value defines the value value we should increment the property by
  3461. * @param condition defines the trigger related conditions
  3462. */
  3463. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3464. /** @hidden */
  3465. _prepare(): void;
  3466. /**
  3467. * Execute the action and increment the target of the value amount.
  3468. */
  3469. execute(): void;
  3470. /**
  3471. * Serializes the actions and its related information.
  3472. * @param parent defines the object to serialize in
  3473. * @returns the serialized object
  3474. */
  3475. serialize(parent: any): any;
  3476. }
  3477. /**
  3478. * This defines an action responsible to start an animation once triggered.
  3479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3480. */
  3481. class PlayAnimationAction extends Action {
  3482. /**
  3483. * Where the animation should start (animation frame)
  3484. */
  3485. from: number;
  3486. /**
  3487. * Where the animation should stop (animation frame)
  3488. */
  3489. to: number;
  3490. /**
  3491. * Define if the animation should loop or stop after the first play.
  3492. */
  3493. loop?: boolean;
  3494. private _target;
  3495. /**
  3496. * Instantiate the action
  3497. * @param triggerOptions defines the trigger options
  3498. * @param target defines the target animation or animation name
  3499. * @param from defines from where the animation should start (animation frame)
  3500. * @param end defines where the animation should stop (animation frame)
  3501. * @param loop defines if the animation should loop or stop after the first play
  3502. * @param condition defines the trigger related conditions
  3503. */
  3504. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3505. /** @hidden */
  3506. _prepare(): void;
  3507. /**
  3508. * Execute the action and play the animation.
  3509. */
  3510. execute(): void;
  3511. /**
  3512. * Serializes the actions and its related information.
  3513. * @param parent defines the object to serialize in
  3514. * @returns the serialized object
  3515. */
  3516. serialize(parent: any): any;
  3517. }
  3518. /**
  3519. * This defines an action responsible to stop an animation once triggered.
  3520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3521. */
  3522. class StopAnimationAction extends Action {
  3523. private _target;
  3524. /**
  3525. * Instantiate the action
  3526. * @param triggerOptions defines the trigger options
  3527. * @param target defines the target animation or animation name
  3528. * @param condition defines the trigger related conditions
  3529. */
  3530. constructor(triggerOptions: any, target: any, condition?: Condition);
  3531. /** @hidden */
  3532. _prepare(): void;
  3533. /**
  3534. * Execute the action and stop the animation.
  3535. */
  3536. execute(): void;
  3537. /**
  3538. * Serializes the actions and its related information.
  3539. * @param parent defines the object to serialize in
  3540. * @returns the serialized object
  3541. */
  3542. serialize(parent: any): any;
  3543. }
  3544. /**
  3545. * This defines an action responsible that does nothing once triggered.
  3546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3547. */
  3548. class DoNothingAction extends Action {
  3549. /**
  3550. * Instantiate the action
  3551. * @param triggerOptions defines the trigger options
  3552. * @param condition defines the trigger related conditions
  3553. */
  3554. constructor(triggerOptions?: any, condition?: Condition);
  3555. /**
  3556. * Execute the action and do nothing.
  3557. */
  3558. execute(): void;
  3559. /**
  3560. * Serializes the actions and its related information.
  3561. * @param parent defines the object to serialize in
  3562. * @returns the serialized object
  3563. */
  3564. serialize(parent: any): any;
  3565. }
  3566. /**
  3567. * This defines an action responsible to trigger several actions once triggered.
  3568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3569. */
  3570. class CombineAction extends Action {
  3571. /**
  3572. * The list of aggregated animations to run.
  3573. */
  3574. children: Action[];
  3575. /**
  3576. * Instantiate the action
  3577. * @param triggerOptions defines the trigger options
  3578. * @param children defines the list of aggregated animations to run
  3579. * @param condition defines the trigger related conditions
  3580. */
  3581. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3582. /** @hidden */
  3583. _prepare(): void;
  3584. /**
  3585. * Execute the action and executes all the aggregated actions.
  3586. */
  3587. execute(evt: ActionEvent): void;
  3588. /**
  3589. * Serializes the actions and its related information.
  3590. * @param parent defines the object to serialize in
  3591. * @returns the serialized object
  3592. */
  3593. serialize(parent: any): any;
  3594. }
  3595. /**
  3596. * This defines an action responsible to run code (external event) once triggered.
  3597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3598. */
  3599. class ExecuteCodeAction extends Action {
  3600. /**
  3601. * The callback function to run.
  3602. */
  3603. func: (evt: ActionEvent) => void;
  3604. /**
  3605. * Instantiate the action
  3606. * @param triggerOptions defines the trigger options
  3607. * @param func defines the callback function to run
  3608. * @param condition defines the trigger related conditions
  3609. */
  3610. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3611. /**
  3612. * Execute the action and run the attached code.
  3613. */
  3614. execute(evt: ActionEvent): void;
  3615. }
  3616. /**
  3617. * This defines an action responsible to set the parent property of the target once triggered.
  3618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3619. */
  3620. class SetParentAction extends Action {
  3621. private _parent;
  3622. private _target;
  3623. /**
  3624. * Instantiate the action
  3625. * @param triggerOptions defines the trigger options
  3626. * @param target defines the target containing the parent property
  3627. * @param parent defines from where the animation should start (animation frame)
  3628. * @param condition defines the trigger related conditions
  3629. */
  3630. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3631. /** @hidden */
  3632. _prepare(): void;
  3633. /**
  3634. * Execute the action and set the parent property.
  3635. */
  3636. execute(): void;
  3637. /**
  3638. * Serializes the actions and its related information.
  3639. * @param parent defines the object to serialize in
  3640. * @returns the serialized object
  3641. */
  3642. serialize(parent: any): any;
  3643. }
  3644. }
  3645. declare module BABYLON {
  3646. /**
  3647. * This defines an action helpful to play a defined sound on a triggered action.
  3648. */
  3649. class PlaySoundAction extends Action {
  3650. private _sound;
  3651. /**
  3652. * Instantiate the action
  3653. * @param triggerOptions defines the trigger options
  3654. * @param sound defines the sound to play
  3655. * @param condition defines the trigger related conditions
  3656. */
  3657. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3658. /** @hidden */
  3659. _prepare(): void;
  3660. /**
  3661. * Execute the action and play the sound.
  3662. */
  3663. execute(): void;
  3664. /**
  3665. * Serializes the actions and its related information.
  3666. * @param parent defines the object to serialize in
  3667. * @returns the serialized object
  3668. */
  3669. serialize(parent: any): any;
  3670. }
  3671. /**
  3672. * This defines an action helpful to stop a defined sound on a triggered action.
  3673. */
  3674. class StopSoundAction extends Action {
  3675. private _sound;
  3676. /**
  3677. * Instantiate the action
  3678. * @param triggerOptions defines the trigger options
  3679. * @param sound defines the sound to stop
  3680. * @param condition defines the trigger related conditions
  3681. */
  3682. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3683. /** @hidden */
  3684. _prepare(): void;
  3685. /**
  3686. * Execute the action and stop the sound.
  3687. */
  3688. execute(): void;
  3689. /**
  3690. * Serializes the actions and its related information.
  3691. * @param parent defines the object to serialize in
  3692. * @returns the serialized object
  3693. */
  3694. serialize(parent: any): any;
  3695. }
  3696. }
  3697. declare module BABYLON {
  3698. /**
  3699. * This defines an action responsible to change the value of a property
  3700. * by interpolating between its current value and the newly set one once triggered.
  3701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3702. */
  3703. class InterpolateValueAction extends Action {
  3704. /**
  3705. * Defines the path of the property where the value should be interpolated
  3706. */
  3707. propertyPath: string;
  3708. /**
  3709. * Defines the target value at the end of the interpolation.
  3710. */
  3711. value: any;
  3712. /**
  3713. * Defines the time it will take for the property to interpolate to the value.
  3714. */
  3715. duration: number;
  3716. /**
  3717. * Defines if the other scene animations should be stopped when the action has been triggered
  3718. */
  3719. stopOtherAnimations?: boolean;
  3720. /**
  3721. * Defines a callback raised once the interpolation animation has been done.
  3722. */
  3723. onInterpolationDone?: () => void;
  3724. /**
  3725. * Observable triggered once the interpolation animation has been done.
  3726. */
  3727. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3728. private _target;
  3729. private _effectiveTarget;
  3730. private _property;
  3731. /**
  3732. * Instantiate the action
  3733. * @param triggerOptions defines the trigger options
  3734. * @param target defines the object containing the value to interpolate
  3735. * @param propertyPath defines the path to the property in the target object
  3736. * @param value defines the target value at the end of the interpolation
  3737. * @param duration deines the time it will take for the property to interpolate to the value.
  3738. * @param condition defines the trigger related conditions
  3739. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3740. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3741. */
  3742. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3743. /** @hidden */
  3744. _prepare(): void;
  3745. /**
  3746. * Execute the action starts the value interpolation.
  3747. */
  3748. execute(): void;
  3749. /**
  3750. * Serializes the actions and its related information.
  3751. * @param parent defines the object to serialize in
  3752. * @returns the serialized object
  3753. */
  3754. serialize(parent: any): any;
  3755. }
  3756. }
  3757. declare module BABYLON {
  3758. /**
  3759. * Class used to store an actual running animation
  3760. */
  3761. class Animatable {
  3762. /** defines the target object */
  3763. target: any;
  3764. /** defines the starting frame number (default is 0) */
  3765. fromFrame: number;
  3766. /** defines the ending frame number (default is 100) */
  3767. toFrame: number;
  3768. /** defines if the animation must loop (default is false) */
  3769. loopAnimation: boolean;
  3770. /** defines a callback to call when animation ends if it is not looping */
  3771. onAnimationEnd?: (() => void) | null | undefined;
  3772. private _localDelayOffset;
  3773. private _pausedDelay;
  3774. private _runtimeAnimations;
  3775. private _paused;
  3776. private _scene;
  3777. private _speedRatio;
  3778. private _weight;
  3779. private _syncRoot;
  3780. /**
  3781. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3782. * This will only apply for non looping animation (default is true)
  3783. */
  3784. disposeOnEnd: boolean;
  3785. /**
  3786. * Gets a boolean indicating if the animation has started
  3787. */
  3788. animationStarted: boolean;
  3789. /**
  3790. * Observer raised when the animation ends
  3791. */
  3792. onAnimationEndObservable: Observable<Animatable>;
  3793. /**
  3794. * Gets the root Animatable used to synchronize and normalize animations
  3795. */
  3796. readonly syncRoot: Animatable;
  3797. /**
  3798. * Gets the current frame of the first RuntimeAnimation
  3799. * Used to synchronize Animatables
  3800. */
  3801. readonly masterFrame: number;
  3802. /**
  3803. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3804. */
  3805. weight: number;
  3806. /**
  3807. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3808. */
  3809. speedRatio: number;
  3810. /**
  3811. * Creates a new Animatable
  3812. * @param scene defines the hosting scene
  3813. * @param target defines the target object
  3814. * @param fromFrame defines the starting frame number (default is 0)
  3815. * @param toFrame defines the ending frame number (default is 100)
  3816. * @param loopAnimation defines if the animation must loop (default is false)
  3817. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3818. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3819. * @param animations defines a group of animation to add to the new Animatable
  3820. */
  3821. constructor(scene: Scene,
  3822. /** defines the target object */
  3823. target: any,
  3824. /** defines the starting frame number (default is 0) */
  3825. fromFrame?: number,
  3826. /** defines the ending frame number (default is 100) */
  3827. toFrame?: number,
  3828. /** defines if the animation must loop (default is false) */
  3829. loopAnimation?: boolean, speedRatio?: number,
  3830. /** defines a callback to call when animation ends if it is not looping */
  3831. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3832. /**
  3833. * Synchronize and normalize current Animatable with a source Animatable
  3834. * This is useful when using animation weights and when animations are not of the same length
  3835. * @param root defines the root Animatable to synchronize with
  3836. * @returns the current Animatable
  3837. */
  3838. syncWith(root: Animatable): Animatable;
  3839. /**
  3840. * Gets the list of runtime animations
  3841. * @returns an array of RuntimeAnimation
  3842. */
  3843. getAnimations(): RuntimeAnimation[];
  3844. /**
  3845. * Adds more animations to the current animatable
  3846. * @param target defines the target of the animations
  3847. * @param animations defines the new animations to add
  3848. */
  3849. appendAnimations(target: any, animations: Animation[]): void;
  3850. /**
  3851. * Gets the source animation for a specific property
  3852. * @param property defines the propertyu to look for
  3853. * @returns null or the source animation for the given property
  3854. */
  3855. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3856. /**
  3857. * Gets the runtime animation for a specific property
  3858. * @param property defines the propertyu to look for
  3859. * @returns null or the runtime animation for the given property
  3860. */
  3861. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3862. /**
  3863. * Resets the animatable to its original state
  3864. */
  3865. reset(): void;
  3866. /**
  3867. * Allows the animatable to blend with current running animations
  3868. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3869. * @param blendingSpeed defines the blending speed to use
  3870. */
  3871. enableBlending(blendingSpeed: number): void;
  3872. /**
  3873. * Disable animation blending
  3874. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3875. */
  3876. disableBlending(): void;
  3877. /**
  3878. * Jump directly to a given frame
  3879. * @param frame defines the frame to jump to
  3880. */
  3881. goToFrame(frame: number): void;
  3882. /**
  3883. * Pause the animation
  3884. */
  3885. pause(): void;
  3886. /**
  3887. * Restart the animation
  3888. */
  3889. restart(): void;
  3890. private _raiseOnAnimationEnd;
  3891. /**
  3892. * Stop and delete the current animation
  3893. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3894. * @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)
  3895. */
  3896. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3897. /**
  3898. * Wait asynchronously for the animation to end
  3899. * @returns a promise which will be fullfilled when the animation ends
  3900. */
  3901. waitAsync(): Promise<Animatable>;
  3902. /** @hidden */
  3903. _animate(delay: number): boolean;
  3904. }
  3905. }
  3906. declare module BABYLON {
  3907. /**
  3908. * Represents the range of an animation
  3909. */
  3910. class AnimationRange {
  3911. /**The name of the animation range**/
  3912. name: string;
  3913. /**The starting frame of the animation */
  3914. from: number;
  3915. /**The ending frame of the animation*/
  3916. to: number;
  3917. /**
  3918. * Initializes the range of an animation
  3919. * @param name The name of the animation range
  3920. * @param from The starting frame of the animation
  3921. * @param to The ending frame of the animation
  3922. */
  3923. constructor(
  3924. /**The name of the animation range**/
  3925. name: string,
  3926. /**The starting frame of the animation */
  3927. from: number,
  3928. /**The ending frame of the animation*/
  3929. to: number);
  3930. /**
  3931. * Makes a copy of the animation range
  3932. * @returns A copy of the animation range
  3933. */
  3934. clone(): AnimationRange;
  3935. }
  3936. /**
  3937. * Composed of a frame, and an action function
  3938. */
  3939. class AnimationEvent {
  3940. /** The frame for which the event is triggered **/
  3941. frame: number;
  3942. /** The event to perform when triggered **/
  3943. action: (currentFrame: number) => void;
  3944. /** Specifies if the event should be triggered only once**/
  3945. onlyOnce?: boolean | undefined;
  3946. /**
  3947. * Specifies if the animation event is done
  3948. */
  3949. isDone: boolean;
  3950. /**
  3951. * Initializes the animation event
  3952. * @param frame The frame for which the event is triggered
  3953. * @param action The event to perform when triggered
  3954. * @param onlyOnce Specifies if the event should be triggered only once
  3955. */
  3956. constructor(
  3957. /** The frame for which the event is triggered **/
  3958. frame: number,
  3959. /** The event to perform when triggered **/
  3960. action: (currentFrame: number) => void,
  3961. /** Specifies if the event should be triggered only once**/
  3962. onlyOnce?: boolean | undefined);
  3963. /** @hidden */
  3964. _clone(): AnimationEvent;
  3965. }
  3966. /**
  3967. * A cursor which tracks a point on a path
  3968. */
  3969. class PathCursor {
  3970. private path;
  3971. /**
  3972. * Stores path cursor callbacks for when an onchange event is triggered
  3973. */
  3974. private _onchange;
  3975. /**
  3976. * The value of the path cursor
  3977. */
  3978. value: number;
  3979. /**
  3980. * The animation array of the path cursor
  3981. */
  3982. animations: Animation[];
  3983. /**
  3984. * Initializes the path cursor
  3985. * @param path The path to track
  3986. */
  3987. constructor(path: Path2);
  3988. /**
  3989. * Gets the cursor point on the path
  3990. * @returns A point on the path cursor at the cursor location
  3991. */
  3992. getPoint(): Vector3;
  3993. /**
  3994. * Moves the cursor ahead by the step amount
  3995. * @param step The amount to move the cursor forward
  3996. * @returns This path cursor
  3997. */
  3998. moveAhead(step?: number): PathCursor;
  3999. /**
  4000. * Moves the cursor behind by the step amount
  4001. * @param step The amount to move the cursor back
  4002. * @returns This path cursor
  4003. */
  4004. moveBack(step?: number): PathCursor;
  4005. /**
  4006. * Moves the cursor by the step amount
  4007. * If the step amount is greater than one, an exception is thrown
  4008. * @param step The amount to move the cursor
  4009. * @returns This path cursor
  4010. */
  4011. move(step: number): PathCursor;
  4012. /**
  4013. * Ensures that the value is limited between zero and one
  4014. * @returns This path cursor
  4015. */
  4016. private ensureLimits;
  4017. /**
  4018. * Runs onchange callbacks on change (used by the animation engine)
  4019. * @returns This path cursor
  4020. */
  4021. private raiseOnChange;
  4022. /**
  4023. * Executes a function on change
  4024. * @param f A path cursor onchange callback
  4025. * @returns This path cursor
  4026. */
  4027. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4028. }
  4029. /**
  4030. * Defines an interface which represents an animation key frame
  4031. */
  4032. interface IAnimationKey {
  4033. /**
  4034. * Frame of the key frame
  4035. */
  4036. frame: number;
  4037. /**
  4038. * Value at the specifies key frame
  4039. */
  4040. value: any;
  4041. /**
  4042. * The input tangent for the cubic hermite spline
  4043. */
  4044. inTangent?: any;
  4045. /**
  4046. * The output tangent for the cubic hermite spline
  4047. */
  4048. outTangent?: any;
  4049. /**
  4050. * The animation interpolation type
  4051. */
  4052. interpolation?: AnimationKeyInterpolation;
  4053. }
  4054. /**
  4055. * Enum for the animation key frame interpolation type
  4056. */
  4057. enum AnimationKeyInterpolation {
  4058. /**
  4059. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4060. */
  4061. STEP = 1
  4062. }
  4063. /**
  4064. * Class used to store any kind of animation
  4065. */
  4066. class Animation {
  4067. /**Name of the animation */
  4068. name: string;
  4069. /**Property to animate */
  4070. targetProperty: string;
  4071. /**The frames per second of the animation */
  4072. framePerSecond: number;
  4073. /**The data type of the animation */
  4074. dataType: number;
  4075. /**The loop mode of the animation */
  4076. loopMode?: number | undefined;
  4077. /**Specifies if blending should be enabled */
  4078. enableBlending?: boolean | undefined;
  4079. /**
  4080. * Use matrix interpolation instead of using direct key value when animating matrices
  4081. */
  4082. static AllowMatricesInterpolation: boolean;
  4083. /**
  4084. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4085. */
  4086. static AllowMatrixDecomposeForInterpolation: boolean;
  4087. /**
  4088. * Stores the key frames of the animation
  4089. */
  4090. private _keys;
  4091. /**
  4092. * Stores the easing function of the animation
  4093. */
  4094. private _easingFunction;
  4095. /**
  4096. * @hidden Internal use only
  4097. */
  4098. _runtimeAnimations: RuntimeAnimation[];
  4099. /**
  4100. * The set of event that will be linked to this animation
  4101. */
  4102. private _events;
  4103. /**
  4104. * Stores an array of target property paths
  4105. */
  4106. targetPropertyPath: string[];
  4107. /**
  4108. * Stores the blending speed of the animation
  4109. */
  4110. blendingSpeed: number;
  4111. /**
  4112. * Stores the animation ranges for the animation
  4113. */
  4114. private _ranges;
  4115. /**
  4116. * @hidden Internal use
  4117. */
  4118. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4119. /**
  4120. * Sets up an animation
  4121. * @param property The property to animate
  4122. * @param animationType The animation type to apply
  4123. * @param framePerSecond The frames per second of the animation
  4124. * @param easingFunction The easing function used in the animation
  4125. * @returns The created animation
  4126. */
  4127. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4128. /**
  4129. * Create and start an animation on a node
  4130. * @param name defines the name of the global animation that will be run on all nodes
  4131. * @param node defines the root node where the animation will take place
  4132. * @param targetProperty defines property to animate
  4133. * @param framePerSecond defines the number of frame per second yo use
  4134. * @param totalFrame defines the number of frames in total
  4135. * @param from defines the initial value
  4136. * @param to defines the final value
  4137. * @param loopMode defines which loop mode you want to use (off by default)
  4138. * @param easingFunction defines the easing function to use (linear by default)
  4139. * @param onAnimationEnd defines the callback to call when animation end
  4140. * @returns the animatable created for this animation
  4141. */
  4142. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4143. /**
  4144. * Create and start an animation on a node and its descendants
  4145. * @param name defines the name of the global animation that will be run on all nodes
  4146. * @param node defines the root node where the animation will take place
  4147. * @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
  4148. * @param targetProperty defines property to animate
  4149. * @param framePerSecond defines the number of frame per second to use
  4150. * @param totalFrame defines the number of frames in total
  4151. * @param from defines the initial value
  4152. * @param to defines the final value
  4153. * @param loopMode defines which loop mode you want to use (off by default)
  4154. * @param easingFunction defines the easing function to use (linear by default)
  4155. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4156. * @returns the list of animatables created for all nodes
  4157. * @example https://www.babylonjs-playground.com/#MH0VLI
  4158. */
  4159. 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[]>;
  4160. /**
  4161. * Creates a new animation, merges it with the existing animations and starts it
  4162. * @param name Name of the animation
  4163. * @param node Node which contains the scene that begins the animations
  4164. * @param targetProperty Specifies which property to animate
  4165. * @param framePerSecond The frames per second of the animation
  4166. * @param totalFrame The total number of frames
  4167. * @param from The frame at the beginning of the animation
  4168. * @param to The frame at the end of the animation
  4169. * @param loopMode Specifies the loop mode of the animation
  4170. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4171. * @param onAnimationEnd Callback to run once the animation is complete
  4172. * @returns Nullable animation
  4173. */
  4174. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4175. /**
  4176. * Transition property of an host to the target Value
  4177. * @param property The property to transition
  4178. * @param targetValue The target Value of the property
  4179. * @param host The object where the property to animate belongs
  4180. * @param scene Scene used to run the animation
  4181. * @param frameRate Framerate (in frame/s) to use
  4182. * @param transition The transition type we want to use
  4183. * @param duration The duration of the animation, in milliseconds
  4184. * @param onAnimationEnd Callback trigger at the end of the animation
  4185. * @returns Nullable animation
  4186. */
  4187. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4188. /**
  4189. * Return the array of runtime animations currently using this animation
  4190. */
  4191. readonly runtimeAnimations: RuntimeAnimation[];
  4192. /**
  4193. * Specifies if any of the runtime animations are currently running
  4194. */
  4195. readonly hasRunningRuntimeAnimations: boolean;
  4196. /**
  4197. * Initializes the animation
  4198. * @param name Name of the animation
  4199. * @param targetProperty Property to animate
  4200. * @param framePerSecond The frames per second of the animation
  4201. * @param dataType The data type of the animation
  4202. * @param loopMode The loop mode of the animation
  4203. * @param enableBlendings Specifies if blending should be enabled
  4204. */
  4205. constructor(
  4206. /**Name of the animation */
  4207. name: string,
  4208. /**Property to animate */
  4209. targetProperty: string,
  4210. /**The frames per second of the animation */
  4211. framePerSecond: number,
  4212. /**The data type of the animation */
  4213. dataType: number,
  4214. /**The loop mode of the animation */
  4215. loopMode?: number | undefined,
  4216. /**Specifies if blending should be enabled */
  4217. enableBlending?: boolean | undefined);
  4218. /**
  4219. * Converts the animation to a string
  4220. * @param fullDetails support for multiple levels of logging within scene loading
  4221. * @returns String form of the animation
  4222. */
  4223. toString(fullDetails?: boolean): string;
  4224. /**
  4225. * Add an event to this animation
  4226. * @param event Event to add
  4227. */
  4228. addEvent(event: AnimationEvent): void;
  4229. /**
  4230. * Remove all events found at the given frame
  4231. * @param frame The frame to remove events from
  4232. */
  4233. removeEvents(frame: number): void;
  4234. /**
  4235. * Retrieves all the events from the animation
  4236. * @returns Events from the animation
  4237. */
  4238. getEvents(): AnimationEvent[];
  4239. /**
  4240. * Creates an animation range
  4241. * @param name Name of the animation range
  4242. * @param from Starting frame of the animation range
  4243. * @param to Ending frame of the animation
  4244. */
  4245. createRange(name: string, from: number, to: number): void;
  4246. /**
  4247. * Deletes an animation range by name
  4248. * @param name Name of the animation range to delete
  4249. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4250. */
  4251. deleteRange(name: string, deleteFrames?: boolean): void;
  4252. /**
  4253. * Gets the animation range by name, or null if not defined
  4254. * @param name Name of the animation range
  4255. * @returns Nullable animation range
  4256. */
  4257. getRange(name: string): Nullable<AnimationRange>;
  4258. /**
  4259. * Gets the key frames from the animation
  4260. * @returns The key frames of the animation
  4261. */
  4262. getKeys(): Array<IAnimationKey>;
  4263. /**
  4264. * Gets the highest frame rate of the animation
  4265. * @returns Highest frame rate of the animation
  4266. */
  4267. getHighestFrame(): number;
  4268. /**
  4269. * Gets the easing function of the animation
  4270. * @returns Easing function of the animation
  4271. */
  4272. getEasingFunction(): IEasingFunction;
  4273. /**
  4274. * Sets the easing function of the animation
  4275. * @param easingFunction A custom mathematical formula for animation
  4276. */
  4277. setEasingFunction(easingFunction: EasingFunction): void;
  4278. /**
  4279. * Interpolates a scalar linearly
  4280. * @param startValue Start value of the animation curve
  4281. * @param endValue End value of the animation curve
  4282. * @param gradient Scalar amount to interpolate
  4283. * @returns Interpolated scalar value
  4284. */
  4285. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4286. /**
  4287. * Interpolates a scalar cubically
  4288. * @param startValue Start value of the animation curve
  4289. * @param outTangent End tangent of the animation
  4290. * @param endValue End value of the animation curve
  4291. * @param inTangent Start tangent of the animation curve
  4292. * @param gradient Scalar amount to interpolate
  4293. * @returns Interpolated scalar value
  4294. */
  4295. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4296. /**
  4297. * Interpolates a quaternion using a spherical linear interpolation
  4298. * @param startValue Start value of the animation curve
  4299. * @param endValue End value of the animation curve
  4300. * @param gradient Scalar amount to interpolate
  4301. * @returns Interpolated quaternion value
  4302. */
  4303. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4304. /**
  4305. * Interpolates a quaternion cubically
  4306. * @param startValue Start value of the animation curve
  4307. * @param outTangent End tangent of the animation curve
  4308. * @param endValue End value of the animation curve
  4309. * @param inTangent Start tangent of the animation curve
  4310. * @param gradient Scalar amount to interpolate
  4311. * @returns Interpolated quaternion value
  4312. */
  4313. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4314. /**
  4315. * Interpolates a Vector3 linearl
  4316. * @param startValue Start value of the animation curve
  4317. * @param endValue End value of the animation curve
  4318. * @param gradient Scalar amount to interpolate
  4319. * @returns Interpolated scalar value
  4320. */
  4321. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4322. /**
  4323. * Interpolates a Vector3 cubically
  4324. * @param startValue Start value of the animation curve
  4325. * @param outTangent End tangent of the animation
  4326. * @param endValue End value of the animation curve
  4327. * @param inTangent Start tangent of the animation curve
  4328. * @param gradient Scalar amount to interpolate
  4329. * @returns InterpolatedVector3 value
  4330. */
  4331. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4332. /**
  4333. * Interpolates a Vector2 linearly
  4334. * @param startValue Start value of the animation curve
  4335. * @param endValue End value of the animation curve
  4336. * @param gradient Scalar amount to interpolate
  4337. * @returns Interpolated Vector2 value
  4338. */
  4339. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4340. /**
  4341. * Interpolates a Vector2 cubically
  4342. * @param startValue Start value of the animation curve
  4343. * @param outTangent End tangent of the animation
  4344. * @param endValue End value of the animation curve
  4345. * @param inTangent Start tangent of the animation curve
  4346. * @param gradient Scalar amount to interpolate
  4347. * @returns Interpolated Vector2 value
  4348. */
  4349. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4350. /**
  4351. * Interpolates a size linearly
  4352. * @param startValue Start value of the animation curve
  4353. * @param endValue End value of the animation curve
  4354. * @param gradient Scalar amount to interpolate
  4355. * @returns Interpolated Size value
  4356. */
  4357. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4358. /**
  4359. * Interpolates a Color3 linearly
  4360. * @param startValue Start value of the animation curve
  4361. * @param endValue End value of the animation curve
  4362. * @param gradient Scalar amount to interpolate
  4363. * @returns Interpolated Color3 value
  4364. */
  4365. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4366. /**
  4367. * @hidden Internal use only
  4368. */
  4369. _getKeyValue(value: any): any;
  4370. /**
  4371. * @hidden Internal use only
  4372. */
  4373. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4374. /**
  4375. * Defines the function to use to interpolate matrices
  4376. * @param startValue defines the start matrix
  4377. * @param endValue defines the end matrix
  4378. * @param gradient defines the gradient between both matrices
  4379. * @param result defines an optional target matrix where to store the interpolation
  4380. * @returns the interpolated matrix
  4381. */
  4382. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4383. /**
  4384. * Makes a copy of the animation
  4385. * @returns Cloned animation
  4386. */
  4387. clone(): Animation;
  4388. /**
  4389. * Sets the key frames of the animation
  4390. * @param values The animation key frames to set
  4391. */
  4392. setKeys(values: Array<IAnimationKey>): void;
  4393. /**
  4394. * Serializes the animation to an object
  4395. * @returns Serialized object
  4396. */
  4397. serialize(): any;
  4398. /**
  4399. * Float animation type
  4400. */
  4401. private static _ANIMATIONTYPE_FLOAT;
  4402. /**
  4403. * Vector3 animation type
  4404. */
  4405. private static _ANIMATIONTYPE_VECTOR3;
  4406. /**
  4407. * Quaternion animation type
  4408. */
  4409. private static _ANIMATIONTYPE_QUATERNION;
  4410. /**
  4411. * Matrix animation type
  4412. */
  4413. private static _ANIMATIONTYPE_MATRIX;
  4414. /**
  4415. * Color3 animation type
  4416. */
  4417. private static _ANIMATIONTYPE_COLOR3;
  4418. /**
  4419. * Vector2 animation type
  4420. */
  4421. private static _ANIMATIONTYPE_VECTOR2;
  4422. /**
  4423. * Size animation type
  4424. */
  4425. private static _ANIMATIONTYPE_SIZE;
  4426. /**
  4427. * Relative Loop Mode
  4428. */
  4429. private static _ANIMATIONLOOPMODE_RELATIVE;
  4430. /**
  4431. * Cycle Loop Mode
  4432. */
  4433. private static _ANIMATIONLOOPMODE_CYCLE;
  4434. /**
  4435. * Constant Loop Mode
  4436. */
  4437. private static _ANIMATIONLOOPMODE_CONSTANT;
  4438. /**
  4439. * Get the float animation type
  4440. */
  4441. static readonly ANIMATIONTYPE_FLOAT: number;
  4442. /**
  4443. * Get the Vector3 animation type
  4444. */
  4445. static readonly ANIMATIONTYPE_VECTOR3: number;
  4446. /**
  4447. * Get the Vector2 animation type
  4448. */
  4449. static readonly ANIMATIONTYPE_VECTOR2: number;
  4450. /**
  4451. * Get the Size animation type
  4452. */
  4453. static readonly ANIMATIONTYPE_SIZE: number;
  4454. /**
  4455. * Get the Quaternion animation type
  4456. */
  4457. static readonly ANIMATIONTYPE_QUATERNION: number;
  4458. /**
  4459. * Get the Matrix animation type
  4460. */
  4461. static readonly ANIMATIONTYPE_MATRIX: number;
  4462. /**
  4463. * Get the Color3 animation type
  4464. */
  4465. static readonly ANIMATIONTYPE_COLOR3: number;
  4466. /**
  4467. * Get the Relative Loop Mode
  4468. */
  4469. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4470. /**
  4471. * Get the Cycle Loop Mode
  4472. */
  4473. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4474. /**
  4475. * Get the Constant Loop Mode
  4476. */
  4477. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4478. /** @hidden */
  4479. static _UniversalLerp(left: any, right: any, amount: number): any;
  4480. /**
  4481. * Parses an animation object and creates an animation
  4482. * @param parsedAnimation Parsed animation object
  4483. * @returns Animation object
  4484. */
  4485. static Parse(parsedAnimation: any): Animation;
  4486. /**
  4487. * Appends the serialized animations from the source animations
  4488. * @param source Source containing the animations
  4489. * @param destination Target to store the animations
  4490. */
  4491. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4492. }
  4493. }
  4494. declare module BABYLON {
  4495. /**
  4496. * This class defines the direct association between an animation and a target
  4497. */
  4498. class TargetedAnimation {
  4499. /**
  4500. * Animation to perform
  4501. */
  4502. animation: Animation;
  4503. /**
  4504. * Target to animate
  4505. */
  4506. target: any;
  4507. }
  4508. /**
  4509. * Use this class to create coordinated animations on multiple targets
  4510. */
  4511. class AnimationGroup implements IDisposable {
  4512. /** The name of the animation group */
  4513. name: string;
  4514. private _scene;
  4515. private _targetedAnimations;
  4516. private _animatables;
  4517. private _from;
  4518. private _to;
  4519. private _isStarted;
  4520. private _speedRatio;
  4521. /**
  4522. * This observable will notify when one animation have ended.
  4523. */
  4524. onAnimationEndObservable: Observable<TargetedAnimation>;
  4525. /**
  4526. * This observable will notify when all animations have ended.
  4527. */
  4528. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4529. /**
  4530. * This observable will notify when all animations have paused.
  4531. */
  4532. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4533. /**
  4534. * Gets the first frame
  4535. */
  4536. readonly from: number;
  4537. /**
  4538. * Gets the last frame
  4539. */
  4540. readonly to: number;
  4541. /**
  4542. * Define if the animations are started
  4543. */
  4544. readonly isStarted: boolean;
  4545. /**
  4546. * Gets or sets the speed ratio to use for all animations
  4547. */
  4548. /**
  4549. * Gets or sets the speed ratio to use for all animations
  4550. */
  4551. speedRatio: number;
  4552. /**
  4553. * Gets the targeted animations for this animation group
  4554. */
  4555. readonly targetedAnimations: Array<TargetedAnimation>;
  4556. /**
  4557. * returning the list of animatables controlled by this animation group.
  4558. */
  4559. readonly animatables: Array<Animatable>;
  4560. /**
  4561. * Instantiates a new Animation Group.
  4562. * This helps managing several animations at once.
  4563. * @see http://doc.babylonjs.com/how_to/group
  4564. * @param name Defines the name of the group
  4565. * @param scene Defines the scene the group belongs to
  4566. */
  4567. constructor(
  4568. /** The name of the animation group */
  4569. name: string, scene?: Nullable<Scene>);
  4570. /**
  4571. * Add an animation (with its target) in the group
  4572. * @param animation defines the animation we want to add
  4573. * @param target defines the target of the animation
  4574. * @returns the TargetedAnimation object
  4575. */
  4576. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4577. /**
  4578. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4579. * It can add constant keys at begin or end
  4580. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4581. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4582. * @returns the animation group
  4583. */
  4584. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4585. /**
  4586. * Start all animations on given targets
  4587. * @param loop defines if animations must loop
  4588. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4589. * @param from defines the from key (optional)
  4590. * @param to defines the to key (optional)
  4591. * @returns the current animation group
  4592. */
  4593. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4594. /**
  4595. * Pause all animations
  4596. * @returns the animation group
  4597. */
  4598. pause(): AnimationGroup;
  4599. /**
  4600. * Play all animations to initial state
  4601. * This function will start() the animations if they were not started or will restart() them if they were paused
  4602. * @param loop defines if animations must loop
  4603. * @returns the animation group
  4604. */
  4605. play(loop?: boolean): AnimationGroup;
  4606. /**
  4607. * Reset all animations to initial state
  4608. * @returns the animation group
  4609. */
  4610. reset(): AnimationGroup;
  4611. /**
  4612. * Restart animations from key 0
  4613. * @returns the animation group
  4614. */
  4615. restart(): AnimationGroup;
  4616. /**
  4617. * Stop all animations
  4618. * @returns the animation group
  4619. */
  4620. stop(): AnimationGroup;
  4621. /**
  4622. * Set animation weight for all animatables
  4623. * @param weight defines the weight to use
  4624. * @return the animationGroup
  4625. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4626. */
  4627. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4628. /**
  4629. * Synchronize and normalize all animatables with a source animatable
  4630. * @param root defines the root animatable to synchronize with
  4631. * @return the animationGroup
  4632. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4633. */
  4634. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4635. /**
  4636. * Goes to a specific frame in this animation group
  4637. * @param frame the frame number to go to
  4638. * @return the animationGroup
  4639. */
  4640. goToFrame(frame: number): AnimationGroup;
  4641. /**
  4642. * Dispose all associated resources
  4643. */
  4644. dispose(): void;
  4645. private _checkAnimationGroupEnded;
  4646. /**
  4647. * Returns a new AnimationGroup object parsed from the source provided.
  4648. * @param parsedAnimationGroup defines the source
  4649. * @param scene defines the scene that will receive the animationGroup
  4650. * @returns a new AnimationGroup
  4651. */
  4652. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4653. /**
  4654. * Returns the string "AnimationGroup"
  4655. * @returns "AnimationGroup"
  4656. */
  4657. getClassName(): string;
  4658. /**
  4659. * Creates a detailled string about the object
  4660. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4661. * @returns a string representing the object
  4662. */
  4663. toString(fullDetails?: boolean): string;
  4664. }
  4665. }
  4666. declare module BABYLON {
  4667. /**
  4668. * Class used to override all child animations of a given target
  4669. */
  4670. class AnimationPropertiesOverride {
  4671. /**
  4672. * Gets or sets a value indicating if animation blending must be used
  4673. */
  4674. enableBlending: boolean;
  4675. /**
  4676. * Gets or sets the blending speed to use when enableBlending is true
  4677. */
  4678. blendingSpeed: number;
  4679. /**
  4680. * Gets or sets the default loop mode to use
  4681. */
  4682. loopMode: number;
  4683. }
  4684. }
  4685. declare module BABYLON {
  4686. /**
  4687. * This represents the main contract an easing function should follow.
  4688. * Easing functions are used throughout the animation system.
  4689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4690. */
  4691. interface IEasingFunction {
  4692. /**
  4693. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4694. * of the easing function.
  4695. * The link below provides some of the most common examples of easing functions.
  4696. * @see https://easings.net/
  4697. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4698. * @returns the corresponding value on the curve defined by the easing function
  4699. */
  4700. ease(gradient: number): number;
  4701. }
  4702. /**
  4703. * Base class used for every default easing function.
  4704. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4705. */
  4706. class EasingFunction implements IEasingFunction {
  4707. /**
  4708. * Interpolation follows the mathematical formula associated with the easing function.
  4709. */
  4710. static readonly EASINGMODE_EASEIN: number;
  4711. /**
  4712. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4713. */
  4714. static readonly EASINGMODE_EASEOUT: number;
  4715. /**
  4716. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4717. */
  4718. static readonly EASINGMODE_EASEINOUT: number;
  4719. private _easingMode;
  4720. /**
  4721. * Sets the easing mode of the current function.
  4722. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4723. */
  4724. setEasingMode(easingMode: number): void;
  4725. /**
  4726. * Gets the current easing mode.
  4727. * @returns the easing mode
  4728. */
  4729. getEasingMode(): number;
  4730. /**
  4731. * @hidden
  4732. */
  4733. easeInCore(gradient: number): number;
  4734. /**
  4735. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4736. * of the easing function.
  4737. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4738. * @returns the corresponding value on the curve defined by the easing function
  4739. */
  4740. ease(gradient: number): number;
  4741. }
  4742. /**
  4743. * Easing function with a circle shape (see link below).
  4744. * @see https://easings.net/#easeInCirc
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. class CircleEase extends EasingFunction implements IEasingFunction {
  4748. /** @hidden */
  4749. easeInCore(gradient: number): number;
  4750. }
  4751. /**
  4752. * Easing function with a ease back shape (see link below).
  4753. * @see https://easings.net/#easeInBack
  4754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4755. */
  4756. class BackEase extends EasingFunction implements IEasingFunction {
  4757. /** Defines the amplitude of the function */
  4758. amplitude: number;
  4759. /**
  4760. * Instantiates a back ease easing
  4761. * @see https://easings.net/#easeInBack
  4762. * @param amplitude Defines the amplitude of the function
  4763. */
  4764. constructor(
  4765. /** Defines the amplitude of the function */
  4766. amplitude?: number);
  4767. /** @hidden */
  4768. easeInCore(gradient: number): number;
  4769. }
  4770. /**
  4771. * Easing function with a bouncing shape (see link below).
  4772. * @see https://easings.net/#easeInBounce
  4773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4774. */
  4775. class BounceEase extends EasingFunction implements IEasingFunction {
  4776. /** Defines the number of bounces */
  4777. bounces: number;
  4778. /** Defines the amplitude of the bounce */
  4779. bounciness: number;
  4780. /**
  4781. * Instantiates a bounce easing
  4782. * @see https://easings.net/#easeInBounce
  4783. * @param bounces Defines the number of bounces
  4784. * @param bounciness Defines the amplitude of the bounce
  4785. */
  4786. constructor(
  4787. /** Defines the number of bounces */
  4788. bounces?: number,
  4789. /** Defines the amplitude of the bounce */
  4790. bounciness?: number);
  4791. /** @hidden */
  4792. easeInCore(gradient: number): number;
  4793. }
  4794. /**
  4795. * Easing function with a power of 3 shape (see link below).
  4796. * @see https://easings.net/#easeInCubic
  4797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4798. */
  4799. class CubicEase extends EasingFunction implements IEasingFunction {
  4800. /** @hidden */
  4801. easeInCore(gradient: number): number;
  4802. }
  4803. /**
  4804. * Easing function with an elastic shape (see link below).
  4805. * @see https://easings.net/#easeInElastic
  4806. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4807. */
  4808. class ElasticEase extends EasingFunction implements IEasingFunction {
  4809. /** Defines the number of oscillations*/
  4810. oscillations: number;
  4811. /** Defines the amplitude of the oscillations*/
  4812. springiness: number;
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. constructor(
  4820. /** Defines the number of oscillations*/
  4821. oscillations?: number,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness?: number);
  4824. /** @hidden */
  4825. easeInCore(gradient: number): number;
  4826. }
  4827. /**
  4828. * Easing function with an exponential shape (see link below).
  4829. * @see https://easings.net/#easeInExpo
  4830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4831. */
  4832. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4833. /** Defines the exponent of the function */
  4834. exponent: number;
  4835. /**
  4836. * Instantiates an exponential easing function
  4837. * @see https://easings.net/#easeInExpo
  4838. * @param exponent Defines the exponent of the function
  4839. */
  4840. constructor(
  4841. /** Defines the exponent of the function */
  4842. exponent?: number);
  4843. /** @hidden */
  4844. easeInCore(gradient: number): number;
  4845. }
  4846. /**
  4847. * Easing function with a power shape (see link below).
  4848. * @see https://easings.net/#easeInQuad
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. class PowerEase extends EasingFunction implements IEasingFunction {
  4852. /** Defines the power of the function */
  4853. power: number;
  4854. /**
  4855. * Instantiates an power base easing function
  4856. * @see https://easings.net/#easeInQuad
  4857. * @param power Defines the power of the function
  4858. */
  4859. constructor(
  4860. /** Defines the power of the function */
  4861. power?: number);
  4862. /** @hidden */
  4863. easeInCore(gradient: number): number;
  4864. }
  4865. /**
  4866. * Easing function with a power of 2 shape (see link below).
  4867. * @see https://easings.net/#easeInQuad
  4868. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4869. */
  4870. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4871. /** @hidden */
  4872. easeInCore(gradient: number): number;
  4873. }
  4874. /**
  4875. * Easing function with a power of 4 shape (see link below).
  4876. * @see https://easings.net/#easeInQuart
  4877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4878. */
  4879. class QuarticEase extends EasingFunction implements IEasingFunction {
  4880. /** @hidden */
  4881. easeInCore(gradient: number): number;
  4882. }
  4883. /**
  4884. * Easing function with a power of 5 shape (see link below).
  4885. * @see https://easings.net/#easeInQuint
  4886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4887. */
  4888. class QuinticEase extends EasingFunction implements IEasingFunction {
  4889. /** @hidden */
  4890. easeInCore(gradient: number): number;
  4891. }
  4892. /**
  4893. * Easing function with a sin shape (see link below).
  4894. * @see https://easings.net/#easeInSine
  4895. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4896. */
  4897. class SineEase extends EasingFunction implements IEasingFunction {
  4898. /** @hidden */
  4899. easeInCore(gradient: number): number;
  4900. }
  4901. /**
  4902. * Easing function with a bezier shape (see link below).
  4903. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4904. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4905. */
  4906. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4907. /** Defines the x component of the start tangent in the bezier curve */
  4908. x1: number;
  4909. /** Defines the y component of the start tangent in the bezier curve */
  4910. y1: number;
  4911. /** Defines the x component of the end tangent in the bezier curve */
  4912. x2: number;
  4913. /** Defines the y component of the end tangent in the bezier curve */
  4914. y2: number;
  4915. /**
  4916. * Instantiates a bezier function
  4917. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4918. * @param x1 Defines the x component of the start tangent in the bezier curve
  4919. * @param y1 Defines the y component of the start tangent in the bezier curve
  4920. * @param x2 Defines the x component of the end tangent in the bezier curve
  4921. * @param y2 Defines the y component of the end tangent in the bezier curve
  4922. */
  4923. constructor(
  4924. /** Defines the x component of the start tangent in the bezier curve */
  4925. x1?: number,
  4926. /** Defines the y component of the start tangent in the bezier curve */
  4927. y1?: number,
  4928. /** Defines the x component of the end tangent in the bezier curve */
  4929. x2?: number,
  4930. /** Defines the y component of the end tangent in the bezier curve */
  4931. y2?: number);
  4932. /** @hidden */
  4933. easeInCore(gradient: number): number;
  4934. }
  4935. }
  4936. declare module BABYLON {
  4937. /**
  4938. * Defines a runtime animation
  4939. */
  4940. class RuntimeAnimation {
  4941. private _events;
  4942. /**
  4943. * The current frame of the runtime animation
  4944. */
  4945. private _currentFrame;
  4946. /**
  4947. * The animation used by the runtime animation
  4948. */
  4949. private _animation;
  4950. /**
  4951. * The target of the runtime animation
  4952. */
  4953. private _target;
  4954. /**
  4955. * The initiating animatable
  4956. */
  4957. private _host;
  4958. /**
  4959. * The original value of the runtime animation
  4960. */
  4961. private _originalValue;
  4962. /**
  4963. * The original blend value of the runtime animation
  4964. */
  4965. private _originalBlendValue;
  4966. /**
  4967. * The offsets cache of the runtime animation
  4968. */
  4969. private _offsetsCache;
  4970. /**
  4971. * The high limits cache of the runtime animation
  4972. */
  4973. private _highLimitsCache;
  4974. /**
  4975. * Specifies if the runtime animation has been stopped
  4976. */
  4977. private _stopped;
  4978. /**
  4979. * The blending factor of the runtime animation
  4980. */
  4981. private _blendingFactor;
  4982. /**
  4983. * The BabylonJS scene
  4984. */
  4985. private _scene;
  4986. /**
  4987. * The current value of the runtime animation
  4988. */
  4989. private _currentValue;
  4990. /** @hidden */
  4991. _workValue: any;
  4992. /**
  4993. * The active target of the runtime animation
  4994. */
  4995. private _activeTarget;
  4996. /**
  4997. * The target path of the runtime animation
  4998. */
  4999. private _targetPath;
  5000. /**
  5001. * The weight of the runtime animation
  5002. */
  5003. private _weight;
  5004. /**
  5005. * The ratio offset of the runtime animation
  5006. */
  5007. private _ratioOffset;
  5008. /**
  5009. * The previous delay of the runtime animation
  5010. */
  5011. private _previousDelay;
  5012. /**
  5013. * The previous ratio of the runtime animation
  5014. */
  5015. private _previousRatio;
  5016. /**
  5017. * Gets the current frame of the runtime animation
  5018. */
  5019. readonly currentFrame: number;
  5020. /**
  5021. * Gets the weight of the runtime animation
  5022. */
  5023. readonly weight: number;
  5024. /**
  5025. * Gets the current value of the runtime animation
  5026. */
  5027. readonly currentValue: any;
  5028. /**
  5029. * Gets the target path of the runtime animation
  5030. */
  5031. readonly targetPath: string;
  5032. /**
  5033. * Gets the actual target of the runtime animation
  5034. */
  5035. readonly target: any;
  5036. /**
  5037. * Create a new RuntimeAnimation object
  5038. * @param target defines the target of the animation
  5039. * @param animation defines the source animation object
  5040. * @param scene defines the hosting scene
  5041. * @param host defines the initiating Animatable
  5042. */
  5043. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5044. /**
  5045. * Gets the animation from the runtime animation
  5046. */
  5047. readonly animation: Animation;
  5048. /**
  5049. * Resets the runtime animation to the beginning
  5050. * @param restoreOriginal defines whether to restore the target property to the original value
  5051. */
  5052. reset(restoreOriginal?: boolean): void;
  5053. /**
  5054. * Specifies if the runtime animation is stopped
  5055. * @returns Boolean specifying if the runtime animation is stopped
  5056. */
  5057. isStopped(): boolean;
  5058. /**
  5059. * Disposes of the runtime animation
  5060. */
  5061. dispose(): void;
  5062. /**
  5063. * Interpolates the animation from the current frame
  5064. * @param currentFrame The frame to interpolate the animation to
  5065. * @param repeatCount The number of times that the animation should loop
  5066. * @param loopMode The type of looping mode to use
  5067. * @param offsetValue Animation offset value
  5068. * @param highLimitValue The high limit value
  5069. * @returns The interpolated value
  5070. */
  5071. private _interpolate;
  5072. /**
  5073. * Apply the interpolated value to the target
  5074. * @param currentValue defines the value computed by the animation
  5075. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5076. */
  5077. setValue(currentValue: any, weight?: number): void;
  5078. private _setValue;
  5079. /**
  5080. * Gets the loop pmode of the runtime animation
  5081. * @returns Loop Mode
  5082. */
  5083. private _getCorrectLoopMode;
  5084. /**
  5085. * Move the current animation to a given frame
  5086. * @param frame defines the frame to move to
  5087. */
  5088. goToFrame(frame: number): void;
  5089. /**
  5090. * @hidden Internal use only
  5091. */
  5092. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5093. /**
  5094. * Execute the current animation
  5095. * @param delay defines the delay to add to the current frame
  5096. * @param from defines the lower bound of the animation range
  5097. * @param to defines the upper bound of the animation range
  5098. * @param loop defines if the current animation must loop
  5099. * @param speedRatio defines the current speed ratio
  5100. * @param weight defines the weight of the animation (default is -1 so no weight)
  5101. * @returns a boolean indicating if the animation is running
  5102. */
  5103. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5104. }
  5105. }
  5106. declare module BABYLON {
  5107. /**
  5108. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5110. */
  5111. class Analyser {
  5112. /**
  5113. * Gets or sets the smoothing
  5114. * @ignorenaming
  5115. */
  5116. SMOOTHING: number;
  5117. /**
  5118. * Gets or sets the FFT table size
  5119. * @ignorenaming
  5120. */
  5121. FFT_SIZE: number;
  5122. /**
  5123. * Gets or sets the bar graph amplitude
  5124. * @ignorenaming
  5125. */
  5126. BARGRAPHAMPLITUDE: number;
  5127. /**
  5128. * Gets or sets the position of the debug canvas
  5129. * @ignorenaming
  5130. */
  5131. DEBUGCANVASPOS: {
  5132. x: number;
  5133. y: number;
  5134. };
  5135. /**
  5136. * Gets or sets the debug canvas size
  5137. * @ignorenaming
  5138. */
  5139. DEBUGCANVASSIZE: {
  5140. width: number;
  5141. height: number;
  5142. };
  5143. private _byteFreqs;
  5144. private _byteTime;
  5145. private _floatFreqs;
  5146. private _webAudioAnalyser;
  5147. private _debugCanvas;
  5148. private _debugCanvasContext;
  5149. private _scene;
  5150. private _registerFunc;
  5151. private _audioEngine;
  5152. /**
  5153. * Creates a new analyser
  5154. * @param scene defines hosting scene
  5155. */
  5156. constructor(scene: Scene);
  5157. /**
  5158. * Get the number of data values you will have to play with for the visualization
  5159. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5160. * @returns a number
  5161. */
  5162. getFrequencyBinCount(): number;
  5163. /**
  5164. * Gets the current frequency data as a byte array
  5165. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5166. * @returns a Uint8Array
  5167. */
  5168. getByteFrequencyData(): Uint8Array;
  5169. /**
  5170. * Gets the current waveform as a byte array
  5171. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5172. * @returns a Uint8Array
  5173. */
  5174. getByteTimeDomainData(): Uint8Array;
  5175. /**
  5176. * Gets the current frequency data as a float array
  5177. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5178. * @returns a Float32Array
  5179. */
  5180. getFloatFrequencyData(): Float32Array;
  5181. /**
  5182. * Renders the debug canvas
  5183. */
  5184. drawDebugCanvas(): void;
  5185. /**
  5186. * Stops rendering the debug canvas and removes it
  5187. */
  5188. stopDebugCanvas(): void;
  5189. /**
  5190. * Connects two audio nodes
  5191. * @param inputAudioNode defines first node to connect
  5192. * @param outputAudioNode defines second node to connect
  5193. */
  5194. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5195. /**
  5196. * Releases all associated resources
  5197. */
  5198. dispose(): void;
  5199. }
  5200. }
  5201. declare module BABYLON {
  5202. /**
  5203. * This represents an audio engine and it is responsible
  5204. * to play, synchronize and analyse sounds throughout the application.
  5205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5206. */
  5207. interface IAudioEngine extends IDisposable {
  5208. /**
  5209. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5210. */
  5211. readonly canUseWebAudio: boolean;
  5212. /**
  5213. * Gets the current AudioContext if available.
  5214. */
  5215. readonly audioContext: Nullable<AudioContext>;
  5216. /**
  5217. * The master gain node defines the global audio volume of your audio engine.
  5218. */
  5219. readonly masterGain: GainNode;
  5220. /**
  5221. * Gets whether or not mp3 are supported by your browser.
  5222. */
  5223. readonly isMP3supported: boolean;
  5224. /**
  5225. * Gets whether or not ogg are supported by your browser.
  5226. */
  5227. readonly isOGGsupported: boolean;
  5228. /**
  5229. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5230. * @ignoreNaming
  5231. */
  5232. WarnedWebAudioUnsupported: boolean;
  5233. /**
  5234. * Defines if the audio engine relies on a custom unlocked button.
  5235. * In this case, the embedded button will not be displayed.
  5236. */
  5237. useCustomUnlockedButton: boolean;
  5238. /**
  5239. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5240. */
  5241. readonly unlocked: boolean;
  5242. /**
  5243. * Event raised when audio has been unlocked on the browser.
  5244. */
  5245. onAudioUnlockedObservable: Observable<AudioEngine>;
  5246. /**
  5247. * Event raised when audio has been locked on the browser.
  5248. */
  5249. onAudioLockedObservable: Observable<AudioEngine>;
  5250. /**
  5251. * Flags the audio engine in Locked state.
  5252. * This happens due to new browser policies preventing audio to autoplay.
  5253. */
  5254. lock(): void;
  5255. /**
  5256. * Unlocks the audio engine once a user action has been done on the dom.
  5257. * This is helpful to resume play once browser policies have been satisfied.
  5258. */
  5259. unlock(): void;
  5260. }
  5261. /**
  5262. * This represents the default audio engine used in babylon.
  5263. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5265. */
  5266. class AudioEngine implements IAudioEngine {
  5267. private _audioContext;
  5268. private _audioContextInitialized;
  5269. private _muteButton;
  5270. private _hostElement;
  5271. /**
  5272. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5273. */
  5274. canUseWebAudio: boolean;
  5275. /**
  5276. * The master gain node defines the global audio volume of your audio engine.
  5277. */
  5278. masterGain: GainNode;
  5279. /**
  5280. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5281. * @ignoreNaming
  5282. */
  5283. WarnedWebAudioUnsupported: boolean;
  5284. /**
  5285. * Gets whether or not mp3 are supported by your browser.
  5286. */
  5287. isMP3supported: boolean;
  5288. /**
  5289. * Gets whether or not ogg are supported by your browser.
  5290. */
  5291. isOGGsupported: boolean;
  5292. /**
  5293. * Gets whether audio has been unlocked on the device.
  5294. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5295. * a user interaction has happened.
  5296. */
  5297. unlocked: boolean;
  5298. /**
  5299. * Defines if the audio engine relies on a custom unlocked button.
  5300. * In this case, the embedded button will not be displayed.
  5301. */
  5302. useCustomUnlockedButton: boolean;
  5303. /**
  5304. * Event raised when audio has been unlocked on the browser.
  5305. */
  5306. onAudioUnlockedObservable: Observable<AudioEngine>;
  5307. /**
  5308. * Event raised when audio has been locked on the browser.
  5309. */
  5310. onAudioLockedObservable: Observable<AudioEngine>;
  5311. /**
  5312. * Gets the current AudioContext if available.
  5313. */
  5314. readonly audioContext: Nullable<AudioContext>;
  5315. private _connectedAnalyser;
  5316. /**
  5317. * Instantiates a new audio engine.
  5318. *
  5319. * There should be only one per page as some browsers restrict the number
  5320. * of audio contexts you can create.
  5321. * @param hostElement defines the host element where to display the mute icon if necessary
  5322. */
  5323. constructor(hostElement?: Nullable<HTMLElement>);
  5324. /**
  5325. * Flags the audio engine in Locked state.
  5326. * This happens due to new browser policies preventing audio to autoplay.
  5327. */
  5328. lock(): void;
  5329. /**
  5330. * Unlocks the audio engine once a user action has been done on the dom.
  5331. * This is helpful to resume play once browser policies have been satisfied.
  5332. */
  5333. unlock(): void;
  5334. private _resumeAudioContext;
  5335. private _initializeAudioContext;
  5336. private _tryToRun;
  5337. private _triggerRunningState;
  5338. private _triggerSuspendedState;
  5339. private _displayMuteButton;
  5340. private _moveButtonToTopLeft;
  5341. private _onResize;
  5342. private _hideMuteButton;
  5343. /**
  5344. * Destroy and release the resources associated with the audio ccontext.
  5345. */
  5346. dispose(): void;
  5347. /**
  5348. * Gets the global volume sets on the master gain.
  5349. * @returns the global volume if set or -1 otherwise
  5350. */
  5351. getGlobalVolume(): number;
  5352. /**
  5353. * Sets the global volume of your experience (sets on the master gain).
  5354. * @param newVolume Defines the new global volume of the application
  5355. */
  5356. setGlobalVolume(newVolume: number): void;
  5357. /**
  5358. * Connect the audio engine to an audio analyser allowing some amazing
  5359. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5361. * @param analyser The analyser to connect to the engine
  5362. */
  5363. connectToAnalyser(analyser: Analyser): void;
  5364. }
  5365. }
  5366. declare module BABYLON {
  5367. interface AbstractScene {
  5368. /**
  5369. * The list of sounds used in the scene.
  5370. */
  5371. sounds: Nullable<Array<Sound>>;
  5372. }
  5373. interface Scene {
  5374. /**
  5375. * @hidden
  5376. * Backing field
  5377. */
  5378. _mainSoundTrack: SoundTrack;
  5379. /**
  5380. * The main sound track played by the scene.
  5381. * It cotains your primary collection of sounds.
  5382. */
  5383. mainSoundTrack: SoundTrack;
  5384. /**
  5385. * The list of sound tracks added to the scene
  5386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5387. */
  5388. soundTracks: Nullable<Array<SoundTrack>>;
  5389. /**
  5390. * Gets a sound using a given name
  5391. * @param name defines the name to search for
  5392. * @return the found sound or null if not found at all.
  5393. */
  5394. getSoundByName(name: string): Nullable<Sound>;
  5395. /**
  5396. * Gets or sets if audio support is enabled
  5397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5398. */
  5399. audioEnabled: boolean;
  5400. /**
  5401. * Gets or sets if audio will be output to headphones
  5402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5403. */
  5404. headphone: boolean;
  5405. }
  5406. /**
  5407. * Defines the sound scene component responsible to manage any sounds
  5408. * in a given scene.
  5409. */
  5410. class AudioSceneComponent implements ISceneSerializableComponent {
  5411. /**
  5412. * The component name helpfull to identify the component in the list of scene components.
  5413. */
  5414. readonly name: string;
  5415. /**
  5416. * The scene the component belongs to.
  5417. */
  5418. scene: Scene;
  5419. private _audioEnabled;
  5420. /**
  5421. * Gets whether audio is enabled or not.
  5422. * Please use related enable/disable method to switch state.
  5423. */
  5424. readonly audioEnabled: boolean;
  5425. private _headphone;
  5426. /**
  5427. * Gets whether audio is outputing to headphone or not.
  5428. * Please use the according Switch methods to change output.
  5429. */
  5430. readonly headphone: boolean;
  5431. /**
  5432. * Creates a new instance of the component for the given scene
  5433. * @param scene Defines the scene to register the component in
  5434. */
  5435. constructor(scene: Scene);
  5436. /**
  5437. * Registers the component in a given scene
  5438. */
  5439. register(): void;
  5440. /**
  5441. * Rebuilds the elements related to this component in case of
  5442. * context lost for instance.
  5443. */
  5444. rebuild(): void;
  5445. /**
  5446. * Serializes the component data to the specified json object
  5447. * @param serializationObject The object to serialize to
  5448. */
  5449. serialize(serializationObject: any): void;
  5450. /**
  5451. * Adds all the element from the container to the scene
  5452. * @param container the container holding the elements
  5453. */
  5454. addFromContainer(container: AbstractScene): void;
  5455. /**
  5456. * Removes all the elements in the container from the scene
  5457. * @param container contains the elements to remove
  5458. */
  5459. removeFromContainer(container: AbstractScene): void;
  5460. /**
  5461. * Disposes the component and the associated ressources.
  5462. */
  5463. dispose(): void;
  5464. /**
  5465. * Disables audio in the associated scene.
  5466. */
  5467. disableAudio(): void;
  5468. /**
  5469. * Enables audio in the associated scene.
  5470. */
  5471. enableAudio(): void;
  5472. /**
  5473. * Switch audio to headphone output.
  5474. */
  5475. switchAudioModeForHeadphones(): void;
  5476. /**
  5477. * Switch audio to normal speakers.
  5478. */
  5479. switchAudioModeForNormalSpeakers(): void;
  5480. private _afterRender;
  5481. }
  5482. }
  5483. declare module BABYLON {
  5484. /**
  5485. * Defines a sound that can be played in the application.
  5486. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5488. */
  5489. class Sound {
  5490. /**
  5491. * The name of the sound in the scene.
  5492. */
  5493. name: string;
  5494. /**
  5495. * Does the sound autoplay once loaded.
  5496. */
  5497. autoplay: boolean;
  5498. /**
  5499. * Does the sound loop after it finishes playing once.
  5500. */
  5501. loop: boolean;
  5502. /**
  5503. * Does the sound use a custom attenuation curve to simulate the falloff
  5504. * happening when the source gets further away from the camera.
  5505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5506. */
  5507. useCustomAttenuation: boolean;
  5508. /**
  5509. * The sound track id this sound belongs to.
  5510. */
  5511. soundTrackId: number;
  5512. /**
  5513. * Is this sound currently played.
  5514. */
  5515. isPlaying: boolean;
  5516. /**
  5517. * Is this sound currently paused.
  5518. */
  5519. isPaused: boolean;
  5520. /**
  5521. * Does this sound enables spatial sound.
  5522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5523. */
  5524. spatialSound: boolean;
  5525. /**
  5526. * Define the reference distance the sound should be heard perfectly.
  5527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5528. */
  5529. refDistance: number;
  5530. /**
  5531. * Define the roll off factor of spatial sounds.
  5532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5533. */
  5534. rolloffFactor: number;
  5535. /**
  5536. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5538. */
  5539. maxDistance: number;
  5540. /**
  5541. * Define the distance attenuation model the sound will follow.
  5542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5543. */
  5544. distanceModel: string;
  5545. /**
  5546. * @hidden
  5547. * Back Compat
  5548. **/
  5549. onended: () => any;
  5550. /**
  5551. * Observable event when the current playing sound finishes.
  5552. */
  5553. onEndedObservable: Observable<Sound>;
  5554. private _panningModel;
  5555. private _playbackRate;
  5556. private _streaming;
  5557. private _startTime;
  5558. private _startOffset;
  5559. private _position;
  5560. /** @hidden */
  5561. _positionInEmitterSpace: boolean;
  5562. private _localDirection;
  5563. private _volume;
  5564. private _isReadyToPlay;
  5565. private _isDirectional;
  5566. private _readyToPlayCallback;
  5567. private _audioBuffer;
  5568. private _soundSource;
  5569. private _streamingSource;
  5570. private _soundPanner;
  5571. private _soundGain;
  5572. private _inputAudioNode;
  5573. private _outputAudioNode;
  5574. private _coneInnerAngle;
  5575. private _coneOuterAngle;
  5576. private _coneOuterGain;
  5577. private _scene;
  5578. private _connectedTransformNode;
  5579. private _customAttenuationFunction;
  5580. private _registerFunc;
  5581. private _isOutputConnected;
  5582. private _htmlAudioElement;
  5583. private _urlType;
  5584. /**
  5585. * Create a sound and attach it to a scene
  5586. * @param name Name of your sound
  5587. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5588. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5589. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5590. */
  5591. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5592. /**
  5593. * Release the sound and its associated resources
  5594. */
  5595. dispose(): void;
  5596. /**
  5597. * Gets if the sounds is ready to be played or not.
  5598. * @returns true if ready, otherwise false
  5599. */
  5600. isReady(): boolean;
  5601. private _soundLoaded;
  5602. /**
  5603. * Sets the data of the sound from an audiobuffer
  5604. * @param audioBuffer The audioBuffer containing the data
  5605. */
  5606. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5607. /**
  5608. * Updates the current sounds options such as maxdistance, loop...
  5609. * @param options A JSON object containing values named as the object properties
  5610. */
  5611. updateOptions(options: any): void;
  5612. private _createSpatialParameters;
  5613. private _updateSpatialParameters;
  5614. /**
  5615. * Switch the panning model to HRTF:
  5616. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5618. */
  5619. switchPanningModelToHRTF(): void;
  5620. /**
  5621. * Switch the panning model to Equal Power:
  5622. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5624. */
  5625. switchPanningModelToEqualPower(): void;
  5626. private _switchPanningModel;
  5627. /**
  5628. * Connect this sound to a sound track audio node like gain...
  5629. * @param soundTrackAudioNode the sound track audio node to connect to
  5630. */
  5631. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5632. /**
  5633. * Transform this sound into a directional source
  5634. * @param coneInnerAngle Size of the inner cone in degree
  5635. * @param coneOuterAngle Size of the outer cone in degree
  5636. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5637. */
  5638. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5639. /**
  5640. * Gets or sets the inner angle for the directional cone.
  5641. */
  5642. /**
  5643. * Gets or sets the inner angle for the directional cone.
  5644. */
  5645. directionalConeInnerAngle: number;
  5646. /**
  5647. * Gets or sets the outer angle for the directional cone.
  5648. */
  5649. /**
  5650. * Gets or sets the outer angle for the directional cone.
  5651. */
  5652. directionalConeOuterAngle: number;
  5653. /**
  5654. * Sets the position of the emitter if spatial sound is enabled
  5655. * @param newPosition Defines the new posisiton
  5656. */
  5657. setPosition(newPosition: Vector3): void;
  5658. /**
  5659. * Sets the local direction of the emitter if spatial sound is enabled
  5660. * @param newLocalDirection Defines the new local direction
  5661. */
  5662. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5663. private _updateDirection;
  5664. /** @hidden */
  5665. updateDistanceFromListener(): void;
  5666. /**
  5667. * Sets a new custom attenuation function for the sound.
  5668. * @param callback Defines the function used for the attenuation
  5669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5670. */
  5671. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5672. /**
  5673. * Play the sound
  5674. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5675. * @param offset (optional) Start the sound setting it at a specific time
  5676. */
  5677. play(time?: number, offset?: number): void;
  5678. private _onended;
  5679. /**
  5680. * Stop the sound
  5681. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5682. */
  5683. stop(time?: number): void;
  5684. /**
  5685. * Put the sound in pause
  5686. */
  5687. pause(): void;
  5688. /**
  5689. * Sets a dedicated volume for this sounds
  5690. * @param newVolume Define the new volume of the sound
  5691. * @param time Define in how long the sound should be at this value
  5692. */
  5693. setVolume(newVolume: number, time?: number): void;
  5694. /**
  5695. * Set the sound play back rate
  5696. * @param newPlaybackRate Define the playback rate the sound should be played at
  5697. */
  5698. setPlaybackRate(newPlaybackRate: number): void;
  5699. /**
  5700. * Gets the volume of the sound.
  5701. * @returns the volume of the sound
  5702. */
  5703. getVolume(): number;
  5704. /**
  5705. * Attach the sound to a dedicated mesh
  5706. * @param transformNode The transform node to connect the sound with
  5707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5708. */
  5709. attachToMesh(transformNode: TransformNode): void;
  5710. /**
  5711. * Detach the sound from the previously attached mesh
  5712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5713. */
  5714. detachFromMesh(): void;
  5715. private _onRegisterAfterWorldMatrixUpdate;
  5716. /**
  5717. * Clone the current sound in the scene.
  5718. * @returns the new sound clone
  5719. */
  5720. clone(): Nullable<Sound>;
  5721. /**
  5722. * Gets the current underlying audio buffer containing the data
  5723. * @returns the audio buffer
  5724. */
  5725. getAudioBuffer(): Nullable<AudioBuffer>;
  5726. /**
  5727. * Serializes the Sound in a JSON representation
  5728. * @returns the JSON representation of the sound
  5729. */
  5730. serialize(): any;
  5731. /**
  5732. * Parse a JSON representation of a sound to innstantiate in a given scene
  5733. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5734. * @param scene Define the scene the new parsed sound should be created in
  5735. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5736. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5737. * @returns the newly parsed sound
  5738. */
  5739. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5740. }
  5741. }
  5742. declare module BABYLON {
  5743. /**
  5744. * Options allowed during the creation of a sound track.
  5745. */
  5746. interface ISoundTrackOptions {
  5747. /**
  5748. * The volume the sound track should take during creation
  5749. */
  5750. volume?: number;
  5751. /**
  5752. * Define if the sound track is the main sound track of the scene
  5753. */
  5754. mainTrack?: boolean;
  5755. }
  5756. /**
  5757. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5758. * It will be also used in a future release to apply effects on a specific track.
  5759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5760. */
  5761. class SoundTrack {
  5762. /**
  5763. * The unique identifier of the sound track in the scene.
  5764. */
  5765. id: number;
  5766. /**
  5767. * The list of sounds included in the sound track.
  5768. */
  5769. soundCollection: Array<Sound>;
  5770. private _outputAudioNode;
  5771. private _scene;
  5772. private _isMainTrack;
  5773. private _connectedAnalyser;
  5774. private _options;
  5775. private _isInitialized;
  5776. /**
  5777. * Creates a new sound track.
  5778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5779. * @param scene Define the scene the sound track belongs to
  5780. * @param options
  5781. */
  5782. constructor(scene: Scene, options?: ISoundTrackOptions);
  5783. private _initializeSoundTrackAudioGraph;
  5784. /**
  5785. * Release the sound track and its associated resources
  5786. */
  5787. dispose(): void;
  5788. /**
  5789. * Adds a sound to this sound track
  5790. * @param sound define the cound to add
  5791. * @ignoreNaming
  5792. */
  5793. AddSound(sound: Sound): void;
  5794. /**
  5795. * Removes a sound to this sound track
  5796. * @param sound define the cound to remove
  5797. * @ignoreNaming
  5798. */
  5799. RemoveSound(sound: Sound): void;
  5800. /**
  5801. * Set a global volume for the full sound track.
  5802. * @param newVolume Define the new volume of the sound track
  5803. */
  5804. setVolume(newVolume: number): void;
  5805. /**
  5806. * Switch the panning model to HRTF:
  5807. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5809. */
  5810. switchPanningModelToHRTF(): void;
  5811. /**
  5812. * Switch the panning model to Equal Power:
  5813. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5815. */
  5816. switchPanningModelToEqualPower(): void;
  5817. /**
  5818. * Connect the sound track to an audio analyser allowing some amazing
  5819. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5821. * @param analyser The analyser to connect to the engine
  5822. */
  5823. connectToAnalyser(analyser: Analyser): void;
  5824. }
  5825. }
  5826. declare module BABYLON {
  5827. /**
  5828. * Wraps one or more Sound objects and selects one with random weight for playback.
  5829. */
  5830. class WeightedSound {
  5831. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5832. loop: boolean;
  5833. private _coneInnerAngle;
  5834. private _coneOuterAngle;
  5835. private _volume;
  5836. /** A Sound is currently playing. */
  5837. isPlaying: boolean;
  5838. /** A Sound is currently paused. */
  5839. isPaused: boolean;
  5840. private _sounds;
  5841. private _weights;
  5842. private _currentIndex?;
  5843. /**
  5844. * Creates a new WeightedSound from the list of sounds given.
  5845. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5846. * @param sounds Array of Sounds that will be selected from.
  5847. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5848. */
  5849. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5850. /**
  5851. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5852. */
  5853. /**
  5854. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5855. */
  5856. directionalConeInnerAngle: number;
  5857. /**
  5858. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5859. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5860. */
  5861. /**
  5862. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5863. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5864. */
  5865. directionalConeOuterAngle: number;
  5866. /**
  5867. * Playback volume.
  5868. */
  5869. /**
  5870. * Playback volume.
  5871. */
  5872. volume: number;
  5873. private _onended;
  5874. /**
  5875. * Suspend playback
  5876. */
  5877. pause(): void;
  5878. /**
  5879. * Stop playback
  5880. */
  5881. stop(): void;
  5882. /**
  5883. * Start playback.
  5884. * @param startOffset Position the clip head at a specific time in seconds.
  5885. */
  5886. play(startOffset?: number): void;
  5887. }
  5888. }
  5889. declare module BABYLON {
  5890. /**
  5891. * Interface used to define a behavior
  5892. */
  5893. interface Behavior<T> {
  5894. /** gets or sets behavior's name */
  5895. name: string;
  5896. /**
  5897. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5898. */
  5899. init(): void;
  5900. /**
  5901. * Called when the behavior is attached to a target
  5902. * @param target defines the target where the behavior is attached to
  5903. */
  5904. attach(target: T): void;
  5905. /**
  5906. * Called when the behavior is detached from its target
  5907. */
  5908. detach(): void;
  5909. }
  5910. /**
  5911. * Interface implemented by classes supporting behaviors
  5912. */
  5913. interface IBehaviorAware<T> {
  5914. /**
  5915. * Attach a behavior
  5916. * @param behavior defines the behavior to attach
  5917. * @returns the current host
  5918. */
  5919. addBehavior(behavior: Behavior<T>): T;
  5920. /**
  5921. * Remove a behavior from the current object
  5922. * @param behavior defines the behavior to detach
  5923. * @returns the current host
  5924. */
  5925. removeBehavior(behavior: Behavior<T>): T;
  5926. /**
  5927. * Gets a behavior using its name to search
  5928. * @param name defines the name to search
  5929. * @returns the behavior or null if not found
  5930. */
  5931. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5932. }
  5933. }
  5934. declare module BABYLON {
  5935. /**
  5936. * Class used to store bone information
  5937. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5938. */
  5939. class Bone extends Node {
  5940. /**
  5941. * defines the bone name
  5942. */
  5943. name: string;
  5944. private static _tmpVecs;
  5945. private static _tmpQuat;
  5946. private static _tmpMats;
  5947. /**
  5948. * Gets the list of child bones
  5949. */
  5950. children: Bone[];
  5951. /** Gets the animations associated with this bone */
  5952. animations: Animation[];
  5953. /**
  5954. * Gets or sets bone length
  5955. */
  5956. length: number;
  5957. /**
  5958. * @hidden Internal only
  5959. * Set this value to map this bone to a different index in the transform matrices
  5960. * Set this value to -1 to exclude the bone from the transform matrices
  5961. */
  5962. _index: Nullable<number>;
  5963. private _skeleton;
  5964. private _localMatrix;
  5965. private _restPose;
  5966. private _baseMatrix;
  5967. private _absoluteTransform;
  5968. private _invertedAbsoluteTransform;
  5969. private _parent;
  5970. private _scalingDeterminant;
  5971. private _worldTransform;
  5972. private _localScaling;
  5973. private _localRotation;
  5974. private _localPosition;
  5975. private _needToDecompose;
  5976. private _needToCompose;
  5977. /** @hidden */
  5978. /** @hidden */
  5979. _matrix: Matrix;
  5980. /**
  5981. * Create a new bone
  5982. * @param name defines the bone name
  5983. * @param skeleton defines the parent skeleton
  5984. * @param parentBone defines the parent (can be null if the bone is the root)
  5985. * @param localMatrix defines the local matrix
  5986. * @param restPose defines the rest pose matrix
  5987. * @param baseMatrix defines the base matrix
  5988. * @param index defines index of the bone in the hiearchy
  5989. */
  5990. constructor(
  5991. /**
  5992. * defines the bone name
  5993. */
  5994. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5995. /**
  5996. * Gets the parent skeleton
  5997. * @returns a skeleton
  5998. */
  5999. getSkeleton(): Skeleton;
  6000. /**
  6001. * Gets parent bone
  6002. * @returns a bone or null if the bone is the root of the bone hierarchy
  6003. */
  6004. getParent(): Nullable<Bone>;
  6005. /**
  6006. * Sets the parent bone
  6007. * @param parent defines the parent (can be null if the bone is the root)
  6008. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6009. */
  6010. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6011. /**
  6012. * Gets the local matrix
  6013. * @returns a matrix
  6014. */
  6015. getLocalMatrix(): Matrix;
  6016. /**
  6017. * Gets the base matrix (initial matrix which remains unchanged)
  6018. * @returns a matrix
  6019. */
  6020. getBaseMatrix(): Matrix;
  6021. /**
  6022. * Gets the rest pose matrix
  6023. * @returns a matrix
  6024. */
  6025. getRestPose(): Matrix;
  6026. /**
  6027. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6028. */
  6029. getWorldMatrix(): Matrix;
  6030. /**
  6031. * Sets the local matrix to rest pose matrix
  6032. */
  6033. returnToRest(): void;
  6034. /**
  6035. * Gets the inverse of the absolute transform matrix.
  6036. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6037. * @returns a matrix
  6038. */
  6039. getInvertedAbsoluteTransform(): Matrix;
  6040. /**
  6041. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6042. * @returns a matrix
  6043. */
  6044. getAbsoluteTransform(): Matrix;
  6045. /** Gets or sets current position (in local space) */
  6046. position: Vector3;
  6047. /** Gets or sets current rotation (in local space) */
  6048. rotation: Vector3;
  6049. /** Gets or sets current rotation quaternion (in local space) */
  6050. rotationQuaternion: Quaternion;
  6051. /** Gets or sets current scaling (in local space) */
  6052. scaling: Vector3;
  6053. /**
  6054. * Gets the animation properties override
  6055. */
  6056. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6057. private _decompose;
  6058. private _compose;
  6059. /**
  6060. * Update the base and local matrices
  6061. * @param matrix defines the new base or local matrix
  6062. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6063. * @param updateLocalMatrix defines if the local matrix should be updated
  6064. */
  6065. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6066. /** @hidden */
  6067. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6068. /**
  6069. * Flag the bone as dirty (Forcing it to update everything)
  6070. */
  6071. markAsDirty(): void;
  6072. private _markAsDirtyAndCompose;
  6073. private _markAsDirtyAndDecompose;
  6074. /**
  6075. * Copy an animation range from another bone
  6076. * @param source defines the source bone
  6077. * @param rangeName defines the range name to copy
  6078. * @param frameOffset defines the frame offset
  6079. * @param rescaleAsRequired defines if rescaling must be applied if required
  6080. * @param skelDimensionsRatio defines the scaling ratio
  6081. * @returns true if operation was successful
  6082. */
  6083. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6084. /**
  6085. * Translate the bone in local or world space
  6086. * @param vec The amount to translate the bone
  6087. * @param space The space that the translation is in
  6088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6089. */
  6090. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6091. /**
  6092. * Set the postion of the bone in local or world space
  6093. * @param position The position to set the bone
  6094. * @param space The space that the position is in
  6095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6096. */
  6097. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6098. /**
  6099. * Set the absolute position of the bone (world space)
  6100. * @param position The position to set the bone
  6101. * @param mesh The mesh that this bone is attached to
  6102. */
  6103. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6104. /**
  6105. * Scale the bone on the x, y and z axes (in local space)
  6106. * @param x The amount to scale the bone on the x axis
  6107. * @param y The amount to scale the bone on the y axis
  6108. * @param z The amount to scale the bone on the z axis
  6109. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6110. */
  6111. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6112. /**
  6113. * Set the bone scaling in local space
  6114. * @param scale defines the scaling vector
  6115. */
  6116. setScale(scale: Vector3): void;
  6117. /**
  6118. * Gets the current scaling in local space
  6119. * @returns the current scaling vector
  6120. */
  6121. getScale(): Vector3;
  6122. /**
  6123. * Gets the current scaling in local space and stores it in a target vector
  6124. * @param result defines the target vector
  6125. */
  6126. getScaleToRef(result: Vector3): void;
  6127. /**
  6128. * Set the yaw, pitch, and roll of the bone in local or world space
  6129. * @param yaw The rotation of the bone on the y axis
  6130. * @param pitch The rotation of the bone on the x axis
  6131. * @param roll The rotation of the bone on the z axis
  6132. * @param space The space that the axes of rotation are in
  6133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6134. */
  6135. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6136. /**
  6137. * Add a rotation to the bone on an axis in local or world space
  6138. * @param axis The axis to rotate the bone on
  6139. * @param amount The amount to rotate the bone
  6140. * @param space The space that the axis is in
  6141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6142. */
  6143. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6144. /**
  6145. * Set the rotation of the bone to a particular axis angle in local or world space
  6146. * @param axis The axis to rotate the bone on
  6147. * @param angle The angle that the bone should be rotated to
  6148. * @param space The space that the axis is in
  6149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6150. */
  6151. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6152. /**
  6153. * Set the euler rotation of the bone in local of world space
  6154. * @param rotation The euler rotation that the bone should be set to
  6155. * @param space The space that the rotation is in
  6156. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6157. */
  6158. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6159. /**
  6160. * Set the quaternion rotation of the bone in local of world space
  6161. * @param quat The quaternion rotation that the bone should be set to
  6162. * @param space The space that the rotation is in
  6163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6164. */
  6165. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6166. /**
  6167. * Set the rotation matrix of the bone in local of world space
  6168. * @param rotMat The rotation matrix that the bone should be set to
  6169. * @param space The space that the rotation is in
  6170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6171. */
  6172. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6173. private _rotateWithMatrix;
  6174. private _getNegativeRotationToRef;
  6175. /**
  6176. * Get the position of the bone in local or world space
  6177. * @param space The space that the returned position is in
  6178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6179. * @returns The position of the bone
  6180. */
  6181. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6182. /**
  6183. * Copy the position of the bone to a vector3 in local or world space
  6184. * @param space The space that the returned position is in
  6185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6186. * @param result The vector3 to copy the position to
  6187. */
  6188. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6189. /**
  6190. * Get the absolute position of the bone (world space)
  6191. * @param mesh The mesh that this bone is attached to
  6192. * @returns The absolute position of the bone
  6193. */
  6194. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6195. /**
  6196. * Copy the absolute position of the bone (world space) to the result param
  6197. * @param mesh The mesh that this bone is attached to
  6198. * @param result The vector3 to copy the absolute position to
  6199. */
  6200. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6201. /**
  6202. * Compute the absolute transforms of this bone and its children
  6203. */
  6204. computeAbsoluteTransforms(): void;
  6205. /**
  6206. * Get the world direction from an axis that is in the local space of the bone
  6207. * @param localAxis The local direction that is used to compute the world direction
  6208. * @param mesh The mesh that this bone is attached to
  6209. * @returns The world direction
  6210. */
  6211. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6212. /**
  6213. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6214. * @param localAxis The local direction that is used to compute the world direction
  6215. * @param mesh The mesh that this bone is attached to
  6216. * @param result The vector3 that the world direction will be copied to
  6217. */
  6218. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6219. /**
  6220. * Get the euler rotation of the bone in local or world space
  6221. * @param space The space that the rotation should be in
  6222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6223. * @returns The euler rotation
  6224. */
  6225. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6226. /**
  6227. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6228. * @param space The space that the rotation should be in
  6229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6230. * @param result The vector3 that the rotation should be copied to
  6231. */
  6232. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6233. /**
  6234. * Get the quaternion rotation of the bone in either local or world space
  6235. * @param space The space that the rotation should be in
  6236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6237. * @returns The quaternion rotation
  6238. */
  6239. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6240. /**
  6241. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6242. * @param space The space that the rotation should be in
  6243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6244. * @param result The quaternion that the rotation should be copied to
  6245. */
  6246. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6247. /**
  6248. * Get the rotation matrix of the bone in local or world space
  6249. * @param space The space that the rotation should be in
  6250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6251. * @returns The rotation matrix
  6252. */
  6253. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6254. /**
  6255. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6256. * @param space The space that the rotation should be in
  6257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6258. * @param result The quaternion that the rotation should be copied to
  6259. */
  6260. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6261. /**
  6262. * Get the world position of a point that is in the local space of the bone
  6263. * @param position The local position
  6264. * @param mesh The mesh that this bone is attached to
  6265. * @returns The world position
  6266. */
  6267. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6268. /**
  6269. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6270. * @param position The local position
  6271. * @param mesh The mesh that this bone is attached to
  6272. * @param result The vector3 that the world position should be copied to
  6273. */
  6274. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6275. /**
  6276. * Get the local position of a point that is in world space
  6277. * @param position The world position
  6278. * @param mesh The mesh that this bone is attached to
  6279. * @returns The local position
  6280. */
  6281. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6282. /**
  6283. * Get the local position of a point that is in world space and copy it to the result param
  6284. * @param position The world position
  6285. * @param mesh The mesh that this bone is attached to
  6286. * @param result The vector3 that the local position should be copied to
  6287. */
  6288. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6289. }
  6290. }
  6291. declare module BABYLON {
  6292. /**
  6293. * Class used to apply inverse kinematics to bones
  6294. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6295. */
  6296. class BoneIKController {
  6297. private static _tmpVecs;
  6298. private static _tmpQuat;
  6299. private static _tmpMats;
  6300. /**
  6301. * Gets or sets the target mesh
  6302. */
  6303. targetMesh: AbstractMesh;
  6304. /** Gets or sets the mesh used as pole */
  6305. poleTargetMesh: AbstractMesh;
  6306. /**
  6307. * Gets or sets the bone used as pole
  6308. */
  6309. poleTargetBone: Nullable<Bone>;
  6310. /**
  6311. * Gets or sets the target position
  6312. */
  6313. targetPosition: Vector3;
  6314. /**
  6315. * Gets or sets the pole target position
  6316. */
  6317. poleTargetPosition: Vector3;
  6318. /**
  6319. * Gets or sets the pole target local offset
  6320. */
  6321. poleTargetLocalOffset: Vector3;
  6322. /**
  6323. * Gets or sets the pole angle
  6324. */
  6325. poleAngle: number;
  6326. /**
  6327. * Gets or sets the mesh associated with the controller
  6328. */
  6329. mesh: AbstractMesh;
  6330. /**
  6331. * 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)
  6332. */
  6333. slerpAmount: number;
  6334. private _bone1Quat;
  6335. private _bone1Mat;
  6336. private _bone2Ang;
  6337. private _bone1;
  6338. private _bone2;
  6339. private _bone1Length;
  6340. private _bone2Length;
  6341. private _maxAngle;
  6342. private _maxReach;
  6343. private _rightHandedSystem;
  6344. private _bendAxis;
  6345. private _slerping;
  6346. private _adjustRoll;
  6347. /**
  6348. * Gets or sets maximum allowed angle
  6349. */
  6350. maxAngle: number;
  6351. /**
  6352. * Creates a new BoneIKController
  6353. * @param mesh defines the mesh to control
  6354. * @param bone defines the bone to control
  6355. * @param options defines options to set up the controller
  6356. */
  6357. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6358. targetMesh?: AbstractMesh;
  6359. poleTargetMesh?: AbstractMesh;
  6360. poleTargetBone?: Bone;
  6361. poleTargetLocalOffset?: Vector3;
  6362. poleAngle?: number;
  6363. bendAxis?: Vector3;
  6364. maxAngle?: number;
  6365. slerpAmount?: number;
  6366. });
  6367. private _setMaxAngle;
  6368. /**
  6369. * Force the controller to update the bones
  6370. */
  6371. update(): void;
  6372. }
  6373. }
  6374. declare module BABYLON {
  6375. /**
  6376. * Class used to make a bone look toward a point in space
  6377. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6378. */
  6379. class BoneLookController {
  6380. private static _tmpVecs;
  6381. private static _tmpQuat;
  6382. private static _tmpMats;
  6383. /**
  6384. * The target Vector3 that the bone will look at
  6385. */
  6386. target: Vector3;
  6387. /**
  6388. * The mesh that the bone is attached to
  6389. */
  6390. mesh: AbstractMesh;
  6391. /**
  6392. * The bone that will be looking to the target
  6393. */
  6394. bone: Bone;
  6395. /**
  6396. * The up axis of the coordinate system that is used when the bone is rotated
  6397. */
  6398. upAxis: Vector3;
  6399. /**
  6400. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6401. */
  6402. upAxisSpace: Space;
  6403. /**
  6404. * Used to make an adjustment to the yaw of the bone
  6405. */
  6406. adjustYaw: number;
  6407. /**
  6408. * Used to make an adjustment to the pitch of the bone
  6409. */
  6410. adjustPitch: number;
  6411. /**
  6412. * Used to make an adjustment to the roll of the bone
  6413. */
  6414. adjustRoll: number;
  6415. /**
  6416. * 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)
  6417. */
  6418. slerpAmount: number;
  6419. private _minYaw;
  6420. private _maxYaw;
  6421. private _minPitch;
  6422. private _maxPitch;
  6423. private _minYawSin;
  6424. private _minYawCos;
  6425. private _maxYawSin;
  6426. private _maxYawCos;
  6427. private _midYawConstraint;
  6428. private _minPitchTan;
  6429. private _maxPitchTan;
  6430. private _boneQuat;
  6431. private _slerping;
  6432. private _transformYawPitch;
  6433. private _transformYawPitchInv;
  6434. private _firstFrameSkipped;
  6435. private _yawRange;
  6436. private _fowardAxis;
  6437. /**
  6438. * Gets or sets the minimum yaw angle that the bone can look to
  6439. */
  6440. minYaw: number;
  6441. /**
  6442. * Gets or sets the maximum yaw angle that the bone can look to
  6443. */
  6444. maxYaw: number;
  6445. /**
  6446. * Gets or sets the minimum pitch angle that the bone can look to
  6447. */
  6448. minPitch: number;
  6449. /**
  6450. * Gets or sets the maximum pitch angle that the bone can look to
  6451. */
  6452. maxPitch: number;
  6453. /**
  6454. * Create a BoneLookController
  6455. * @param mesh the mesh that the bone belongs to
  6456. * @param bone the bone that will be looking to the target
  6457. * @param target the target Vector3 to look at
  6458. * @param settings optional settings:
  6459. * * maxYaw: the maximum angle the bone will yaw to
  6460. * * minYaw: the minimum angle the bone will yaw to
  6461. * * maxPitch: the maximum angle the bone will pitch to
  6462. * * minPitch: the minimum angle the bone will yaw to
  6463. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6464. * * upAxis: the up axis of the coordinate system
  6465. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6466. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6467. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6468. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6469. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6470. * * adjustRoll: used to make an adjustment to the roll of the bone
  6471. **/
  6472. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6473. maxYaw?: number;
  6474. minYaw?: number;
  6475. maxPitch?: number;
  6476. minPitch?: number;
  6477. slerpAmount?: number;
  6478. upAxis?: Vector3;
  6479. upAxisSpace?: Space;
  6480. yawAxis?: Vector3;
  6481. pitchAxis?: Vector3;
  6482. adjustYaw?: number;
  6483. adjustPitch?: number;
  6484. adjustRoll?: number;
  6485. });
  6486. /**
  6487. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6488. */
  6489. update(): void;
  6490. private _getAngleDiff;
  6491. private _getAngleBetween;
  6492. private _isAngleBetween;
  6493. }
  6494. }
  6495. declare module BABYLON {
  6496. /**
  6497. * Class used to handle skinning animations
  6498. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6499. */
  6500. class Skeleton implements IAnimatable {
  6501. /** defines the skeleton name */
  6502. name: string;
  6503. /** defines the skeleton Id */
  6504. id: string;
  6505. /**
  6506. * Gets the list of child bones
  6507. */
  6508. bones: Bone[];
  6509. /**
  6510. * Gets an estimate of the dimension of the skeleton at rest
  6511. */
  6512. dimensionsAtRest: Vector3;
  6513. /**
  6514. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6515. */
  6516. needInitialSkinMatrix: boolean;
  6517. /**
  6518. * Gets the list of animations attached to this skeleton
  6519. */
  6520. animations: Array<Animation>;
  6521. private _scene;
  6522. private _isDirty;
  6523. private _transformMatrices;
  6524. private _transformMatrixTexture;
  6525. private _meshesWithPoseMatrix;
  6526. private _animatables;
  6527. private _identity;
  6528. private _synchronizedWithMesh;
  6529. private _ranges;
  6530. private _lastAbsoluteTransformsUpdateId;
  6531. private _canUseTextureForBones;
  6532. /**
  6533. * Specifies if the skeleton should be serialized
  6534. */
  6535. doNotSerialize: boolean;
  6536. /**
  6537. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6538. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6539. */
  6540. useTextureToStoreBoneMatrices: boolean;
  6541. private _animationPropertiesOverride;
  6542. /**
  6543. * Gets or sets the animation properties override
  6544. */
  6545. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6546. /**
  6547. * An observable triggered before computing the skeleton's matrices
  6548. */
  6549. onBeforeComputeObservable: Observable<Skeleton>;
  6550. /**
  6551. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6552. */
  6553. readonly isUsingTextureForMatrices: boolean;
  6554. /**
  6555. * Creates a new skeleton
  6556. * @param name defines the skeleton name
  6557. * @param id defines the skeleton Id
  6558. * @param scene defines the hosting scene
  6559. */
  6560. constructor(
  6561. /** defines the skeleton name */
  6562. name: string,
  6563. /** defines the skeleton Id */
  6564. id: string, scene: Scene);
  6565. /**
  6566. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6567. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6568. * @returns a Float32Array containing matrices data
  6569. */
  6570. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6571. /**
  6572. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6573. * @returns a raw texture containing the data
  6574. */
  6575. getTransformMatrixTexture(): Nullable<RawTexture>;
  6576. /**
  6577. * Gets the current hosting scene
  6578. * @returns a scene object
  6579. */
  6580. getScene(): Scene;
  6581. /**
  6582. * Gets a string representing the current skeleton data
  6583. * @param fullDetails defines a boolean indicating if we want a verbose version
  6584. * @returns a string representing the current skeleton data
  6585. */
  6586. toString(fullDetails?: boolean): string;
  6587. /**
  6588. * Get bone's index searching by name
  6589. * @param name defines bone's name to search for
  6590. * @return the indice of the bone. Returns -1 if not found
  6591. */
  6592. getBoneIndexByName(name: string): number;
  6593. /**
  6594. * Creater a new animation range
  6595. * @param name defines the name of the range
  6596. * @param from defines the start key
  6597. * @param to defines the end key
  6598. */
  6599. createAnimationRange(name: string, from: number, to: number): void;
  6600. /**
  6601. * Delete a specific animation range
  6602. * @param name defines the name of the range
  6603. * @param deleteFrames defines if frames must be removed as well
  6604. */
  6605. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6606. /**
  6607. * Gets a specific animation range
  6608. * @param name defines the name of the range to look for
  6609. * @returns the requested animation range or null if not found
  6610. */
  6611. getAnimationRange(name: string): Nullable<AnimationRange>;
  6612. /**
  6613. * Gets the list of all animation ranges defined on this skeleton
  6614. * @returns an array
  6615. */
  6616. getAnimationRanges(): Nullable<AnimationRange>[];
  6617. /**
  6618. * Copy animation range from a source skeleton.
  6619. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6620. * @param source defines the source skeleton
  6621. * @param name defines the name of the range to copy
  6622. * @param rescaleAsRequired defines if rescaling must be applied if required
  6623. * @returns true if operation was successful
  6624. */
  6625. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6626. /**
  6627. * Forces the skeleton to go to rest pose
  6628. */
  6629. returnToRest(): void;
  6630. private _getHighestAnimationFrame;
  6631. /**
  6632. * Begin a specific animation range
  6633. * @param name defines the name of the range to start
  6634. * @param loop defines if looping must be turned on (false by default)
  6635. * @param speedRatio defines the speed ratio to apply (1 by default)
  6636. * @param onAnimationEnd defines a callback which will be called when animation will end
  6637. * @returns a new animatable
  6638. */
  6639. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6640. /** @hidden */
  6641. _markAsDirty(): void;
  6642. /** @hidden */
  6643. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6644. /** @hidden */
  6645. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6646. private _computeTransformMatrices;
  6647. /**
  6648. * Build all resources required to render a skeleton
  6649. */
  6650. prepare(): void;
  6651. /**
  6652. * Gets the list of animatables currently running for this skeleton
  6653. * @returns an array of animatables
  6654. */
  6655. getAnimatables(): IAnimatable[];
  6656. /**
  6657. * Clone the current skeleton
  6658. * @param name defines the name of the new skeleton
  6659. * @param id defines the id of the enw skeleton
  6660. * @returns the new skeleton
  6661. */
  6662. clone(name: string, id: string): Skeleton;
  6663. /**
  6664. * Enable animation blending for this skeleton
  6665. * @param blendingSpeed defines the blending speed to apply
  6666. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6667. */
  6668. enableBlending(blendingSpeed?: number): void;
  6669. /**
  6670. * Releases all resources associated with the current skeleton
  6671. */
  6672. dispose(): void;
  6673. /**
  6674. * Serialize the skeleton in a JSON object
  6675. * @returns a JSON object
  6676. */
  6677. serialize(): any;
  6678. /**
  6679. * Creates a new skeleton from serialized data
  6680. * @param parsedSkeleton defines the serialized data
  6681. * @param scene defines the hosting scene
  6682. * @returns a new skeleton
  6683. */
  6684. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6685. /**
  6686. * Compute all node absolute transforms
  6687. * @param forceUpdate defines if computation must be done even if cache is up to date
  6688. */
  6689. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6690. /**
  6691. * Gets the root pose matrix
  6692. * @returns a matrix
  6693. */
  6694. getPoseMatrix(): Nullable<Matrix>;
  6695. /**
  6696. * Sorts bones per internal index
  6697. */
  6698. sortBones(): void;
  6699. private _sortBones;
  6700. }
  6701. }
  6702. declare module BABYLON {
  6703. /**
  6704. * This represents an orbital type of camera.
  6705. *
  6706. * 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.
  6707. * 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.
  6708. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6709. */
  6710. class ArcRotateCamera extends TargetCamera {
  6711. /**
  6712. * Defines the rotation angle of the camera along the longitudinal axis.
  6713. */
  6714. alpha: number;
  6715. /**
  6716. * Defines the rotation angle of the camera along the latitudinal axis.
  6717. */
  6718. beta: number;
  6719. /**
  6720. * Defines the radius of the camera from it s target point.
  6721. */
  6722. radius: number;
  6723. protected _target: Vector3;
  6724. protected _targetHost: Nullable<AbstractMesh>;
  6725. /**
  6726. * Defines the target point of the camera.
  6727. * The camera looks towards it form the radius distance.
  6728. */
  6729. target: Vector3;
  6730. /**
  6731. * Current inertia value on the longitudinal axis.
  6732. * The bigger this number the longer it will take for the camera to stop.
  6733. */
  6734. inertialAlphaOffset: number;
  6735. /**
  6736. * Current inertia value on the latitudinal axis.
  6737. * The bigger this number the longer it will take for the camera to stop.
  6738. */
  6739. inertialBetaOffset: number;
  6740. /**
  6741. * Current inertia value on the radius axis.
  6742. * The bigger this number the longer it will take for the camera to stop.
  6743. */
  6744. inertialRadiusOffset: number;
  6745. /**
  6746. * Minimum allowed angle on the longitudinal axis.
  6747. * This can help limiting how the Camera is able to move in the scene.
  6748. */
  6749. lowerAlphaLimit: Nullable<number>;
  6750. /**
  6751. * Maximum allowed angle on the longitudinal axis.
  6752. * This can help limiting how the Camera is able to move in the scene.
  6753. */
  6754. upperAlphaLimit: Nullable<number>;
  6755. /**
  6756. * Minimum allowed angle on the latitudinal axis.
  6757. * This can help limiting how the Camera is able to move in the scene.
  6758. */
  6759. lowerBetaLimit: number;
  6760. /**
  6761. * Maximum allowed angle on the latitudinal axis.
  6762. * This can help limiting how the Camera is able to move in the scene.
  6763. */
  6764. upperBetaLimit: number;
  6765. /**
  6766. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6767. * This can help limiting how the Camera is able to move in the scene.
  6768. */
  6769. lowerRadiusLimit: Nullable<number>;
  6770. /**
  6771. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6772. * This can help limiting how the Camera is able to move in the scene.
  6773. */
  6774. upperRadiusLimit: Nullable<number>;
  6775. /**
  6776. * Defines the current inertia value used during panning of the camera along the X axis.
  6777. */
  6778. inertialPanningX: number;
  6779. /**
  6780. * Defines the current inertia value used during panning of the camera along the Y axis.
  6781. */
  6782. inertialPanningY: number;
  6783. /**
  6784. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6785. * Basically if your fingers moves away from more than this distance you will be considered
  6786. * in pinch mode.
  6787. */
  6788. pinchToPanMaxDistance: number;
  6789. /**
  6790. * Defines the maximum distance the camera can pan.
  6791. * This could help keeping the cammera always in your scene.
  6792. */
  6793. panningDistanceLimit: Nullable<number>;
  6794. /**
  6795. * Defines the target of the camera before paning.
  6796. */
  6797. panningOriginTarget: Vector3;
  6798. /**
  6799. * Defines the value of the inertia used during panning.
  6800. * 0 would mean stop inertia and one would mean no decelleration at all.
  6801. */
  6802. panningInertia: number;
  6803. /**
  6804. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6805. */
  6806. angularSensibilityX: number;
  6807. /**
  6808. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6809. */
  6810. angularSensibilityY: number;
  6811. /**
  6812. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6813. */
  6814. pinchPrecision: number;
  6815. /**
  6816. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6817. * It will be used instead of pinchDeltaPrecision if different from 0.
  6818. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6819. */
  6820. pinchDeltaPercentage: number;
  6821. /**
  6822. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6823. */
  6824. panningSensibility: number;
  6825. /**
  6826. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6827. */
  6828. keysUp: number[];
  6829. /**
  6830. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6831. */
  6832. keysDown: number[];
  6833. /**
  6834. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6835. */
  6836. keysLeft: number[];
  6837. /**
  6838. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6839. */
  6840. keysRight: number[];
  6841. /**
  6842. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6843. */
  6844. wheelPrecision: number;
  6845. /**
  6846. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6847. * It will be used instead of pinchDeltaPrecision if different from 0.
  6848. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6849. */
  6850. wheelDeltaPercentage: number;
  6851. /**
  6852. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6853. */
  6854. zoomOnFactor: number;
  6855. /**
  6856. * Defines a screen offset for the camera position.
  6857. */
  6858. targetScreenOffset: Vector2;
  6859. /**
  6860. * Allows the camera to be completely reversed.
  6861. * If false the camera can not arrive upside down.
  6862. */
  6863. allowUpsideDown: boolean;
  6864. /**
  6865. * Define if double tap/click is used to restore the previously saved state of the camera.
  6866. */
  6867. useInputToRestoreState: boolean;
  6868. /** @hidden */
  6869. _viewMatrix: Matrix;
  6870. /** @hidden */
  6871. _useCtrlForPanning: boolean;
  6872. /** @hidden */
  6873. _panningMouseButton: number;
  6874. /**
  6875. * Defines the inpute associated to the camera.
  6876. */
  6877. inputs: ArcRotateCameraInputsManager;
  6878. /** @hidden */
  6879. _reset: () => void;
  6880. /**
  6881. * Defines the allowed panning axis.
  6882. */
  6883. panningAxis: Vector3;
  6884. protected _localDirection: Vector3;
  6885. protected _transformedDirection: Vector3;
  6886. private _bouncingBehavior;
  6887. /**
  6888. * Gets the bouncing behavior of the camera if it has been enabled.
  6889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6890. */
  6891. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6892. /**
  6893. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6895. */
  6896. useBouncingBehavior: boolean;
  6897. private _framingBehavior;
  6898. /**
  6899. * Gets the framing behavior of the camera if it has been enabled.
  6900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6901. */
  6902. readonly framingBehavior: Nullable<FramingBehavior>;
  6903. /**
  6904. * Defines if the framing behavior of the camera is enabled on the camera.
  6905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6906. */
  6907. useFramingBehavior: boolean;
  6908. private _autoRotationBehavior;
  6909. /**
  6910. * Gets the auto rotation behavior of the camera if it has been enabled.
  6911. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6912. */
  6913. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6914. /**
  6915. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6917. */
  6918. useAutoRotationBehavior: boolean;
  6919. /**
  6920. * Observable triggered when the mesh target has been changed on the camera.
  6921. */
  6922. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6923. /**
  6924. * Event raised when the camera is colliding with a mesh.
  6925. */
  6926. onCollide: (collidedMesh: AbstractMesh) => void;
  6927. /**
  6928. * Defines whether the camera should check collision with the objects oh the scene.
  6929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6930. */
  6931. checkCollisions: boolean;
  6932. /**
  6933. * Defines the collision radius of the camera.
  6934. * This simulates a sphere around the camera.
  6935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6936. */
  6937. collisionRadius: Vector3;
  6938. protected _collider: Collider;
  6939. protected _previousPosition: Vector3;
  6940. protected _collisionVelocity: Vector3;
  6941. protected _newPosition: Vector3;
  6942. protected _previousAlpha: number;
  6943. protected _previousBeta: number;
  6944. protected _previousRadius: number;
  6945. protected _collisionTriggered: boolean;
  6946. protected _targetBoundingCenter: Nullable<Vector3>;
  6947. private _computationVector;
  6948. /**
  6949. * Instantiates a new ArcRotateCamera in a given scene
  6950. * @param name Defines the name of the camera
  6951. * @param alpha Defines the camera rotation along the logitudinal axis
  6952. * @param beta Defines the camera rotation along the latitudinal axis
  6953. * @param radius Defines the camera distance from its target
  6954. * @param target Defines the camera target
  6955. * @param scene Defines the scene the camera belongs to
  6956. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6957. */
  6958. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6959. /** @hidden */
  6960. _initCache(): void;
  6961. /** @hidden */
  6962. _updateCache(ignoreParentClass?: boolean): void;
  6963. protected _getTargetPosition(): Vector3;
  6964. private _storedAlpha;
  6965. private _storedBeta;
  6966. private _storedRadius;
  6967. private _storedTarget;
  6968. /**
  6969. * Stores the current state of the camera (alpha, beta, radius and target)
  6970. * @returns the camera itself
  6971. */
  6972. storeState(): Camera;
  6973. /**
  6974. * @hidden
  6975. * Restored camera state. You must call storeState() first
  6976. */
  6977. _restoreStateValues(): boolean;
  6978. /** @hidden */
  6979. _isSynchronizedViewMatrix(): boolean;
  6980. /**
  6981. * Attached controls to the current camera.
  6982. * @param element Defines the element the controls should be listened from
  6983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6984. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  6985. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  6986. */
  6987. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6988. /**
  6989. * Detach the current controls from the camera.
  6990. * The camera will stop reacting to inputs.
  6991. * @param element Defines the element to stop listening the inputs from
  6992. */
  6993. detachControl(element: HTMLElement): void;
  6994. /** @hidden */
  6995. _checkInputs(): void;
  6996. protected _checkLimits(): void;
  6997. /**
  6998. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  6999. */
  7000. rebuildAnglesAndRadius(): void;
  7001. /**
  7002. * Use a position to define the current camera related information like aplha, beta and radius
  7003. * @param position Defines the position to set the camera at
  7004. */
  7005. setPosition(position: Vector3): void;
  7006. /**
  7007. * Defines the target the camera should look at.
  7008. * This will automatically adapt alpha beta and radius to fit within the new target.
  7009. * @param target Defines the new target as a Vector or a mesh
  7010. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7011. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7012. */
  7013. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7014. /** @hidden */
  7015. _getViewMatrix(): Matrix;
  7016. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7017. /**
  7018. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7019. * @param meshes Defines the mesh to zoom on
  7020. * @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)
  7021. */
  7022. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7023. /**
  7024. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7025. * The target will be changed but the radius
  7026. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7027. * @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)
  7028. */
  7029. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7030. min: Vector3;
  7031. max: Vector3;
  7032. distance: number;
  7033. }, doNotUpdateMaxZ?: boolean): void;
  7034. /**
  7035. * @override
  7036. * Override Camera.createRigCamera
  7037. */
  7038. createRigCamera(name: string, cameraIndex: number): Camera;
  7039. /**
  7040. * @hidden
  7041. * @override
  7042. * Override Camera._updateRigCameras
  7043. */
  7044. _updateRigCameras(): void;
  7045. /**
  7046. * Destroy the camera and release the current resources hold by it.
  7047. */
  7048. dispose(): void;
  7049. /**
  7050. * Gets the current object class name.
  7051. * @return the class name
  7052. */
  7053. getClassName(): string;
  7054. }
  7055. }
  7056. declare module BABYLON {
  7057. /**
  7058. * Default Inputs manager for the ArcRotateCamera.
  7059. * It groups all the default supported inputs for ease of use.
  7060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7061. */
  7062. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7063. /**
  7064. * Instantiates a new ArcRotateCameraInputsManager.
  7065. * @param camera Defines the camera the inputs belong to
  7066. */
  7067. constructor(camera: ArcRotateCamera);
  7068. /**
  7069. * Add mouse wheel input support to the input manager.
  7070. * @returns the current input manager
  7071. */
  7072. addMouseWheel(): ArcRotateCameraInputsManager;
  7073. /**
  7074. * Add pointers input support to the input manager.
  7075. * @returns the current input manager
  7076. */
  7077. addPointers(): ArcRotateCameraInputsManager;
  7078. /**
  7079. * Add keyboard input support to the input manager.
  7080. * @returns the current input manager
  7081. */
  7082. addKeyboard(): ArcRotateCameraInputsManager;
  7083. /**
  7084. * Add orientation input support to the input manager.
  7085. * @returns the current input manager
  7086. */
  7087. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7088. }
  7089. }
  7090. declare module BABYLON {
  7091. /**
  7092. * This is the base class of all the camera used in the application.
  7093. * @see http://doc.babylonjs.com/features/cameras
  7094. */
  7095. class Camera extends Node {
  7096. /**
  7097. * This is the default projection mode used by the cameras.
  7098. * It helps recreating a feeling of perspective and better appreciate depth.
  7099. * This is the best way to simulate real life cameras.
  7100. */
  7101. static readonly PERSPECTIVE_CAMERA: number;
  7102. /**
  7103. * This helps creating camera with an orthographic mode.
  7104. * 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.
  7105. */
  7106. static readonly ORTHOGRAPHIC_CAMERA: number;
  7107. /**
  7108. * This is the default FOV mode for perspective cameras.
  7109. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7110. */
  7111. static readonly FOVMODE_VERTICAL_FIXED: number;
  7112. /**
  7113. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7114. */
  7115. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7116. /**
  7117. * This specifies ther is no need for a camera rig.
  7118. * Basically only one eye is rendered corresponding to the camera.
  7119. */
  7120. static readonly RIG_MODE_NONE: number;
  7121. /**
  7122. * Simulates a camera Rig with one blue eye and one red eye.
  7123. * This can be use with 3d blue and red glasses.
  7124. */
  7125. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7126. /**
  7127. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7128. */
  7129. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7130. /**
  7131. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7132. */
  7133. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7134. /**
  7135. * Defines that both eyes of the camera will be rendered over under each other.
  7136. */
  7137. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7138. /**
  7139. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7140. */
  7141. static readonly RIG_MODE_VR: number;
  7142. /**
  7143. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7144. */
  7145. static readonly RIG_MODE_WEBVR: number;
  7146. /**
  7147. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7148. */
  7149. static readonly RIG_MODE_CUSTOM: number;
  7150. /**
  7151. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7152. */
  7153. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7154. /**
  7155. * @hidden
  7156. * Might be removed once multiview will be a thing
  7157. */
  7158. static UseAlternateWebVRRendering: boolean;
  7159. /**
  7160. * Define the input manager associated with the camera.
  7161. */
  7162. inputs: CameraInputsManager<Camera>;
  7163. /**
  7164. * Define the current local position of the camera in the scene
  7165. */
  7166. position: Vector3;
  7167. /**
  7168. * The vector the camera should consider as up.
  7169. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7170. */
  7171. upVector: Vector3;
  7172. /**
  7173. * Define the current limit on the left side for an orthographic camera
  7174. * In scene unit
  7175. */
  7176. orthoLeft: Nullable<number>;
  7177. /**
  7178. * Define the current limit on the right side for an orthographic camera
  7179. * In scene unit
  7180. */
  7181. orthoRight: Nullable<number>;
  7182. /**
  7183. * Define the current limit on the bottom side for an orthographic camera
  7184. * In scene unit
  7185. */
  7186. orthoBottom: Nullable<number>;
  7187. /**
  7188. * Define the current limit on the top side for an orthographic camera
  7189. * In scene unit
  7190. */
  7191. orthoTop: Nullable<number>;
  7192. /**
  7193. * Field Of View is set in Radians. (default is 0.8)
  7194. */
  7195. fov: number;
  7196. /**
  7197. * Define the minimum distance the camera can see from.
  7198. * This is important to note that the depth buffer are not infinite and the closer it starts
  7199. * the more your scene might encounter depth fighting issue.
  7200. */
  7201. minZ: number;
  7202. /**
  7203. * Define the maximum distance the camera can see to.
  7204. * This is important to note that the depth buffer are not infinite and the further it end
  7205. * the more your scene might encounter depth fighting issue.
  7206. */
  7207. maxZ: number;
  7208. /**
  7209. * Define the default inertia of the camera.
  7210. * This helps giving a smooth feeling to the camera movement.
  7211. */
  7212. inertia: number;
  7213. /**
  7214. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7215. */
  7216. mode: number;
  7217. /**
  7218. * Define wether the camera is intermediate.
  7219. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7220. */
  7221. isIntermediate: boolean;
  7222. /**
  7223. * Define the viewport of the camera.
  7224. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7225. */
  7226. viewport: Viewport;
  7227. /**
  7228. * Restricts the camera to viewing objects with the same layerMask.
  7229. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7230. */
  7231. layerMask: number;
  7232. /**
  7233. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7234. */
  7235. fovMode: number;
  7236. /**
  7237. * Rig mode of the camera.
  7238. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7239. * This is normally controlled byt the camera themselves as internal use.
  7240. */
  7241. cameraRigMode: number;
  7242. /**
  7243. * Defines the distance between both "eyes" in case of a RIG
  7244. */
  7245. interaxialDistance: number;
  7246. /**
  7247. * Defines if stereoscopic rendering is done side by side or over under.
  7248. */
  7249. isStereoscopicSideBySide: boolean;
  7250. /**
  7251. * 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
  7252. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7253. * else in the scene.
  7254. */
  7255. customRenderTargets: RenderTargetTexture[];
  7256. /**
  7257. * When set, the camera will render to this render target instead of the default canvas
  7258. */
  7259. outputRenderTarget: Nullable<RenderTargetTexture>;
  7260. /**
  7261. * Observable triggered when the camera view matrix has changed.
  7262. */
  7263. onViewMatrixChangedObservable: Observable<Camera>;
  7264. /**
  7265. * Observable triggered when the camera Projection matrix has changed.
  7266. */
  7267. onProjectionMatrixChangedObservable: Observable<Camera>;
  7268. /**
  7269. * Observable triggered when the inputs have been processed.
  7270. */
  7271. onAfterCheckInputsObservable: Observable<Camera>;
  7272. /**
  7273. * Observable triggered when reset has been called and applied to the camera.
  7274. */
  7275. onRestoreStateObservable: Observable<Camera>;
  7276. /** @hidden */
  7277. _cameraRigParams: any;
  7278. /** @hidden */
  7279. _rigCameras: Camera[];
  7280. /** @hidden */
  7281. _rigPostProcess: Nullable<PostProcess>;
  7282. protected _webvrViewMatrix: Matrix;
  7283. /** @hidden */
  7284. _skipRendering: boolean;
  7285. /** @hidden */
  7286. _alternateCamera: Camera;
  7287. /** @hidden */
  7288. _projectionMatrix: Matrix;
  7289. /** @hidden */
  7290. _postProcesses: Nullable<PostProcess>[];
  7291. /** @hidden */
  7292. _activeMeshes: SmartArray<AbstractMesh>;
  7293. protected _globalPosition: Vector3;
  7294. /** hidden */
  7295. _computedViewMatrix: Matrix;
  7296. private _doNotComputeProjectionMatrix;
  7297. private _transformMatrix;
  7298. private _frustumPlanes;
  7299. private _refreshFrustumPlanes;
  7300. private _storedFov;
  7301. private _stateStored;
  7302. /**
  7303. * Instantiates a new camera object.
  7304. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7305. * @see http://doc.babylonjs.com/features/cameras
  7306. * @param name Defines the name of the camera in the scene
  7307. * @param position Defines the position of the camera
  7308. * @param scene Defines the scene the camera belongs too
  7309. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7310. */
  7311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7312. /**
  7313. * Store current camera state (fov, position, etc..)
  7314. * @returns the camera
  7315. */
  7316. storeState(): Camera;
  7317. /**
  7318. * Restores the camera state values if it has been stored. You must call storeState() first
  7319. */
  7320. protected _restoreStateValues(): boolean;
  7321. /**
  7322. * Restored camera state. You must call storeState() first.
  7323. * @returns true if restored and false otherwise
  7324. */
  7325. restoreState(): boolean;
  7326. /**
  7327. * Gets the class name of the camera.
  7328. * @returns the class name
  7329. */
  7330. getClassName(): string;
  7331. /**
  7332. * Gets a string representation of the camera usefull for debug purpose.
  7333. * @param fullDetails Defines that a more verboe level of logging is required
  7334. * @returns the string representation
  7335. */
  7336. toString(fullDetails?: boolean): string;
  7337. /**
  7338. * Gets the current world space position of the camera.
  7339. */
  7340. readonly globalPosition: Vector3;
  7341. /**
  7342. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7343. * @returns the active meshe list
  7344. */
  7345. getActiveMeshes(): SmartArray<AbstractMesh>;
  7346. /**
  7347. * Check wether a mesh is part of the current active mesh list of the camera
  7348. * @param mesh Defines the mesh to check
  7349. * @returns true if active, false otherwise
  7350. */
  7351. isActiveMesh(mesh: Mesh): boolean;
  7352. /**
  7353. * Is this camera ready to be used/rendered
  7354. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7355. * @return true if the camera is ready
  7356. */
  7357. isReady(completeCheck?: boolean): boolean;
  7358. /** @hidden */
  7359. _initCache(): void;
  7360. /** @hidden */
  7361. _updateCache(ignoreParentClass?: boolean): void;
  7362. /** @hidden */
  7363. _isSynchronized(): boolean;
  7364. /** @hidden */
  7365. _isSynchronizedViewMatrix(): boolean;
  7366. /** @hidden */
  7367. _isSynchronizedProjectionMatrix(): boolean;
  7368. /**
  7369. * Attach the input controls to a specific dom element to get the input from.
  7370. * @param element Defines the element the controls should be listened from
  7371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7372. */
  7373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7374. /**
  7375. * Detach the current controls from the specified dom element.
  7376. * @param element Defines the element to stop listening the inputs from
  7377. */
  7378. detachControl(element: HTMLElement): void;
  7379. /**
  7380. * Update the camera state according to the different inputs gathered during the frame.
  7381. */
  7382. update(): void;
  7383. /** @hidden */
  7384. _checkInputs(): void;
  7385. /** @hidden */
  7386. readonly rigCameras: Camera[];
  7387. /**
  7388. * Gets the post process used by the rig cameras
  7389. */
  7390. readonly rigPostProcess: Nullable<PostProcess>;
  7391. /**
  7392. * Internal, gets the first post proces.
  7393. * @returns the first post process to be run on this camera.
  7394. */
  7395. _getFirstPostProcess(): Nullable<PostProcess>;
  7396. private _cascadePostProcessesToRigCams;
  7397. /**
  7398. * Attach a post process to the camera.
  7399. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7400. * @param postProcess The post process to attach to the camera
  7401. * @param insertAt The position of the post process in case several of them are in use in the scene
  7402. * @returns the position the post process has been inserted at
  7403. */
  7404. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7405. /**
  7406. * Detach a post process to the camera.
  7407. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7408. * @param postProcess The post process to detach from the camera
  7409. */
  7410. detachPostProcess(postProcess: PostProcess): void;
  7411. /**
  7412. * Gets the current world matrix of the camera
  7413. */
  7414. getWorldMatrix(): Matrix;
  7415. /** @hidden */
  7416. protected _getViewMatrix(): Matrix;
  7417. /**
  7418. * Gets the current view matrix of the camera.
  7419. * @param force forces the camera to recompute the matrix without looking at the cached state
  7420. * @returns the view matrix
  7421. */
  7422. getViewMatrix(force?: boolean): Matrix;
  7423. /**
  7424. * Freeze the projection matrix.
  7425. * It will prevent the cache check of the camera projection compute and can speed up perf
  7426. * if no parameter of the camera are meant to change
  7427. * @param projection Defines manually a projection if necessary
  7428. */
  7429. freezeProjectionMatrix(projection?: Matrix): void;
  7430. /**
  7431. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7432. */
  7433. unfreezeProjectionMatrix(): void;
  7434. /**
  7435. * Gets the current projection matrix of the camera.
  7436. * @param force forces the camera to recompute the matrix without looking at the cached state
  7437. * @returns the projection matrix
  7438. */
  7439. getProjectionMatrix(force?: boolean): Matrix;
  7440. /**
  7441. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7442. * @returns a Matrix
  7443. */
  7444. getTransformationMatrix(): Matrix;
  7445. private _updateFrustumPlanes;
  7446. /**
  7447. * Checks if a cullable object (mesh...) is in the camera frustum
  7448. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7449. * @param target The object to check
  7450. * @returns true if the object is in frustum otherwise false
  7451. */
  7452. isInFrustum(target: ICullable): boolean;
  7453. /**
  7454. * Checks if a cullable object (mesh...) is in the camera frustum
  7455. * Unlike isInFrustum this cheks the full bounding box
  7456. * @param target The object to check
  7457. * @returns true if the object is in frustum otherwise false
  7458. */
  7459. isCompletelyInFrustum(target: ICullable): boolean;
  7460. /**
  7461. * Gets a ray in the forward direction from the camera.
  7462. * @param length Defines the length of the ray to create
  7463. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7464. * @param origin Defines the start point of the ray which defaults to the camera position
  7465. * @returns the forward ray
  7466. */
  7467. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7468. /**
  7469. * Releases resources associated with this node.
  7470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7472. */
  7473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7474. /**
  7475. * Gets the left camera of a rig setup in case of Rigged Camera
  7476. */
  7477. readonly leftCamera: Nullable<FreeCamera>;
  7478. /**
  7479. * Gets the right camera of a rig setup in case of Rigged Camera
  7480. */
  7481. readonly rightCamera: Nullable<FreeCamera>;
  7482. /**
  7483. * Gets the left camera target of a rig setup in case of Rigged Camera
  7484. * @returns the target position
  7485. */
  7486. getLeftTarget(): Nullable<Vector3>;
  7487. /**
  7488. * Gets the right camera target of a rig setup in case of Rigged Camera
  7489. * @returns the target position
  7490. */
  7491. getRightTarget(): Nullable<Vector3>;
  7492. /**
  7493. * @hidden
  7494. */
  7495. setCameraRigMode(mode: number, rigParams: any): void;
  7496. private _getVRProjectionMatrix;
  7497. protected _updateCameraRotationMatrix(): void;
  7498. protected _updateWebVRCameraRotationMatrix(): void;
  7499. /**
  7500. * This function MUST be overwritten by the different WebVR cameras available.
  7501. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7502. */
  7503. protected _getWebVRProjectionMatrix(): Matrix;
  7504. /**
  7505. * This function MUST be overwritten by the different WebVR cameras available.
  7506. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7507. */
  7508. protected _getWebVRViewMatrix(): Matrix;
  7509. /** @hidden */
  7510. setCameraRigParameter(name: string, value: any): void;
  7511. /**
  7512. * needs to be overridden by children so sub has required properties to be copied
  7513. * @hidden
  7514. */
  7515. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7516. /**
  7517. * May need to be overridden by children
  7518. * @hidden
  7519. */
  7520. _updateRigCameras(): void;
  7521. /** @hidden */
  7522. _setupInputs(): void;
  7523. /**
  7524. * Serialiaze the camera setup to a json represention
  7525. * @returns the JSON representation
  7526. */
  7527. serialize(): any;
  7528. /**
  7529. * Clones the current camera.
  7530. * @param name The cloned camera name
  7531. * @returns the cloned camera
  7532. */
  7533. clone(name: string): Camera;
  7534. /**
  7535. * Gets the direction of the camera relative to a given local axis.
  7536. * @param localAxis Defines the reference axis to provide a relative direction.
  7537. * @return the direction
  7538. */
  7539. getDirection(localAxis: Vector3): Vector3;
  7540. /**
  7541. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7542. * @param localAxis Defines the reference axis to provide a relative direction.
  7543. * @param result Defines the vector to store the result in
  7544. */
  7545. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7546. /**
  7547. * Gets a camera constructor for a given camera type
  7548. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7549. * @param name The name of the camera the result will be able to instantiate
  7550. * @param scene The scene the result will construct the camera in
  7551. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7552. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7553. * @returns a factory method to construc the camera
  7554. */
  7555. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7556. /**
  7557. * Compute the world matrix of the camera.
  7558. * @returns the camera workd matrix
  7559. */
  7560. computeWorldMatrix(): Matrix;
  7561. /**
  7562. * Parse a JSON and creates the camera from the parsed information
  7563. * @param parsedCamera The JSON to parse
  7564. * @param scene The scene to instantiate the camera in
  7565. * @returns the newly constructed camera
  7566. */
  7567. static Parse(parsedCamera: any, scene: Scene): Camera;
  7568. }
  7569. }
  7570. declare module BABYLON {
  7571. /**
  7572. * @ignore
  7573. * This is a list of all the different input types that are available in the application.
  7574. * Fo instance: ArcRotateCameraGamepadInput...
  7575. */
  7576. var CameraInputTypes: {};
  7577. /**
  7578. * This is the contract to implement in order to create a new input class.
  7579. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7580. */
  7581. interface ICameraInput<TCamera extends Camera> {
  7582. /**
  7583. * Defines the camera the input is attached to.
  7584. */
  7585. camera: Nullable<TCamera>;
  7586. /**
  7587. * Gets the class name of the current intput.
  7588. * @returns the class name
  7589. */
  7590. getClassName(): string;
  7591. /**
  7592. * Get the friendly name associated with the input class.
  7593. * @returns the input friendly name
  7594. */
  7595. getSimpleName(): string;
  7596. /**
  7597. * Attach the input controls to a specific dom element to get the input from.
  7598. * @param element Defines the element the controls should be listened from
  7599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7600. */
  7601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7602. /**
  7603. * Detach the current controls from the specified dom element.
  7604. * @param element Defines the element to stop listening the inputs from
  7605. */
  7606. detachControl(element: Nullable<HTMLElement>): void;
  7607. /**
  7608. * Update the current camera state depending on the inputs that have been used this frame.
  7609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7610. */
  7611. checkInputs?: () => void;
  7612. }
  7613. /**
  7614. * Represents a map of input types to input instance or input index to input instance.
  7615. */
  7616. interface CameraInputsMap<TCamera extends Camera> {
  7617. /**
  7618. * Accessor to the input by input type.
  7619. */
  7620. [name: string]: ICameraInput<TCamera>;
  7621. /**
  7622. * Accessor to the input by input index.
  7623. */
  7624. [idx: number]: ICameraInput<TCamera>;
  7625. }
  7626. /**
  7627. * This represents the input manager used within a camera.
  7628. * It helps dealing with all the different kind of input attached to a camera.
  7629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7630. */
  7631. class CameraInputsManager<TCamera extends Camera> {
  7632. /**
  7633. * Defines the list of inputs attahed to the camera.
  7634. */
  7635. attached: CameraInputsMap<TCamera>;
  7636. /**
  7637. * Defines the dom element the camera is collecting inputs from.
  7638. * This is null if the controls have not been attached.
  7639. */
  7640. attachedElement: Nullable<HTMLElement>;
  7641. /**
  7642. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7643. */
  7644. noPreventDefault: boolean;
  7645. /**
  7646. * Defined the camera the input manager belongs to.
  7647. */
  7648. camera: TCamera;
  7649. /**
  7650. * Update the current camera state depending on the inputs that have been used this frame.
  7651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7652. */
  7653. checkInputs: () => void;
  7654. /**
  7655. * Instantiate a new Camera Input Manager.
  7656. * @param camera Defines the camera the input manager blongs to
  7657. */
  7658. constructor(camera: TCamera);
  7659. /**
  7660. * Add an input method to a camera
  7661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7662. * @param input camera input method
  7663. */
  7664. add(input: ICameraInput<TCamera>): void;
  7665. /**
  7666. * Remove a specific input method from a camera
  7667. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7668. * @param inputToRemove camera input method
  7669. */
  7670. remove(inputToRemove: ICameraInput<TCamera>): void;
  7671. /**
  7672. * Remove a specific input type from a camera
  7673. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7674. * @param inputType the type of the input to remove
  7675. */
  7676. removeByType(inputType: string): void;
  7677. private _addCheckInputs;
  7678. /**
  7679. * Attach the input controls to the currently attached dom element to listen the events from.
  7680. * @param input Defines the input to attach
  7681. */
  7682. attachInput(input: ICameraInput<TCamera>): void;
  7683. /**
  7684. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7685. * @param element Defines the dom element to collect the events from
  7686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7687. */
  7688. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7689. /**
  7690. * Detach the current manager inputs controls from a specific dom element.
  7691. * @param element Defines the dom element to collect the events from
  7692. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7693. */
  7694. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7695. /**
  7696. * Rebuild the dynamic inputCheck function from the current list of
  7697. * defined inputs in the manager.
  7698. */
  7699. rebuildInputCheck(): void;
  7700. /**
  7701. * Remove all attached input methods from a camera
  7702. */
  7703. clear(): void;
  7704. /**
  7705. * Serialize the current input manager attached to a camera.
  7706. * This ensures than once parsed,
  7707. * the input associated to the camera will be identical to the current ones
  7708. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7709. */
  7710. serialize(serializedCamera: any): void;
  7711. /**
  7712. * Parses an input manager serialized JSON to restore the previous list of inputs
  7713. * and states associated to a camera.
  7714. * @param parsedCamera Defines the JSON to parse
  7715. */
  7716. parse(parsedCamera: any): void;
  7717. }
  7718. }
  7719. declare module BABYLON {
  7720. /**
  7721. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7722. * being tilted forward or back and left or right.
  7723. */
  7724. class DeviceOrientationCamera extends FreeCamera {
  7725. private _initialQuaternion;
  7726. private _quaternionCache;
  7727. /**
  7728. * Creates a new device orientation camera
  7729. * @param name The name of the camera
  7730. * @param position The start position camera
  7731. * @param scene The scene the camera belongs to
  7732. */
  7733. constructor(name: string, position: Vector3, scene: Scene);
  7734. /**
  7735. * Gets the current instance class name ("DeviceOrientationCamera").
  7736. * This helps avoiding instanceof at run time.
  7737. * @returns the class name
  7738. */
  7739. getClassName(): string;
  7740. /**
  7741. * @hidden
  7742. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7743. */
  7744. _checkInputs(): void;
  7745. /**
  7746. * Reset the camera to its default orientation on the specified axis only.
  7747. * @param axis The axis to reset
  7748. */
  7749. resetToCurrentRotation(axis?: Axis): void;
  7750. }
  7751. }
  7752. declare module BABYLON {
  7753. /**
  7754. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7755. * such as in a 3D Space Shooter or a Flight Simulator.
  7756. */
  7757. class FlyCamera extends TargetCamera {
  7758. /**
  7759. * Define the collision ellipsoid of the camera.
  7760. * This is helpful for simulating a camera body, like a player's body.
  7761. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7762. */
  7763. ellipsoid: Vector3;
  7764. /**
  7765. * Define an offset for the position of the ellipsoid around the camera.
  7766. * This can be helpful if the camera is attached away from the player's body center,
  7767. * such as at its head.
  7768. */
  7769. ellipsoidOffset: Vector3;
  7770. /**
  7771. * Enable or disable collisions of the camera with the rest of the scene objects.
  7772. */
  7773. checkCollisions: boolean;
  7774. /**
  7775. * Enable or disable gravity on the camera.
  7776. */
  7777. applyGravity: boolean;
  7778. /**
  7779. * Define the current direction the camera is moving to.
  7780. */
  7781. cameraDirection: Vector3;
  7782. /**
  7783. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7784. * This overrides and empties cameraRotation.
  7785. */
  7786. rotationQuaternion: BABYLON.Quaternion;
  7787. /**
  7788. * Track Roll to maintain the wanted Rolling when looking around.
  7789. */
  7790. _trackRoll: number;
  7791. /**
  7792. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7793. */
  7794. rollCorrect: number;
  7795. /**
  7796. * Mimic a banked turn, Rolling the camera when Yawing.
  7797. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7798. */
  7799. bankedTurn: boolean;
  7800. /**
  7801. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7802. */
  7803. bankedTurnLimit: number;
  7804. /**
  7805. * Value of 0 disables the banked Roll.
  7806. * Value of 1 is equal to the Yaw angle in radians.
  7807. */
  7808. bankedTurnMultiplier: number;
  7809. /**
  7810. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7811. */
  7812. inputs: FlyCameraInputsManager;
  7813. /**
  7814. * Gets the input sensibility for mouse input.
  7815. * Higher values reduce sensitivity.
  7816. */
  7817. /**
  7818. * Sets the input sensibility for a mouse input.
  7819. * Higher values reduce sensitivity.
  7820. */
  7821. angularSensibility: number;
  7822. /**
  7823. * Get the keys for camera movement forward.
  7824. */
  7825. /**
  7826. * Set the keys for camera movement forward.
  7827. */
  7828. keysForward: number[];
  7829. /**
  7830. * Get the keys for camera movement backward.
  7831. */
  7832. keysBackward: number[];
  7833. /**
  7834. * Get the keys for camera movement up.
  7835. */
  7836. /**
  7837. * Set the keys for camera movement up.
  7838. */
  7839. keysUp: number[];
  7840. /**
  7841. * Get the keys for camera movement down.
  7842. */
  7843. /**
  7844. * Set the keys for camera movement down.
  7845. */
  7846. keysDown: number[];
  7847. /**
  7848. * Get the keys for camera movement left.
  7849. */
  7850. /**
  7851. * Set the keys for camera movement left.
  7852. */
  7853. keysLeft: number[];
  7854. /**
  7855. * Set the keys for camera movement right.
  7856. */
  7857. /**
  7858. * Set the keys for camera movement right.
  7859. */
  7860. keysRight: number[];
  7861. /**
  7862. * Event raised when the camera collides with a mesh in the scene.
  7863. */
  7864. onCollide: (collidedMesh: AbstractMesh) => void;
  7865. private _collider;
  7866. private _needMoveForGravity;
  7867. private _oldPosition;
  7868. private _diffPosition;
  7869. private _newPosition;
  7870. /** @hidden */
  7871. _localDirection: Vector3;
  7872. /** @hidden */
  7873. _transformedDirection: Vector3;
  7874. /**
  7875. * Instantiates a FlyCamera.
  7876. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7877. * such as in a 3D Space Shooter or a Flight Simulator.
  7878. * @param name Define the name of the camera in the scene.
  7879. * @param position Define the starting position of the camera in the scene.
  7880. * @param scene Define the scene the camera belongs to.
  7881. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7882. */
  7883. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7884. /**
  7885. * Attach a control to the HTML DOM element.
  7886. * @param element Defines the element that listens to the input events.
  7887. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7888. */
  7889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7890. /**
  7891. * Detach a control from the HTML DOM element.
  7892. * The camera will stop reacting to that input.
  7893. * @param element Defines the element that listens to the input events.
  7894. */
  7895. detachControl(element: HTMLElement): void;
  7896. private _collisionMask;
  7897. /**
  7898. * Get the mask that the camera ignores in collision events.
  7899. */
  7900. /**
  7901. * Set the mask that the camera ignores in collision events.
  7902. */
  7903. collisionMask: number;
  7904. /** @hidden */
  7905. _collideWithWorld(displacement: Vector3): void;
  7906. /** @hidden */
  7907. private _onCollisionPositionChange;
  7908. /** @hidden */
  7909. _checkInputs(): void;
  7910. /** @hidden */
  7911. _decideIfNeedsToMove(): boolean;
  7912. /** @hidden */
  7913. _updatePosition(): void;
  7914. /**
  7915. * Restore the Roll to its target value at the rate specified.
  7916. * @param rate - Higher means slower restoring.
  7917. * @hidden
  7918. */
  7919. restoreRoll(rate: number): void;
  7920. /**
  7921. * Destroy the camera and release the current resources held by it.
  7922. */
  7923. dispose(): void;
  7924. /**
  7925. * Get the current object class name.
  7926. * @returns the class name.
  7927. */
  7928. getClassName(): string;
  7929. }
  7930. }
  7931. declare module BABYLON {
  7932. /**
  7933. * Default Inputs manager for the FlyCamera.
  7934. * It groups all the default supported inputs for ease of use.
  7935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7936. */
  7937. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  7938. /**
  7939. * Instantiates a new FlyCameraInputsManager.
  7940. * @param camera Defines the camera the inputs belong to.
  7941. */
  7942. constructor(camera: FlyCamera);
  7943. /**
  7944. * Add keyboard input support to the input manager.
  7945. * @returns the new FlyCameraKeyboardMoveInput().
  7946. */
  7947. addKeyboard(): FlyCameraInputsManager;
  7948. /**
  7949. * Add mouse input support to the input manager.
  7950. * @param touchEnabled Enable touch screen support.
  7951. * @returns the new FlyCameraMouseInput().
  7952. */
  7953. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  7954. }
  7955. }
  7956. declare module BABYLON {
  7957. /**
  7958. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7959. * an arc rotate version arcFollowCamera are available.
  7960. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7961. */
  7962. class FollowCamera extends TargetCamera {
  7963. /**
  7964. * Distance the follow camera should follow an object at
  7965. */
  7966. radius: number;
  7967. /**
  7968. * Define a rotation offset between the camera and the object it follows
  7969. */
  7970. rotationOffset: number;
  7971. /**
  7972. * Define a height offset between the camera and the object it follows.
  7973. * It can help following an object from the top (like a car chaing a plane)
  7974. */
  7975. heightOffset: number;
  7976. /**
  7977. * Define how fast the camera can accelerate to follow it s target.
  7978. */
  7979. cameraAcceleration: number;
  7980. /**
  7981. * Define the speed limit of the camera following an object.
  7982. */
  7983. maxCameraSpeed: number;
  7984. /**
  7985. * Define the target of the camera.
  7986. */
  7987. lockedTarget: Nullable<AbstractMesh>;
  7988. /**
  7989. * Instantiates the follow camera.
  7990. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7991. * @param name Define the name of the camera in the scene
  7992. * @param position Define the position of the camera
  7993. * @param scene Define the scene the camera belong to
  7994. * @param lockedTarget Define the target of the camera
  7995. */
  7996. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7997. private _follow;
  7998. /** @hidden */
  7999. _checkInputs(): void;
  8000. /**
  8001. * Gets the camera class name.
  8002. * @returns the class name
  8003. */
  8004. getClassName(): string;
  8005. }
  8006. /**
  8007. * Arc Rotate version of the follow camera.
  8008. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8009. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8010. */
  8011. class ArcFollowCamera extends TargetCamera {
  8012. /** The longitudinal angle of the camera */
  8013. alpha: number;
  8014. /** The latitudinal angle of the camera */
  8015. beta: number;
  8016. /** The radius of the camera from its target */
  8017. radius: number;
  8018. /** Define the camera target (the messh it should follow) */
  8019. target: Nullable<AbstractMesh>;
  8020. private _cartesianCoordinates;
  8021. /**
  8022. * Instantiates a new ArcFollowCamera
  8023. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8024. * @param name Define the name of the camera
  8025. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8026. * @param beta Define the rotation angle of the camera around the elevation axis
  8027. * @param radius Define the radius of the camera from its target point
  8028. * @param target Define the target of the camera
  8029. * @param scene Define the scene the camera belongs to
  8030. */
  8031. constructor(name: string,
  8032. /** The longitudinal angle of the camera */
  8033. alpha: number,
  8034. /** The latitudinal angle of the camera */
  8035. beta: number,
  8036. /** The radius of the camera from its target */
  8037. radius: number,
  8038. /** Define the camera target (the messh it should follow) */
  8039. target: Nullable<AbstractMesh>, scene: Scene);
  8040. private _follow;
  8041. /** @hidden */
  8042. _checkInputs(): void;
  8043. /**
  8044. * Returns the class name of the object.
  8045. * It is mostly used internally for serialization purposes.
  8046. */
  8047. getClassName(): string;
  8048. }
  8049. }
  8050. declare module BABYLON {
  8051. /**
  8052. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8053. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8054. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8055. */
  8056. class FreeCamera extends TargetCamera {
  8057. /**
  8058. * Define the collision ellipsoid of the camera.
  8059. * This is helpful to simulate a camera body like the player body around the camera
  8060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8061. */
  8062. ellipsoid: Vector3;
  8063. /**
  8064. * Define an offset for the position of the ellipsoid around the camera.
  8065. * This can be helpful to determine the center of the body near the gravity center of the body
  8066. * instead of its head.
  8067. */
  8068. ellipsoidOffset: Vector3;
  8069. /**
  8070. * Enable or disable collisions of the camera with the rest of the scene objects.
  8071. */
  8072. checkCollisions: boolean;
  8073. /**
  8074. * Enable or disable gravity on the camera.
  8075. */
  8076. applyGravity: boolean;
  8077. /**
  8078. * Define the input manager associated to the camera.
  8079. */
  8080. inputs: FreeCameraInputsManager;
  8081. /**
  8082. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8083. * Higher values reduce sensitivity.
  8084. */
  8085. /**
  8086. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8087. * Higher values reduce sensitivity.
  8088. */
  8089. angularSensibility: number;
  8090. /**
  8091. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8092. */
  8093. keysUp: number[];
  8094. /**
  8095. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8096. */
  8097. keysDown: number[];
  8098. /**
  8099. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8100. */
  8101. keysLeft: number[];
  8102. /**
  8103. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8104. */
  8105. keysRight: number[];
  8106. /**
  8107. * Event raised when the camera collide with a mesh in the scene.
  8108. */
  8109. onCollide: (collidedMesh: AbstractMesh) => void;
  8110. private _collider;
  8111. private _needMoveForGravity;
  8112. private _oldPosition;
  8113. private _diffPosition;
  8114. private _newPosition;
  8115. /** @hidden */
  8116. _localDirection: Vector3;
  8117. /** @hidden */
  8118. _transformedDirection: Vector3;
  8119. /**
  8120. * Instantiates a Free Camera.
  8121. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8122. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8123. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8124. * @param name Define the name of the camera in the scene
  8125. * @param position Define the start position of the camera in the scene
  8126. * @param scene Define the scene the camera belongs to
  8127. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8128. */
  8129. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8130. /**
  8131. * Attached controls to the current camera.
  8132. * @param element Defines the element the controls should be listened from
  8133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8134. */
  8135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8136. /**
  8137. * Detach the current controls from the camera.
  8138. * The camera will stop reacting to inputs.
  8139. * @param element Defines the element to stop listening the inputs from
  8140. */
  8141. detachControl(element: HTMLElement): void;
  8142. private _collisionMask;
  8143. /**
  8144. * Define a collision mask to limit the list of object the camera can collide with
  8145. */
  8146. collisionMask: number;
  8147. /** @hidden */
  8148. _collideWithWorld(displacement: Vector3): void;
  8149. private _onCollisionPositionChange;
  8150. /** @hidden */
  8151. _checkInputs(): void;
  8152. /** @hidden */
  8153. _decideIfNeedsToMove(): boolean;
  8154. /** @hidden */
  8155. _updatePosition(): void;
  8156. /**
  8157. * Destroy the camera and release the current resources hold by it.
  8158. */
  8159. dispose(): void;
  8160. /**
  8161. * Gets the current object class name.
  8162. * @return the class name
  8163. */
  8164. getClassName(): string;
  8165. }
  8166. }
  8167. declare module BABYLON {
  8168. /**
  8169. * Default Inputs manager for the FreeCamera.
  8170. * It groups all the default supported inputs for ease of use.
  8171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8172. */
  8173. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8174. /**
  8175. * Instantiates a new FreeCameraInputsManager.
  8176. * @param camera Defines the camera the inputs belong to
  8177. */
  8178. constructor(camera: FreeCamera);
  8179. /**
  8180. * Add keyboard input support to the input manager.
  8181. * @returns the current input manager
  8182. */
  8183. addKeyboard(): FreeCameraInputsManager;
  8184. /**
  8185. * Add mouse input support to the input manager.
  8186. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8187. * @returns the current input manager
  8188. */
  8189. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8190. /**
  8191. * Add orientation input support to the input manager.
  8192. * @returns the current input manager
  8193. */
  8194. addDeviceOrientation(): FreeCameraInputsManager;
  8195. /**
  8196. * Add touch input support to the input manager.
  8197. * @returns the current input manager
  8198. */
  8199. addTouch(): FreeCameraInputsManager;
  8200. /**
  8201. * Add virtual joystick input support to the input manager.
  8202. * @returns the current input manager
  8203. */
  8204. addVirtualJoystick(): FreeCameraInputsManager;
  8205. }
  8206. }
  8207. declare module BABYLON {
  8208. /**
  8209. * This represents a FPS type of camera. This is only here for back compat purpose.
  8210. * Please use the UniversalCamera instead as both are identical.
  8211. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8212. */
  8213. class GamepadCamera extends UniversalCamera {
  8214. /**
  8215. * Instantiates a new Gamepad Camera
  8216. * This represents a FPS type of camera. This is only here for back compat purpose.
  8217. * Please use the UniversalCamera instead as both are identical.
  8218. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8219. * @param name Define the name of the camera in the scene
  8220. * @param position Define the start position of the camera in the scene
  8221. * @param scene Define the scene the camera belongs to
  8222. */
  8223. constructor(name: string, position: Vector3, scene: Scene);
  8224. /**
  8225. * Gets the current object class name.
  8226. * @return the class name
  8227. */
  8228. getClassName(): string;
  8229. }
  8230. }
  8231. declare module BABYLON {
  8232. /**
  8233. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8234. * This is the base of the follow, arc rotate cameras and Free camera
  8235. * @see http://doc.babylonjs.com/features/cameras
  8236. */
  8237. class TargetCamera extends Camera {
  8238. /**
  8239. * Define the current direction the camera is moving to
  8240. */
  8241. cameraDirection: Vector3;
  8242. /**
  8243. * Define the current rotation the camera is rotating to
  8244. */
  8245. cameraRotation: Vector2;
  8246. /**
  8247. * When set, the up vector of the camera will be updated by the rotation of the camera
  8248. */
  8249. updateUpVectorFromRotation: boolean;
  8250. private _tmpQuaternion;
  8251. /**
  8252. * Define the current rotation of the camera
  8253. */
  8254. rotation: Vector3;
  8255. /**
  8256. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8257. */
  8258. rotationQuaternion: Quaternion;
  8259. /**
  8260. * Define the current speed of the camera
  8261. */
  8262. speed: number;
  8263. /**
  8264. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8265. * around all axis.
  8266. */
  8267. noRotationConstraint: boolean;
  8268. /**
  8269. * Define the current target of the camera as an object or a position.
  8270. */
  8271. lockedTarget: any;
  8272. /** @hidden */
  8273. _currentTarget: Vector3;
  8274. /** @hidden */
  8275. _viewMatrix: Matrix;
  8276. /** @hidden */
  8277. _camMatrix: Matrix;
  8278. /** @hidden */
  8279. _cameraTransformMatrix: Matrix;
  8280. /** @hidden */
  8281. _cameraRotationMatrix: Matrix;
  8282. private _rigCamTransformMatrix;
  8283. /** @hidden */
  8284. _referencePoint: Vector3;
  8285. /** @hidden */
  8286. _transformedReferencePoint: Vector3;
  8287. protected _globalCurrentTarget: Vector3;
  8288. protected _globalCurrentUpVector: Vector3;
  8289. /** @hidden */
  8290. _reset: () => void;
  8291. private _defaultUp;
  8292. /**
  8293. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8294. * This is the base of the follow, arc rotate cameras and Free camera
  8295. * @see http://doc.babylonjs.com/features/cameras
  8296. * @param name Defines the name of the camera in the scene
  8297. * @param position Defines the start position of the camera in the scene
  8298. * @param scene Defines the scene the camera belongs to
  8299. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8300. */
  8301. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8302. /**
  8303. * Gets the position in front of the camera at a given distance.
  8304. * @param distance The distance from the camera we want the position to be
  8305. * @returns the position
  8306. */
  8307. getFrontPosition(distance: number): Vector3;
  8308. /** @hidden */
  8309. _getLockedTargetPosition(): Nullable<Vector3>;
  8310. private _storedPosition;
  8311. private _storedRotation;
  8312. private _storedRotationQuaternion;
  8313. /**
  8314. * Store current camera state of the camera (fov, position, rotation, etc..)
  8315. * @returns the camera
  8316. */
  8317. storeState(): Camera;
  8318. /**
  8319. * Restored camera state. You must call storeState() first
  8320. * @returns whether it was successful or not
  8321. * @hidden
  8322. */
  8323. _restoreStateValues(): boolean;
  8324. /** @hidden */
  8325. _initCache(): void;
  8326. /** @hidden */
  8327. _updateCache(ignoreParentClass?: boolean): void;
  8328. /** @hidden */
  8329. _isSynchronizedViewMatrix(): boolean;
  8330. /** @hidden */
  8331. _computeLocalCameraSpeed(): number;
  8332. /** @hidden */
  8333. setTarget(target: Vector3): void;
  8334. /**
  8335. * Return the current target position of the camera. This value is expressed in local space.
  8336. * @returns the target position
  8337. */
  8338. getTarget(): Vector3;
  8339. /** @hidden */
  8340. _decideIfNeedsToMove(): boolean;
  8341. /** @hidden */
  8342. _updatePosition(): void;
  8343. /** @hidden */
  8344. _checkInputs(): void;
  8345. protected _updateCameraRotationMatrix(): void;
  8346. /**
  8347. * 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)
  8348. * @returns the current camera
  8349. */
  8350. private _rotateUpVectorWithCameraRotationMatrix;
  8351. private _cachedRotationZ;
  8352. private _cachedQuaternionRotationZ;
  8353. /** @hidden */
  8354. _getViewMatrix(): Matrix;
  8355. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8356. /**
  8357. * @hidden
  8358. */
  8359. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8360. /**
  8361. * @hidden
  8362. */
  8363. _updateRigCameras(): void;
  8364. private _getRigCamPosition;
  8365. /**
  8366. * Gets the current object class name.
  8367. * @return the class name
  8368. */
  8369. getClassName(): string;
  8370. }
  8371. }
  8372. declare module BABYLON {
  8373. /**
  8374. * This represents a FPS type of camera controlled by touch.
  8375. * This is like a universal camera minus the Gamepad controls.
  8376. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8377. */
  8378. class TouchCamera extends FreeCamera {
  8379. /**
  8380. * Defines the touch sensibility for rotation.
  8381. * The higher the faster.
  8382. */
  8383. touchAngularSensibility: number;
  8384. /**
  8385. * Defines the touch sensibility for move.
  8386. * The higher the faster.
  8387. */
  8388. touchMoveSensibility: number;
  8389. /**
  8390. * Instantiates a new touch camera.
  8391. * This represents a FPS type of camera controlled by touch.
  8392. * This is like a universal camera minus the Gamepad controls.
  8393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8394. * @param name Define the name of the camera in the scene
  8395. * @param position Define the start position of the camera in the scene
  8396. * @param scene Define the scene the camera belongs to
  8397. */
  8398. constructor(name: string, position: Vector3, scene: Scene);
  8399. /**
  8400. * Gets the current object class name.
  8401. * @return the class name
  8402. */
  8403. getClassName(): string;
  8404. /** @hidden */
  8405. _setupInputs(): void;
  8406. }
  8407. }
  8408. declare module BABYLON {
  8409. /**
  8410. * 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,
  8411. * which still works and will still be found in many Playgrounds.
  8412. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8413. */
  8414. class UniversalCamera extends TouchCamera {
  8415. /**
  8416. * Defines the gamepad rotation sensiblity.
  8417. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8418. */
  8419. gamepadAngularSensibility: number;
  8420. /**
  8421. * Defines the gamepad move sensiblity.
  8422. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8423. */
  8424. gamepadMoveSensibility: number;
  8425. /**
  8426. * 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,
  8427. * which still works and will still be found in many Playgrounds.
  8428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8429. * @param name Define the name of the camera in the scene
  8430. * @param position Define the start position of the camera in the scene
  8431. * @param scene Define the scene the camera belongs to
  8432. */
  8433. constructor(name: string, position: Vector3, scene: Scene);
  8434. /**
  8435. * Gets the current object class name.
  8436. * @return the class name
  8437. */
  8438. getClassName(): string;
  8439. }
  8440. }
  8441. declare module BABYLON {
  8442. /**
  8443. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8444. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8445. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8446. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8447. */
  8448. class VirtualJoysticksCamera extends FreeCamera {
  8449. /**
  8450. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8451. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8452. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8453. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8454. * @param name Define the name of the camera in the scene
  8455. * @param position Define the start position of the camera in the scene
  8456. * @param scene Define the scene the camera belongs to
  8457. */
  8458. constructor(name: string, position: Vector3, scene: Scene);
  8459. /**
  8460. * Gets the current object class name.
  8461. * @return the class name
  8462. */
  8463. getClassName(): string;
  8464. }
  8465. }
  8466. interface VRDisplay extends EventTarget {
  8467. /**
  8468. * Dictionary of capabilities describing the VRDisplay.
  8469. */
  8470. readonly capabilities: VRDisplayCapabilities;
  8471. /**
  8472. * z-depth defining the far plane of the eye view frustum
  8473. * enables mapping of values in the render target depth
  8474. * attachment to scene coordinates. Initially set to 10000.0.
  8475. */
  8476. depthFar: number;
  8477. /**
  8478. * z-depth defining the near plane of the eye view frustum
  8479. * enables mapping of values in the render target depth
  8480. * attachment to scene coordinates. Initially set to 0.01.
  8481. */
  8482. depthNear: number;
  8483. /**
  8484. * An identifier for this distinct VRDisplay. Used as an
  8485. * association point in the Gamepad API.
  8486. */
  8487. readonly displayId: number;
  8488. /**
  8489. * A display name, a user-readable name identifying it.
  8490. */
  8491. readonly displayName: string;
  8492. readonly isConnected: boolean;
  8493. readonly isPresenting: boolean;
  8494. /**
  8495. * If this VRDisplay supports room-scale experiences, the optional
  8496. * stage attribute contains details on the room-scale parameters.
  8497. */
  8498. readonly stageParameters: VRStageParameters | null;
  8499. /**
  8500. * Passing the value returned by `requestAnimationFrame` to
  8501. * `cancelAnimationFrame` will unregister the callback.
  8502. * @param handle Define the hanle of the request to cancel
  8503. */
  8504. cancelAnimationFrame(handle: number): void;
  8505. /**
  8506. * Stops presenting to the VRDisplay.
  8507. * @returns a promise to know when it stopped
  8508. */
  8509. exitPresent(): Promise<void>;
  8510. /**
  8511. * Return the current VREyeParameters for the given eye.
  8512. * @param whichEye Define the eye we want the parameter for
  8513. * @returns the eye parameters
  8514. */
  8515. getEyeParameters(whichEye: string): VREyeParameters;
  8516. /**
  8517. * Populates the passed VRFrameData with the information required to render
  8518. * the current frame.
  8519. * @param frameData Define the data structure to populate
  8520. * @returns true if ok otherwise false
  8521. */
  8522. getFrameData(frameData: VRFrameData): boolean;
  8523. /**
  8524. * Get the layers currently being presented.
  8525. * @returns the list of VR layers
  8526. */
  8527. getLayers(): VRLayer[];
  8528. /**
  8529. * Return a VRPose containing the future predicted pose of the VRDisplay
  8530. * when the current frame will be presented. The value returned will not
  8531. * change until JavaScript has returned control to the browser.
  8532. *
  8533. * The VRPose will contain the position, orientation, velocity,
  8534. * and acceleration of each of these properties.
  8535. * @returns the pose object
  8536. */
  8537. getPose(): VRPose;
  8538. /**
  8539. * Return the current instantaneous pose of the VRDisplay, with no
  8540. * prediction applied.
  8541. * @returns the current instantaneous pose
  8542. */
  8543. getImmediatePose(): VRPose;
  8544. /**
  8545. * The callback passed to `requestAnimationFrame` will be called
  8546. * any time a new frame should be rendered. When the VRDisplay is
  8547. * presenting the callback will be called at the native refresh
  8548. * rate of the HMD. When not presenting this function acts
  8549. * identically to how window.requestAnimationFrame acts. Content should
  8550. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8551. * asynchronously from other displays and at differing refresh rates.
  8552. * @param callback Define the eaction to run next frame
  8553. * @returns the request handle it
  8554. */
  8555. requestAnimationFrame(callback: FrameRequestCallback): number;
  8556. /**
  8557. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8558. * Repeat calls while already presenting will update the VRLayers being displayed.
  8559. * @param layers Define the list of layer to present
  8560. * @returns a promise to know when the request has been fulfilled
  8561. */
  8562. requestPresent(layers: VRLayer[]): Promise<void>;
  8563. /**
  8564. * Reset the pose for this display, treating its current position and
  8565. * orientation as the "origin/zero" values. VRPose.position,
  8566. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8567. * updated when calling resetPose(). This should be called in only
  8568. * sitting-space experiences.
  8569. */
  8570. resetPose(): void;
  8571. /**
  8572. * The VRLayer provided to the VRDisplay will be captured and presented
  8573. * in the HMD. Calling this function has the same effect on the source
  8574. * canvas as any other operation that uses its source image, and canvases
  8575. * created without preserveDrawingBuffer set to true will be cleared.
  8576. * @param pose Define the pose to submit
  8577. */
  8578. submitFrame(pose?: VRPose): void;
  8579. }
  8580. declare var VRDisplay: {
  8581. prototype: VRDisplay;
  8582. new (): VRDisplay;
  8583. };
  8584. interface VRLayer {
  8585. leftBounds?: number[] | Float32Array | null;
  8586. rightBounds?: number[] | Float32Array | null;
  8587. source?: HTMLCanvasElement | null;
  8588. }
  8589. interface VRDisplayCapabilities {
  8590. readonly canPresent: boolean;
  8591. readonly hasExternalDisplay: boolean;
  8592. readonly hasOrientation: boolean;
  8593. readonly hasPosition: boolean;
  8594. readonly maxLayers: number;
  8595. }
  8596. interface VREyeParameters {
  8597. /** @deprecated */
  8598. readonly fieldOfView: VRFieldOfView;
  8599. readonly offset: Float32Array;
  8600. readonly renderHeight: number;
  8601. readonly renderWidth: number;
  8602. }
  8603. interface VRFieldOfView {
  8604. readonly downDegrees: number;
  8605. readonly leftDegrees: number;
  8606. readonly rightDegrees: number;
  8607. readonly upDegrees: number;
  8608. }
  8609. interface VRFrameData {
  8610. readonly leftProjectionMatrix: Float32Array;
  8611. readonly leftViewMatrix: Float32Array;
  8612. readonly pose: VRPose;
  8613. readonly rightProjectionMatrix: Float32Array;
  8614. readonly rightViewMatrix: Float32Array;
  8615. readonly timestamp: number;
  8616. }
  8617. interface VRPose {
  8618. readonly angularAcceleration: Float32Array | null;
  8619. readonly angularVelocity: Float32Array | null;
  8620. readonly linearAcceleration: Float32Array | null;
  8621. readonly linearVelocity: Float32Array | null;
  8622. readonly orientation: Float32Array | null;
  8623. readonly position: Float32Array | null;
  8624. readonly timestamp: number;
  8625. }
  8626. interface VRStageParameters {
  8627. sittingToStandingTransform?: Float32Array;
  8628. sizeX?: number;
  8629. sizeY?: number;
  8630. }
  8631. interface Navigator {
  8632. getVRDisplays(): Promise<VRDisplay[]>;
  8633. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8634. }
  8635. interface Window {
  8636. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8637. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8638. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8639. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8640. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8641. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8642. }
  8643. interface Gamepad {
  8644. readonly displayId: number;
  8645. }
  8646. /**
  8647. * Module Debug contains the (visual) components to debug a scene correctly
  8648. */
  8649. declare module BABYLON.Debug {
  8650. /**
  8651. * The Axes viewer will show 3 axes in a specific point in space
  8652. */
  8653. class AxesViewer {
  8654. private _xline;
  8655. private _yline;
  8656. private _zline;
  8657. private _xmesh;
  8658. private _ymesh;
  8659. private _zmesh;
  8660. /**
  8661. * Gets the hosting scene
  8662. */
  8663. scene: Nullable<Scene>;
  8664. /**
  8665. * Gets or sets a number used to scale line length
  8666. */
  8667. scaleLines: number;
  8668. /**
  8669. * Creates a new AxesViewer
  8670. * @param scene defines the hosting scene
  8671. * @param scaleLines defines a number used to scale line length (1 by default)
  8672. */
  8673. constructor(scene: Scene, scaleLines?: number);
  8674. /**
  8675. * Force the viewer to update
  8676. * @param position defines the position of the viewer
  8677. * @param xaxis defines the x axis of the viewer
  8678. * @param yaxis defines the y axis of the viewer
  8679. * @param zaxis defines the z axis of the viewer
  8680. */
  8681. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8682. /** Releases resources */
  8683. dispose(): void;
  8684. }
  8685. }
  8686. declare module BABYLON.Debug {
  8687. /**
  8688. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8689. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8690. */
  8691. class BoneAxesViewer extends AxesViewer {
  8692. /**
  8693. * Gets or sets the target mesh where to display the axes viewer
  8694. */
  8695. mesh: Nullable<Mesh>;
  8696. /**
  8697. * Gets or sets the target bone where to display the axes viewer
  8698. */
  8699. bone: Nullable<Bone>;
  8700. /** Gets current position */
  8701. pos: Vector3;
  8702. /** Gets direction of X axis */
  8703. xaxis: Vector3;
  8704. /** Gets direction of Y axis */
  8705. yaxis: Vector3;
  8706. /** Gets direction of Z axis */
  8707. zaxis: Vector3;
  8708. /**
  8709. * Creates a new BoneAxesViewer
  8710. * @param scene defines the hosting scene
  8711. * @param bone defines the target bone
  8712. * @param mesh defines the target mesh
  8713. * @param scaleLines defines a scaling factor for line length (1 by default)
  8714. */
  8715. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8716. /**
  8717. * Force the viewer to update
  8718. */
  8719. update(): void;
  8720. /** Releases resources */
  8721. dispose(): void;
  8722. }
  8723. }
  8724. declare module BABYLON {
  8725. interface Scene {
  8726. /**
  8727. * @hidden
  8728. * Backing field
  8729. */
  8730. _debugLayer: DebugLayer;
  8731. /**
  8732. * Gets the debug layer (aka Inspector) associated with the scene
  8733. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8734. */
  8735. debugLayer: DebugLayer;
  8736. }
  8737. /**
  8738. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8739. * what is happening in your scene
  8740. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8741. */
  8742. class DebugLayer {
  8743. /**
  8744. * Define the url to get the inspector script from.
  8745. * By default it uses the babylonjs CDN.
  8746. * @ignoreNaming
  8747. */
  8748. static InspectorURL: string;
  8749. private _scene;
  8750. private _inspector;
  8751. private BJSINSPECTOR;
  8752. /**
  8753. * Observable triggered when a property is changed through the inspector.
  8754. */
  8755. onPropertyChangedObservable: Observable<{
  8756. object: any;
  8757. property: string;
  8758. value: any;
  8759. initialValue: any;
  8760. }>;
  8761. /**
  8762. * Instantiates a new debug layer.
  8763. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8764. * what is happening in your scene
  8765. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8766. * @param scene Defines the scene to inspect
  8767. */
  8768. constructor(scene: Scene);
  8769. /** Creates the inspector window. */
  8770. private _createInspector;
  8771. /**
  8772. * Get if the inspector is visible or not.
  8773. * @returns true if visible otherwise, false
  8774. */
  8775. isVisible(): boolean;
  8776. /**
  8777. * Hide the inspector and close its window.
  8778. */
  8779. hide(): void;
  8780. /**
  8781. *
  8782. * Launch the debugLayer.
  8783. *
  8784. * initialTab:
  8785. * | Value | Tab Name |
  8786. * | --- | --- |
  8787. * | 0 | Scene |
  8788. * | 1 | Console |
  8789. * | 2 | Stats |
  8790. * | 3 | Textures |
  8791. * | 4 | Mesh |
  8792. * | 5 | Light |
  8793. * | 6 | Material |
  8794. * | 7 | GLTF |
  8795. * | 8 | GUI |
  8796. * | 9 | Physics |
  8797. * | 10 | Camera |
  8798. * | 11 | Audio |
  8799. *
  8800. * @param config Define the configuration of the inspector
  8801. */
  8802. show(config?: {
  8803. popup?: boolean;
  8804. initialTab?: number | string;
  8805. parentElement?: HTMLElement;
  8806. newColors?: {
  8807. backgroundColor?: string;
  8808. backgroundColorLighter?: string;
  8809. backgroundColorLighter2?: string;
  8810. backgroundColorLighter3?: string;
  8811. color?: string;
  8812. colorTop?: string;
  8813. colorBot?: string;
  8814. };
  8815. }): void;
  8816. /**
  8817. * Gets the active tab
  8818. * @return the index of the active tab or -1 if the inspector is hidden
  8819. */
  8820. getActiveTab(): number;
  8821. }
  8822. }
  8823. declare module BABYLON.Debug {
  8824. /**
  8825. * Used to show the physics impostor around the specific mesh
  8826. */
  8827. class PhysicsViewer {
  8828. /** @hidden */
  8829. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  8830. /** @hidden */
  8831. protected _meshes: Array<Nullable<AbstractMesh>>;
  8832. /** @hidden */
  8833. protected _scene: Nullable<Scene>;
  8834. /** @hidden */
  8835. protected _numMeshes: number;
  8836. /** @hidden */
  8837. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  8838. private _renderFunction;
  8839. private _debugBoxMesh;
  8840. private _debugSphereMesh;
  8841. private _debugMaterial;
  8842. /**
  8843. * Creates a new PhysicsViewer
  8844. * @param scene defines the hosting scene
  8845. */
  8846. constructor(scene: Scene);
  8847. /** @hidden */
  8848. protected _updateDebugMeshes(): void;
  8849. /**
  8850. * Renders a specified physic impostor
  8851. * @param impostor defines the impostor to render
  8852. */
  8853. showImpostor(impostor: PhysicsImpostor): void;
  8854. /**
  8855. * Hides a specified physic impostor
  8856. * @param impostor defines the impostor to hide
  8857. */
  8858. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  8859. private _getDebugMaterial;
  8860. private _getDebugBoxMesh;
  8861. private _getDebugSphereMesh;
  8862. private _getDebugMesh;
  8863. /** Releases all resources */
  8864. dispose(): void;
  8865. }
  8866. }
  8867. declare module BABYLON {
  8868. /**
  8869. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8870. * in order to better appreciate the issue one might have.
  8871. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8872. */
  8873. class RayHelper {
  8874. /**
  8875. * Defines the ray we are currently tryin to visualize.
  8876. */
  8877. ray: Nullable<Ray>;
  8878. private _renderPoints;
  8879. private _renderLine;
  8880. private _renderFunction;
  8881. private _scene;
  8882. private _updateToMeshFunction;
  8883. private _attachedToMesh;
  8884. private _meshSpaceDirection;
  8885. private _meshSpaceOrigin;
  8886. /**
  8887. * Helper function to create a colored helper in a scene in one line.
  8888. * @param ray Defines the ray we are currently tryin to visualize
  8889. * @param scene Defines the scene the ray is used in
  8890. * @param color Defines the color we want to see the ray in
  8891. * @returns The newly created ray helper.
  8892. */
  8893. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  8894. /**
  8895. * Instantiate a new ray helper.
  8896. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8897. * in order to better appreciate the issue one might have.
  8898. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8899. * @param ray Defines the ray we are currently tryin to visualize
  8900. */
  8901. constructor(ray: Ray);
  8902. /**
  8903. * Shows the ray we are willing to debug.
  8904. * @param scene Defines the scene the ray needs to be rendered in
  8905. * @param color Defines the color the ray needs to be rendered in
  8906. */
  8907. show(scene: Scene, color?: Color3): void;
  8908. /**
  8909. * Hides the ray we are debugging.
  8910. */
  8911. hide(): void;
  8912. private _render;
  8913. /**
  8914. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  8915. * @param mesh Defines the mesh we want the helper attached to
  8916. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  8917. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  8918. * @param length Defines the length of the ray
  8919. */
  8920. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  8921. /**
  8922. * Detach the ray helper from the mesh it has previously been attached to.
  8923. */
  8924. detachFromMesh(): void;
  8925. private _updateToMesh;
  8926. /**
  8927. * Dispose the helper and release its associated resources.
  8928. */
  8929. dispose(): void;
  8930. }
  8931. }
  8932. declare module BABYLON.Debug {
  8933. /**
  8934. * Class used to render a debug view of a given skeleton
  8935. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  8936. */
  8937. class SkeletonViewer {
  8938. /** defines the skeleton to render */
  8939. skeleton: Skeleton;
  8940. /** defines the mesh attached to the skeleton */
  8941. mesh: AbstractMesh;
  8942. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8943. autoUpdateBonesMatrices: boolean;
  8944. /** defines the rendering group id to use with the viewer */
  8945. renderingGroupId: number;
  8946. /** defines an optional utility layer to render the helper on */
  8947. utilityLayerRenderer?: UtilityLayerRenderer | undefined;
  8948. /** Gets or sets the color used to render the skeleton */
  8949. color: Color3;
  8950. private _scene;
  8951. private _debugLines;
  8952. private _debugMesh;
  8953. private _isEnabled;
  8954. private _renderFunction;
  8955. /**
  8956. * Returns the mesh used to render the bones
  8957. */
  8958. readonly debugMesh: Nullable<LinesMesh>;
  8959. /**
  8960. * Creates a new SkeletonViewer
  8961. * @param skeleton defines the skeleton to render
  8962. * @param mesh defines the mesh attached to the skeleton
  8963. * @param scene defines the hosting scene
  8964. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  8965. * @param renderingGroupId defines the rendering group id to use with the viewer
  8966. * @param utilityLayerRenderer defines an optional utility layer to render the helper on
  8967. */
  8968. constructor(
  8969. /** defines the skeleton to render */
  8970. skeleton: Skeleton,
  8971. /** defines the mesh attached to the skeleton */
  8972. mesh: AbstractMesh, scene: Scene,
  8973. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8974. autoUpdateBonesMatrices?: boolean,
  8975. /** defines the rendering group id to use with the viewer */
  8976. renderingGroupId?: number,
  8977. /** defines an optional utility layer to render the helper on */
  8978. utilityLayerRenderer?: UtilityLayerRenderer | undefined);
  8979. /** Gets or sets a boolean indicating if the viewer is enabled */
  8980. isEnabled: boolean;
  8981. private _getBonePosition;
  8982. private _getLinesForBonesWithLength;
  8983. private _getLinesForBonesNoLength;
  8984. /** Update the viewer to sync with current skeleton state */
  8985. update(): void;
  8986. /** Release associated resources */
  8987. dispose(): void;
  8988. }
  8989. }
  8990. declare module BABYLON {
  8991. /**
  8992. * Class used to store bounding box information
  8993. */
  8994. class BoundingBox implements ICullable {
  8995. /**
  8996. * Gets the 8 vectors representing the bounding box in local space
  8997. */
  8998. readonly vectors: Vector3[];
  8999. /**
  9000. * Gets the center of the bounding box in local space
  9001. */
  9002. readonly center: Vector3;
  9003. /**
  9004. * Gets the center of the bounding box in world space
  9005. */
  9006. readonly centerWorld: Vector3;
  9007. /**
  9008. * Gets the extend size in local space
  9009. */
  9010. readonly extendSize: Vector3;
  9011. /**
  9012. * Gets the extend size in world space
  9013. */
  9014. readonly extendSizeWorld: Vector3;
  9015. /**
  9016. * Gets the OBB (object bounding box) directions
  9017. */
  9018. readonly directions: Vector3[];
  9019. /**
  9020. * Gets the 8 vectors representing the bounding box in world space
  9021. */
  9022. readonly vectorsWorld: Vector3[];
  9023. /**
  9024. * Gets the minimum vector in world space
  9025. */
  9026. readonly minimumWorld: Vector3;
  9027. /**
  9028. * Gets the maximum vector in world space
  9029. */
  9030. readonly maximumWorld: Vector3;
  9031. /**
  9032. * Gets the minimum vector in local space
  9033. */
  9034. readonly minimum: Vector3;
  9035. /**
  9036. * Gets the maximum vector in local space
  9037. */
  9038. readonly maximum: Vector3;
  9039. private _worldMatrix;
  9040. private static readonly TmpVector3;
  9041. /**
  9042. * @hidden
  9043. */
  9044. _tag: number;
  9045. /**
  9046. * Creates a new bounding box
  9047. * @param min defines the minimum vector (in local space)
  9048. * @param max defines the maximum vector (in local space)
  9049. * @param worldMatrix defines the new world matrix
  9050. */
  9051. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  9052. /**
  9053. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9054. * @param min defines the new minimum vector (in local space)
  9055. * @param max defines the new maximum vector (in local space)
  9056. * @param worldMatrix defines the new world matrix
  9057. */
  9058. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  9059. /**
  9060. * Scale the current bounding box by applying a scale factor
  9061. * @param factor defines the scale factor to apply
  9062. * @returns the current bounding box
  9063. */
  9064. scale(factor: number): BoundingBox;
  9065. /**
  9066. * Gets the world matrix of the bounding box
  9067. * @returns a matrix
  9068. */
  9069. getWorldMatrix(): Readonly<Matrix>;
  9070. /** @hidden */
  9071. _update(world: Readonly<Matrix>): void;
  9072. /**
  9073. * Tests if the bounding box is intersecting the frustum planes
  9074. * @param frustumPlanes defines the frustum planes to test
  9075. * @returns true if there is an intersection
  9076. */
  9077. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9078. /**
  9079. * Tests if the bounding box is entirely inside the frustum planes
  9080. * @param frustumPlanes defines the frustum planes to test
  9081. * @returns true if there is an inclusion
  9082. */
  9083. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9084. /**
  9085. * Tests if a point is inside the bounding box
  9086. * @param point defines the point to test
  9087. * @returns true if the point is inside the bounding box
  9088. */
  9089. intersectsPoint(point: Readonly<Vector3>): boolean;
  9090. /**
  9091. * Tests if the bounding box intersects with a bounding sphere
  9092. * @param sphere defines the sphere to test
  9093. * @returns true if there is an intersection
  9094. */
  9095. intersectsSphere(sphere: Readonly<BoundingSphere>): boolean;
  9096. /**
  9097. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9098. * @param min defines the min vector to use
  9099. * @param max defines the max vector to use
  9100. * @returns true if there is an intersection
  9101. */
  9102. intersectsMinMax(min: Readonly<Vector3>, max: Readonly<Vector3>): boolean;
  9103. /**
  9104. * Tests if two bounding boxes are intersections
  9105. * @param box0 defines the first box to test
  9106. * @param box1 defines the second box to test
  9107. * @returns true if there is an intersection
  9108. */
  9109. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  9110. /**
  9111. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9112. * @param minPoint defines the minimum vector of the bounding box
  9113. * @param maxPoint defines the maximum vector of the bounding box
  9114. * @param sphereCenter defines the sphere center
  9115. * @param sphereRadius defines the sphere radius
  9116. * @returns true if there is an intersection
  9117. */
  9118. static IntersectsSphere(minPoint: Readonly<Vector3>, maxPoint: Readonly<Vector3>, sphereCenter: Readonly<Vector3>, sphereRadius: number): boolean;
  9119. /**
  9120. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9121. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9122. * @param frustumPlanes defines the frustum planes to test
  9123. * @return true if there is an inclusion
  9124. */
  9125. static IsCompletelyInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  9126. /**
  9127. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9128. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9129. * @param frustumPlanes defines the frustum planes to test
  9130. * @return true if there is an intersection
  9131. */
  9132. static IsInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  9133. }
  9134. }
  9135. declare module BABYLON {
  9136. /**
  9137. * Interface for cullable objects
  9138. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9139. */
  9140. interface ICullable {
  9141. /**
  9142. * Checks if the object or part of the object is in the frustum
  9143. * @param frustumPlanes Camera near/planes
  9144. * @returns true if the object is in frustum otherwise false
  9145. */
  9146. isInFrustum(frustumPlanes: Plane[]): boolean;
  9147. /**
  9148. * Checks if a cullable object (mesh...) is in the camera frustum
  9149. * Unlike isInFrustum this cheks the full bounding box
  9150. * @param frustumPlanes Camera near/planes
  9151. * @returns true if the object is in frustum otherwise false
  9152. */
  9153. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9154. }
  9155. /**
  9156. * Info for a bounding data of a mesh
  9157. */
  9158. class BoundingInfo implements ICullable {
  9159. /**
  9160. * Bounding box for the mesh
  9161. */
  9162. readonly boundingBox: BoundingBox;
  9163. /**
  9164. * Bounding sphere for the mesh
  9165. */
  9166. readonly boundingSphere: BoundingSphere;
  9167. private _isLocked;
  9168. private static readonly TmpVector3;
  9169. /**
  9170. * Constructs bounding info
  9171. * @param minimum min vector of the bounding box/sphere
  9172. * @param maximum max vector of the bounding box/sphere
  9173. * @param worldMatrix defines the new world matrix
  9174. */
  9175. constructor(minimum: Readonly<Vector3>, maximum: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  9176. /**
  9177. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9178. * @param min defines the new minimum vector (in local space)
  9179. * @param max defines the new maximum vector (in local space)
  9180. * @param worldMatrix defines the new world matrix
  9181. */
  9182. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  9183. /**
  9184. * min vector of the bounding box/sphere
  9185. */
  9186. readonly minimum: Vector3;
  9187. /**
  9188. * max vector of the bounding box/sphere
  9189. */
  9190. readonly maximum: Vector3;
  9191. /**
  9192. * If the info is locked and won't be updated to avoid perf overhead
  9193. */
  9194. isLocked: boolean;
  9195. /**
  9196. * Updates the bounding sphere and box
  9197. * @param world world matrix to be used to update
  9198. */
  9199. update(world: Readonly<Matrix>): void;
  9200. /**
  9201. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9202. * @param center New center of the bounding info
  9203. * @param extend New extend of the bounding info
  9204. * @returns the current bounding info
  9205. */
  9206. centerOn(center: Readonly<Vector3>, extend: Readonly<Vector3>): BoundingInfo;
  9207. /**
  9208. * Scale the current bounding info by applying a scale factor
  9209. * @param factor defines the scale factor to apply
  9210. * @returns the current bounding info
  9211. */
  9212. scale(factor: number): BoundingInfo;
  9213. /**
  9214. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9215. * @param frustumPlanes defines the frustum to test
  9216. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  9217. * @returns true if the bounding info is in the frustum planes
  9218. */
  9219. isInFrustum(frustumPlanes: Array<Readonly<Plane>>, strategy?: number): boolean;
  9220. /**
  9221. * Gets the world distance between the min and max points of the bounding box
  9222. */
  9223. readonly diagonalLength: number;
  9224. /**
  9225. * Checks if a cullable object (mesh...) is in the camera frustum
  9226. * Unlike isInFrustum this cheks the full bounding box
  9227. * @param frustumPlanes Camera near/planes
  9228. * @returns true if the object is in frustum otherwise false
  9229. */
  9230. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9231. /** @hidden */
  9232. _checkCollision(collider: Collider): boolean;
  9233. /**
  9234. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9235. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9236. * @param point the point to check intersection with
  9237. * @returns if the point intersects
  9238. */
  9239. intersectsPoint(point: Readonly<Vector3>): boolean;
  9240. /**
  9241. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9242. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9243. * @param boundingInfo the bounding info to check intersection with
  9244. * @param precise if the intersection should be done using OBB
  9245. * @returns if the bounding info intersects
  9246. */
  9247. intersects(boundingInfo: Readonly<BoundingInfo>, precise: boolean): boolean;
  9248. }
  9249. }
  9250. declare module BABYLON {
  9251. /**
  9252. * Class used to store bounding sphere information
  9253. */
  9254. class BoundingSphere {
  9255. /**
  9256. * Gets the center of the bounding sphere in local space
  9257. */
  9258. readonly center: Vector3;
  9259. /**
  9260. * Radius of the bounding sphere in local space
  9261. */
  9262. radius: number;
  9263. /**
  9264. * Gets the center of the bounding sphere in world space
  9265. */
  9266. readonly centerWorld: Vector3;
  9267. /**
  9268. * Radius of the bounding sphere in world space
  9269. */
  9270. radiusWorld: number;
  9271. /**
  9272. * Gets the minimum vector in local space
  9273. */
  9274. readonly minimum: Vector3;
  9275. /**
  9276. * Gets the maximum vector in local space
  9277. */
  9278. readonly maximum: Vector3;
  9279. private _worldMatrix;
  9280. private static readonly TmpVector3;
  9281. /**
  9282. * Creates a new bounding sphere
  9283. * @param min defines the minimum vector (in local space)
  9284. * @param max defines the maximum vector (in local space)
  9285. * @param worldMatrix defines the new world matrix
  9286. */
  9287. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  9288. /**
  9289. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9290. * @param min defines the new minimum vector (in local space)
  9291. * @param max defines the new maximum vector (in local space)
  9292. * @param worldMatrix defines the new world matrix
  9293. */
  9294. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  9295. /**
  9296. * Scale the current bounding sphere by applying a scale factor
  9297. * @param factor defines the scale factor to apply
  9298. * @returns the current bounding box
  9299. */
  9300. scale(factor: number): BoundingSphere;
  9301. /**
  9302. * Gets the world matrix of the bounding box
  9303. * @returns a matrix
  9304. */
  9305. getWorldMatrix(): Readonly<Matrix>;
  9306. /** @hidden */
  9307. _update(worldMatrix: Readonly<Matrix>): void;
  9308. /**
  9309. * Tests if the bounding sphere is intersecting the frustum planes
  9310. * @param frustumPlanes defines the frustum planes to test
  9311. * @returns true if there is an intersection
  9312. */
  9313. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  9314. /**
  9315. * Tests if a point is inside the bounding sphere
  9316. * @param point defines the point to test
  9317. * @returns true if the point is inside the bounding sphere
  9318. */
  9319. intersectsPoint(point: Readonly<Vector3>): boolean;
  9320. /**
  9321. * Checks if two sphere intersct
  9322. * @param sphere0 sphere 0
  9323. * @param sphere1 sphere 1
  9324. * @returns true if the speres intersect
  9325. */
  9326. static Intersects(sphere0: Readonly<BoundingSphere>, sphere1: Readonly<BoundingSphere>): boolean;
  9327. }
  9328. }
  9329. declare module BABYLON {
  9330. /**
  9331. * Class representing a ray with position and direction
  9332. */
  9333. class Ray {
  9334. /** origin point */
  9335. origin: Vector3;
  9336. /** direction */
  9337. direction: Vector3;
  9338. /** length of the ray */
  9339. length: number;
  9340. private static readonly TmpVector3;
  9341. private _tmpRay;
  9342. /**
  9343. * Creates a new ray
  9344. * @param origin origin point
  9345. * @param direction direction
  9346. * @param length length of the ray
  9347. */
  9348. constructor(
  9349. /** origin point */
  9350. origin: Vector3,
  9351. /** direction */
  9352. direction: Vector3,
  9353. /** length of the ray */
  9354. length?: number);
  9355. /**
  9356. * Checks if the ray intersects a box
  9357. * @param minimum bound of the box
  9358. * @param maximum bound of the box
  9359. * @param intersectionTreshold extra extend to be added to the box in all direction
  9360. * @returns if the box was hit
  9361. */
  9362. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3, intersectionTreshold?: number): boolean;
  9363. /**
  9364. * Checks if the ray intersects a box
  9365. * @param box the bounding box to check
  9366. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9367. * @returns if the box was hit
  9368. */
  9369. intersectsBox(box: BoundingBox, intersectionTreshold?: number): boolean;
  9370. /**
  9371. * If the ray hits a sphere
  9372. * @param sphere the bounding sphere to check
  9373. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9374. * @returns true if it hits the sphere
  9375. */
  9376. intersectsSphere(sphere: BoundingSphere, intersectionTreshold?: number): boolean;
  9377. /**
  9378. * If the ray hits a triange
  9379. * @param vertex0 triangle vertex
  9380. * @param vertex1 triangle vertex
  9381. * @param vertex2 triangle vertex
  9382. * @returns intersection information if hit
  9383. */
  9384. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  9385. /**
  9386. * Checks if ray intersects a plane
  9387. * @param plane the plane to check
  9388. * @returns the distance away it was hit
  9389. */
  9390. intersectsPlane(plane: Plane): Nullable<number>;
  9391. /**
  9392. * Checks if ray intersects a mesh
  9393. * @param mesh the mesh to check
  9394. * @param fastCheck if only the bounding box should checked
  9395. * @returns picking info of the intersecton
  9396. */
  9397. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  9398. /**
  9399. * Checks if ray intersects a mesh
  9400. * @param meshes the meshes to check
  9401. * @param fastCheck if only the bounding box should checked
  9402. * @param results array to store result in
  9403. * @returns Array of picking infos
  9404. */
  9405. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9406. private _comparePickingInfo;
  9407. private static smallnum;
  9408. private static rayl;
  9409. /**
  9410. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9411. * @param sega the first point of the segment to test the intersection against
  9412. * @param segb the second point of the segment to test the intersection against
  9413. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9414. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9415. */
  9416. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  9417. /**
  9418. * Update the ray from viewport position
  9419. * @param x position
  9420. * @param y y position
  9421. * @param viewportWidth viewport width
  9422. * @param viewportHeight viewport height
  9423. * @param world world matrix
  9424. * @param view view matrix
  9425. * @param projection projection matrix
  9426. * @returns this ray updated
  9427. */
  9428. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Readonly<Matrix>, view: Readonly<Matrix>, projection: Readonly<Matrix>): Ray;
  9429. /**
  9430. * Creates a ray with origin and direction of 0,0,0
  9431. * @returns the new ray
  9432. */
  9433. static Zero(): Ray;
  9434. /**
  9435. * Creates a new ray from screen space and viewport
  9436. * @param x position
  9437. * @param y y position
  9438. * @param viewportWidth viewport width
  9439. * @param viewportHeight viewport height
  9440. * @param world world matrix
  9441. * @param view view matrix
  9442. * @param projection projection matrix
  9443. * @returns new ray
  9444. */
  9445. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9446. /**
  9447. * 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
  9448. * transformed to the given world matrix.
  9449. * @param origin The origin point
  9450. * @param end The end point
  9451. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9452. * @returns the new ray
  9453. */
  9454. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Readonly<Matrix>): Ray;
  9455. /**
  9456. * Transforms a ray by a matrix
  9457. * @param ray ray to transform
  9458. * @param matrix matrix to apply
  9459. * @returns the resulting new ray
  9460. */
  9461. static Transform(ray: Ray, matrix: Readonly<Matrix>): Ray;
  9462. /**
  9463. * Transforms a ray by a matrix
  9464. * @param ray ray to transform
  9465. * @param matrix matrix to apply
  9466. * @param result ray to store result in
  9467. */
  9468. static TransformToRef(ray: Ray, matrix: Readonly<Matrix>, result: Ray): void;
  9469. }
  9470. }
  9471. declare module BABYLON {
  9472. /** @hidden */
  9473. class Collider {
  9474. /** Define if a collision was found */
  9475. collisionFound: boolean;
  9476. /**
  9477. * Define last intersection point in local space
  9478. */
  9479. intersectionPoint: Vector3;
  9480. /**
  9481. * Define last collided mesh
  9482. */
  9483. collidedMesh: Nullable<AbstractMesh>;
  9484. private _collisionPoint;
  9485. private _planeIntersectionPoint;
  9486. private _tempVector;
  9487. private _tempVector2;
  9488. private _tempVector3;
  9489. private _tempVector4;
  9490. private _edge;
  9491. private _baseToVertex;
  9492. private _destinationPoint;
  9493. private _slidePlaneNormal;
  9494. private _displacementVector;
  9495. /** @hidden */
  9496. _radius: Vector3;
  9497. /** @hidden */
  9498. _retry: number;
  9499. private _velocity;
  9500. private _basePoint;
  9501. private _epsilon;
  9502. /** @hidden */
  9503. _velocityWorldLength: number;
  9504. /** @hidden */
  9505. _basePointWorld: Vector3;
  9506. private _velocityWorld;
  9507. private _normalizedVelocity;
  9508. /** @hidden */
  9509. _initialVelocity: Vector3;
  9510. /** @hidden */
  9511. _initialPosition: Vector3;
  9512. private _nearestDistance;
  9513. private _collisionMask;
  9514. collisionMask: number;
  9515. /**
  9516. * Gets the plane normal used to compute the sliding response (in local space)
  9517. */
  9518. readonly slidePlaneNormal: Vector3;
  9519. /** @hidden */
  9520. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9521. /** @hidden */
  9522. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9523. /** @hidden */
  9524. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9525. /** @hidden */
  9526. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9527. /** @hidden */
  9528. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9529. /** @hidden */
  9530. _getResponse(pos: Vector3, vel: Vector3): void;
  9531. }
  9532. }
  9533. declare module BABYLON {
  9534. /** @hidden */
  9535. var CollisionWorker: string;
  9536. /** @hidden */
  9537. interface ICollisionCoordinator {
  9538. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9539. init(scene: Scene): void;
  9540. destroy(): void;
  9541. onMeshAdded(mesh: AbstractMesh): void;
  9542. onMeshUpdated(mesh: AbstractMesh): void;
  9543. onMeshRemoved(mesh: AbstractMesh): void;
  9544. onGeometryAdded(geometry: Geometry): void;
  9545. onGeometryUpdated(geometry: Geometry): void;
  9546. onGeometryDeleted(geometry: Geometry): void;
  9547. }
  9548. /** @hidden */
  9549. interface SerializedMesh {
  9550. id: string;
  9551. name: string;
  9552. uniqueId: number;
  9553. geometryId: Nullable<string>;
  9554. sphereCenter: Array<number>;
  9555. sphereRadius: number;
  9556. boxMinimum: Array<number>;
  9557. boxMaximum: Array<number>;
  9558. worldMatrixFromCache: any;
  9559. subMeshes: Array<SerializedSubMesh>;
  9560. checkCollisions: boolean;
  9561. }
  9562. /** @hidden */
  9563. interface SerializedSubMesh {
  9564. position: number;
  9565. verticesStart: number;
  9566. verticesCount: number;
  9567. indexStart: number;
  9568. indexCount: number;
  9569. hasMaterial: boolean;
  9570. sphereCenter: Array<number>;
  9571. sphereRadius: number;
  9572. boxMinimum: Array<number>;
  9573. boxMaximum: Array<number>;
  9574. }
  9575. /**
  9576. * Interface describing the value associated with a geometry.
  9577. * @hidden
  9578. */
  9579. interface SerializedGeometry {
  9580. /**
  9581. * Defines the unique ID of the geometry
  9582. */
  9583. id: string;
  9584. /**
  9585. * Defines the array containing the positions
  9586. */
  9587. positions: Float32Array;
  9588. /**
  9589. * Defines the array containing the indices
  9590. */
  9591. indices: Uint32Array;
  9592. /**
  9593. * Defines the array containing the normals
  9594. */
  9595. normals: Float32Array;
  9596. }
  9597. /** @hidden */
  9598. interface BabylonMessage {
  9599. taskType: WorkerTaskType;
  9600. payload: InitPayload | CollidePayload | UpdatePayload;
  9601. }
  9602. /** @hidden */
  9603. interface SerializedColliderToWorker {
  9604. position: Array<number>;
  9605. velocity: Array<number>;
  9606. radius: Array<number>;
  9607. }
  9608. /** Defines supported task for worker process */
  9609. enum WorkerTaskType {
  9610. /** Initialization */
  9611. INIT = 0,
  9612. /** Update of geometry */
  9613. UPDATE = 1,
  9614. /** Evaluate collision */
  9615. COLLIDE = 2
  9616. }
  9617. /** @hidden */
  9618. interface WorkerReply {
  9619. error: WorkerReplyType;
  9620. taskType: WorkerTaskType;
  9621. payload?: any;
  9622. }
  9623. /** @hidden */
  9624. interface CollisionReplyPayload {
  9625. newPosition: Array<number>;
  9626. collisionId: number;
  9627. collidedMeshUniqueId: number;
  9628. }
  9629. /** @hidden */
  9630. interface InitPayload {
  9631. }
  9632. /** @hidden */
  9633. interface CollidePayload {
  9634. collisionId: number;
  9635. collider: SerializedColliderToWorker;
  9636. maximumRetry: number;
  9637. excludedMeshUniqueId: Nullable<number>;
  9638. }
  9639. /** @hidden */
  9640. interface UpdatePayload {
  9641. updatedMeshes: {
  9642. [n: number]: SerializedMesh;
  9643. };
  9644. updatedGeometries: {
  9645. [s: string]: SerializedGeometry;
  9646. };
  9647. removedMeshes: Array<number>;
  9648. removedGeometries: Array<string>;
  9649. }
  9650. /** Defines kind of replies returned by worker */
  9651. enum WorkerReplyType {
  9652. /** Success */
  9653. SUCCESS = 0,
  9654. /** Unkown error */
  9655. UNKNOWN_ERROR = 1
  9656. }
  9657. /** @hidden */
  9658. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9659. private _scene;
  9660. private _scaledPosition;
  9661. private _scaledVelocity;
  9662. private _collisionsCallbackArray;
  9663. private _init;
  9664. private _runningUpdated;
  9665. private _worker;
  9666. private _addUpdateMeshesList;
  9667. private _addUpdateGeometriesList;
  9668. private _toRemoveMeshesArray;
  9669. private _toRemoveGeometryArray;
  9670. constructor();
  9671. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9672. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9673. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9674. init(scene: Scene): void;
  9675. destroy(): void;
  9676. onMeshAdded(mesh: AbstractMesh): void;
  9677. onMeshUpdated: (transformNode: TransformNode) => void;
  9678. onMeshRemoved(mesh: AbstractMesh): void;
  9679. onGeometryAdded(geometry: Geometry): void;
  9680. onGeometryUpdated: (geometry: Geometry) => void;
  9681. onGeometryDeleted(geometry: Geometry): void;
  9682. private _afterRender;
  9683. private _onMessageFromWorker;
  9684. }
  9685. /** @hidden */
  9686. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9687. private _scene;
  9688. private _scaledPosition;
  9689. private _scaledVelocity;
  9690. private _finalPosition;
  9691. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9692. init(scene: Scene): void;
  9693. destroy(): void;
  9694. onMeshAdded(mesh: AbstractMesh): void;
  9695. onMeshUpdated(mesh: AbstractMesh): void;
  9696. onMeshRemoved(mesh: AbstractMesh): void;
  9697. onGeometryAdded(geometry: Geometry): void;
  9698. onGeometryUpdated(geometry: Geometry): void;
  9699. onGeometryDeleted(geometry: Geometry): void;
  9700. private _collideWithWorld;
  9701. }
  9702. }
  9703. declare function importScripts(...urls: string[]): void;
  9704. declare const safePostMessage: any;
  9705. declare module BABYLON {
  9706. /** @hidden */
  9707. var WorkerIncluded: boolean;
  9708. /** @hidden */
  9709. class CollisionCache {
  9710. private _meshes;
  9711. private _geometries;
  9712. getMeshes(): {
  9713. [n: number]: SerializedMesh;
  9714. };
  9715. getGeometries(): {
  9716. [s: number]: SerializedGeometry;
  9717. };
  9718. getMesh(id: any): SerializedMesh;
  9719. addMesh(mesh: SerializedMesh): void;
  9720. removeMesh(uniqueId: number): void;
  9721. getGeometry(id: string): SerializedGeometry;
  9722. addGeometry(geometry: SerializedGeometry): void;
  9723. removeGeometry(id: string): void;
  9724. }
  9725. /** @hidden */
  9726. class CollideWorker {
  9727. collider: Collider;
  9728. private _collisionCache;
  9729. private finalPosition;
  9730. private collisionsScalingMatrix;
  9731. private collisionTranformationMatrix;
  9732. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9733. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9734. private checkCollision;
  9735. private processCollisionsForSubMeshes;
  9736. private collideForSubMesh;
  9737. private checkSubmeshCollision;
  9738. }
  9739. /** @hidden */
  9740. interface ICollisionDetector {
  9741. onInit(payload: InitPayload): void;
  9742. onUpdate(payload: UpdatePayload): void;
  9743. onCollision(payload: CollidePayload): void;
  9744. }
  9745. /** @hidden */
  9746. class CollisionDetectorTransferable implements ICollisionDetector {
  9747. private _collisionCache;
  9748. onInit(payload: InitPayload): void;
  9749. onUpdate(payload: UpdatePayload): void;
  9750. onCollision(payload: CollidePayload): void;
  9751. }
  9752. }
  9753. declare module BABYLON {
  9754. /**
  9755. * @hidden
  9756. */
  9757. class IntersectionInfo {
  9758. bu: Nullable<number>;
  9759. bv: Nullable<number>;
  9760. distance: number;
  9761. faceId: number;
  9762. subMeshId: number;
  9763. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9764. }
  9765. /**
  9766. * Information about the result of picking within a scene
  9767. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9768. */
  9769. class PickingInfo {
  9770. /**
  9771. * If the pick collided with an object
  9772. */
  9773. hit: boolean;
  9774. /**
  9775. * Distance away where the pick collided
  9776. */
  9777. distance: number;
  9778. /**
  9779. * The location of pick collision
  9780. */
  9781. pickedPoint: Nullable<Vector3>;
  9782. /**
  9783. * The mesh corresponding the the pick collision
  9784. */
  9785. pickedMesh: Nullable<AbstractMesh>;
  9786. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9787. bu: number;
  9788. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9789. bv: number;
  9790. /** The id of the face on the mesh that was picked */
  9791. faceId: number;
  9792. /** Id of the the submesh that was picked */
  9793. subMeshId: number;
  9794. /** If a sprite was picked, this will be the sprite the pick collided with */
  9795. pickedSprite: Nullable<Sprite>;
  9796. /**
  9797. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9798. */
  9799. originMesh: Nullable<AbstractMesh>;
  9800. /**
  9801. * The ray that was used to perform the picking.
  9802. */
  9803. ray: Nullable<Ray>;
  9804. /**
  9805. * Gets the normal correspodning to the face the pick collided with
  9806. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9807. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9808. * @returns The normal correspodning to the face the pick collided with
  9809. */
  9810. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9811. /**
  9812. * Gets the texture coordinates of where the pick occured
  9813. * @returns the vector containing the coordnates of the texture
  9814. */
  9815. getTextureCoordinates(): Nullable<Vector2>;
  9816. }
  9817. }
  9818. declare module BABYLON {
  9819. /**
  9820. * Interface for attribute information associated with buffer instanciation
  9821. */
  9822. class InstancingAttributeInfo {
  9823. /**
  9824. * Index/offset of the attribute in the vertex shader
  9825. */
  9826. index: number;
  9827. /**
  9828. * size of the attribute, 1, 2, 3 or 4
  9829. */
  9830. attributeSize: number;
  9831. /**
  9832. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9833. * default is FLOAT
  9834. */
  9835. attribyteType: number;
  9836. /**
  9837. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9838. */
  9839. normalized: boolean;
  9840. /**
  9841. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9842. */
  9843. offset: number;
  9844. /**
  9845. * Name of the GLSL attribute, for debugging purpose only
  9846. */
  9847. attributeName: string;
  9848. }
  9849. /**
  9850. * Define options used to create a render target texture
  9851. */
  9852. class RenderTargetCreationOptions {
  9853. /**
  9854. * Specifies is mipmaps must be generated
  9855. */
  9856. generateMipMaps?: boolean;
  9857. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9858. generateDepthBuffer?: boolean;
  9859. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9860. generateStencilBuffer?: boolean;
  9861. /** Defines texture type (int by default) */
  9862. type?: number;
  9863. /** Defines sampling mode (trilinear by default) */
  9864. samplingMode?: number;
  9865. /** Defines format (RGBA by default) */
  9866. format?: number;
  9867. }
  9868. /**
  9869. * Define options used to create a depth texture
  9870. */
  9871. class DepthTextureCreationOptions {
  9872. /** Specifies whether or not a stencil should be allocated in the texture */
  9873. generateStencil?: boolean;
  9874. /** Specifies whether or not bilinear filtering is enable on the texture */
  9875. bilinearFiltering?: boolean;
  9876. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9877. comparisonFunction?: number;
  9878. /** Specifies if the created texture is a cube texture */
  9879. isCube?: boolean;
  9880. }
  9881. /**
  9882. * Class used to describe the capabilities of the engine relatively to the current browser
  9883. */
  9884. class EngineCapabilities {
  9885. /** Maximum textures units per fragment shader */
  9886. maxTexturesImageUnits: number;
  9887. /** Maximum texture units per vertex shader */
  9888. maxVertexTextureImageUnits: number;
  9889. /** Maximum textures units in the entire pipeline */
  9890. maxCombinedTexturesImageUnits: number;
  9891. /** Maximum texture size */
  9892. maxTextureSize: number;
  9893. /** Maximum cube texture size */
  9894. maxCubemapTextureSize: number;
  9895. /** Maximum render texture size */
  9896. maxRenderTextureSize: number;
  9897. /** Maximum number of vertex attributes */
  9898. maxVertexAttribs: number;
  9899. /** Maximum number of varyings */
  9900. maxVaryingVectors: number;
  9901. /** Maximum number of uniforms per vertex shader */
  9902. maxVertexUniformVectors: number;
  9903. /** Maximum number of uniforms per fragment shader */
  9904. maxFragmentUniformVectors: number;
  9905. /** Defines if standard derivates (dx/dy) are supported */
  9906. standardDerivatives: boolean;
  9907. /** Defines if s3tc texture compression is supported */
  9908. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9909. /** Defines if pvrtc texture compression is supported */
  9910. pvrtc: any;
  9911. /** Defines if etc1 texture compression is supported */
  9912. etc1: any;
  9913. /** Defines if etc2 texture compression is supported */
  9914. etc2: any;
  9915. /** Defines if astc texture compression is supported */
  9916. astc: any;
  9917. /** Defines if float textures are supported */
  9918. textureFloat: boolean;
  9919. /** Defines if vertex array objects are supported */
  9920. vertexArrayObject: boolean;
  9921. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9922. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9923. /** Gets the maximum level of anisotropy supported */
  9924. maxAnisotropy: number;
  9925. /** Defines if instancing is supported */
  9926. instancedArrays: boolean;
  9927. /** Defines if 32 bits indices are supported */
  9928. uintIndices: boolean;
  9929. /** Defines if high precision shaders are supported */
  9930. highPrecisionShaderSupported: boolean;
  9931. /** Defines if depth reading in the fragment shader is supported */
  9932. fragmentDepthSupported: boolean;
  9933. /** Defines if float texture linear filtering is supported*/
  9934. textureFloatLinearFiltering: boolean;
  9935. /** Defines if rendering to float textures is supported */
  9936. textureFloatRender: boolean;
  9937. /** Defines if half float textures are supported*/
  9938. textureHalfFloat: boolean;
  9939. /** Defines if half float texture linear filtering is supported*/
  9940. textureHalfFloatLinearFiltering: boolean;
  9941. /** Defines if rendering to half float textures is supported */
  9942. textureHalfFloatRender: boolean;
  9943. /** Defines if textureLOD shader command is supported */
  9944. textureLOD: boolean;
  9945. /** Defines if draw buffers extension is supported */
  9946. drawBuffersExtension: boolean;
  9947. /** Defines if depth textures are supported */
  9948. depthTextureExtension: boolean;
  9949. /** Defines if float color buffer are supported */
  9950. colorBufferFloat: boolean;
  9951. /** Gets disjoint timer query extension (null if not supported) */
  9952. timerQuery: EXT_disjoint_timer_query;
  9953. /** Defines if timestamp can be used with timer query */
  9954. canUseTimestampForTimerQuery: boolean;
  9955. /** Function used to let the system compiles shaders in background */
  9956. parallelShaderCompile: {
  9957. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9958. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9959. COMPLETION_STATUS_KHR: number;
  9960. };
  9961. }
  9962. /** Interface defining initialization parameters for Engine class */
  9963. interface EngineOptions extends WebGLContextAttributes {
  9964. /**
  9965. * Defines if the engine should no exceed a specified device ratio
  9966. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9967. */
  9968. limitDeviceRatio?: number;
  9969. /**
  9970. * Defines if webvr should be enabled automatically
  9971. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9972. */
  9973. autoEnableWebVR?: boolean;
  9974. /**
  9975. * Defines if webgl2 should be turned off even if supported
  9976. * @see http://doc.babylonjs.com/features/webgl2
  9977. */
  9978. disableWebGL2Support?: boolean;
  9979. /**
  9980. * Defines if webaudio should be initialized as well
  9981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9982. */
  9983. audioEngine?: boolean;
  9984. /**
  9985. * Defines if animations should run using a deterministic lock step
  9986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9987. */
  9988. deterministicLockstep?: boolean;
  9989. /** Defines the maximum steps to use with deterministic lock step mode */
  9990. lockstepMaxSteps?: number;
  9991. /**
  9992. * Defines that engine should ignore context lost events
  9993. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9994. */
  9995. doNotHandleContextLost?: boolean;
  9996. }
  9997. /**
  9998. * Defines the interface used by display changed events
  9999. */
  10000. interface IDisplayChangedEventArgs {
  10001. /** Gets the vrDisplay object (if any) */
  10002. vrDisplay: Nullable<any>;
  10003. /** Gets a boolean indicating if webVR is supported */
  10004. vrSupported: boolean;
  10005. }
  10006. /**
  10007. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10008. */
  10009. class Engine {
  10010. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10011. static ExceptionList: ({
  10012. key: string;
  10013. capture: string;
  10014. captureConstraint: number;
  10015. targets: string[];
  10016. } | {
  10017. key: string;
  10018. capture: null;
  10019. captureConstraint: null;
  10020. targets: string[];
  10021. })[];
  10022. /** Gets the list of created engines */
  10023. static Instances: Engine[];
  10024. /**
  10025. * Gets the latest created engine
  10026. */
  10027. static readonly LastCreatedEngine: Nullable<Engine>;
  10028. /**
  10029. * Gets the latest created scene
  10030. */
  10031. static readonly LastCreatedScene: Nullable<Scene>;
  10032. /**
  10033. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10034. * @param flag defines which part of the materials must be marked as dirty
  10035. * @param predicate defines a predicate used to filter which materials should be affected
  10036. */
  10037. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10038. /**
  10039. * Hidden
  10040. */
  10041. static _TextureLoaders: IInternalTextureLoader[];
  10042. /** Defines that alpha blending is disabled */
  10043. static readonly ALPHA_DISABLE: number;
  10044. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10045. static readonly ALPHA_ADD: number;
  10046. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10047. static readonly ALPHA_COMBINE: number;
  10048. /** Defines that alpha blending to DEST - SRC * DEST */
  10049. static readonly ALPHA_SUBTRACT: number;
  10050. /** Defines that alpha blending to SRC * DEST */
  10051. static readonly ALPHA_MULTIPLY: number;
  10052. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10053. static readonly ALPHA_MAXIMIZED: number;
  10054. /** Defines that alpha blending to SRC + DEST */
  10055. static readonly ALPHA_ONEONE: number;
  10056. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10057. static readonly ALPHA_PREMULTIPLIED: number;
  10058. /**
  10059. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10060. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10061. */
  10062. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10063. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10064. static readonly ALPHA_INTERPOLATE: number;
  10065. /**
  10066. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10067. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10068. */
  10069. static readonly ALPHA_SCREENMODE: number;
  10070. /** Defines that the ressource is not delayed*/
  10071. static readonly DELAYLOADSTATE_NONE: number;
  10072. /** Defines that the ressource was successfully delay loaded */
  10073. static readonly DELAYLOADSTATE_LOADED: number;
  10074. /** Defines that the ressource is currently delay loading */
  10075. static readonly DELAYLOADSTATE_LOADING: number;
  10076. /** Defines that the ressource is delayed and has not started loading */
  10077. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10079. static readonly NEVER: number;
  10080. /** 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 */
  10081. static readonly ALWAYS: number;
  10082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10083. static readonly LESS: number;
  10084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10085. static readonly EQUAL: number;
  10086. /** 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 */
  10087. static readonly LEQUAL: number;
  10088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10089. static readonly GREATER: number;
  10090. /** 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 */
  10091. static readonly GEQUAL: number;
  10092. /** 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 */
  10093. static readonly NOTEQUAL: number;
  10094. /** Passed to stencilOperation to specify that stencil value must be kept */
  10095. static readonly KEEP: number;
  10096. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10097. static readonly REPLACE: number;
  10098. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10099. static readonly INCR: number;
  10100. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10101. static readonly DECR: number;
  10102. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10103. static readonly INVERT: number;
  10104. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10105. static readonly INCR_WRAP: number;
  10106. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10107. static readonly DECR_WRAP: number;
  10108. /** Texture is not repeating outside of 0..1 UVs */
  10109. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10110. /** Texture is repeating outside of 0..1 UVs */
  10111. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10112. /** Texture is repeating and mirrored */
  10113. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10114. /** ALPHA */
  10115. static readonly TEXTUREFORMAT_ALPHA: number;
  10116. /** LUMINANCE */
  10117. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10118. /** LUMINANCE_ALPHA */
  10119. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10120. /** RGB */
  10121. static readonly TEXTUREFORMAT_RGB: number;
  10122. /** RGBA */
  10123. static readonly TEXTUREFORMAT_RGBA: number;
  10124. /** RED */
  10125. static readonly TEXTUREFORMAT_RED: number;
  10126. /** RED (2nd reference) */
  10127. static readonly TEXTUREFORMAT_R: number;
  10128. /** RG */
  10129. static readonly TEXTUREFORMAT_RG: number;
  10130. /** RED_INTEGER */
  10131. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10132. /** RED_INTEGER (2nd reference) */
  10133. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10134. /** RG_INTEGER */
  10135. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10136. /** RGB_INTEGER */
  10137. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10138. /** RGBA_INTEGER */
  10139. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10140. /** UNSIGNED_BYTE */
  10141. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10142. /** UNSIGNED_BYTE (2nd reference) */
  10143. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10144. /** FLOAT */
  10145. static readonly TEXTURETYPE_FLOAT: number;
  10146. /** HALF_FLOAT */
  10147. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10148. /** BYTE */
  10149. static readonly TEXTURETYPE_BYTE: number;
  10150. /** SHORT */
  10151. static readonly TEXTURETYPE_SHORT: number;
  10152. /** UNSIGNED_SHORT */
  10153. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10154. /** INT */
  10155. static readonly TEXTURETYPE_INT: number;
  10156. /** UNSIGNED_INT */
  10157. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10158. /** UNSIGNED_SHORT_4_4_4_4 */
  10159. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10160. /** UNSIGNED_SHORT_5_5_5_1 */
  10161. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10162. /** UNSIGNED_SHORT_5_6_5 */
  10163. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10164. /** UNSIGNED_INT_2_10_10_10_REV */
  10165. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10166. /** UNSIGNED_INT_24_8 */
  10167. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10168. /** UNSIGNED_INT_10F_11F_11F_REV */
  10169. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10170. /** UNSIGNED_INT_5_9_9_9_REV */
  10171. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10172. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10173. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10174. /** nearest is mag = nearest and min = nearest and mip = linear */
  10175. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10177. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10178. /** Trilinear is mag = linear and min = linear and mip = linear */
  10179. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10180. /** nearest is mag = nearest and min = nearest and mip = linear */
  10181. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10183. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10184. /** Trilinear is mag = linear and min = linear and mip = linear */
  10185. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10186. /** mag = nearest and min = nearest and mip = nearest */
  10187. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10188. /** mag = nearest and min = linear and mip = nearest */
  10189. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10190. /** mag = nearest and min = linear and mip = linear */
  10191. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10192. /** mag = nearest and min = linear and mip = none */
  10193. static readonly TEXTURE_NEAREST_LINEAR: number;
  10194. /** mag = nearest and min = nearest and mip = none */
  10195. static readonly TEXTURE_NEAREST_NEAREST: number;
  10196. /** mag = linear and min = nearest and mip = nearest */
  10197. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10198. /** mag = linear and min = nearest and mip = linear */
  10199. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10200. /** mag = linear and min = linear and mip = none */
  10201. static readonly TEXTURE_LINEAR_LINEAR: number;
  10202. /** mag = linear and min = nearest and mip = none */
  10203. static readonly TEXTURE_LINEAR_NEAREST: number;
  10204. /** Explicit coordinates mode */
  10205. static readonly TEXTURE_EXPLICIT_MODE: number;
  10206. /** Spherical coordinates mode */
  10207. static readonly TEXTURE_SPHERICAL_MODE: number;
  10208. /** Planar coordinates mode */
  10209. static readonly TEXTURE_PLANAR_MODE: number;
  10210. /** Cubic coordinates mode */
  10211. static readonly TEXTURE_CUBIC_MODE: number;
  10212. /** Projection coordinates mode */
  10213. static readonly TEXTURE_PROJECTION_MODE: number;
  10214. /** Skybox coordinates mode */
  10215. static readonly TEXTURE_SKYBOX_MODE: number;
  10216. /** Inverse Cubic coordinates mode */
  10217. static readonly TEXTURE_INVCUBIC_MODE: number;
  10218. /** Equirectangular coordinates mode */
  10219. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10220. /** Equirectangular Fixed coordinates mode */
  10221. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10222. /** Equirectangular Fixed Mirrored coordinates mode */
  10223. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10224. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10225. static readonly SCALEMODE_FLOOR: number;
  10226. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10227. static readonly SCALEMODE_NEAREST: number;
  10228. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10229. static readonly SCALEMODE_CEILING: number;
  10230. /**
  10231. * Returns the current version of the framework
  10232. */
  10233. static readonly Version: string;
  10234. /**
  10235. * Returns a string describing the current engine
  10236. */
  10237. readonly description: string;
  10238. /**
  10239. * Gets or sets the epsilon value used by collision engine
  10240. */
  10241. static CollisionsEpsilon: number;
  10242. /**
  10243. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10244. */
  10245. static CodeRepository: string;
  10246. /**
  10247. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10248. */
  10249. static ShadersRepository: string;
  10250. /**
  10251. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10252. */
  10253. forcePOTTextures: boolean;
  10254. /**
  10255. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10256. */
  10257. isFullscreen: boolean;
  10258. /**
  10259. * Gets a boolean indicating if the pointer is currently locked
  10260. */
  10261. isPointerLock: boolean;
  10262. /**
  10263. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10264. */
  10265. cullBackFaces: boolean;
  10266. /**
  10267. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10268. */
  10269. renderEvenInBackground: boolean;
  10270. /**
  10271. * Gets or sets a boolean indicating that cache can be kept between frames
  10272. */
  10273. preventCacheWipeBetweenFrames: boolean;
  10274. /**
  10275. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10276. **/
  10277. enableOfflineSupport: boolean;
  10278. /**
  10279. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10280. **/
  10281. disableManifestCheck: boolean;
  10282. /**
  10283. * Gets the list of created scenes
  10284. */
  10285. scenes: Scene[];
  10286. /**
  10287. * Gets the list of created postprocesses
  10288. */
  10289. postProcesses: PostProcess[];
  10290. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10291. validateShaderPrograms: boolean;
  10292. /**
  10293. * Observable event triggered each time the rendering canvas is resized
  10294. */
  10295. onResizeObservable: Observable<Engine>;
  10296. /**
  10297. * Observable event triggered each time the canvas loses focus
  10298. */
  10299. onCanvasBlurObservable: Observable<Engine>;
  10300. /**
  10301. * Observable event triggered each time the canvas gains focus
  10302. */
  10303. onCanvasFocusObservable: Observable<Engine>;
  10304. /**
  10305. * Observable event triggered each time the canvas receives pointerout event
  10306. */
  10307. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10308. /**
  10309. * Observable event triggered before each texture is initialized
  10310. */
  10311. onBeforeTextureInitObservable: Observable<Texture>;
  10312. private _vrDisplay;
  10313. private _vrSupported;
  10314. private _oldSize;
  10315. private _oldHardwareScaleFactor;
  10316. private _vrExclusivePointerMode;
  10317. private _webVRInitPromise;
  10318. /**
  10319. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10320. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10321. */
  10322. readonly isInVRExclusivePointerMode: boolean;
  10323. /**
  10324. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10325. */
  10326. disableUniformBuffers: boolean;
  10327. /** @hidden */
  10328. _uniformBuffers: UniformBuffer[];
  10329. /**
  10330. * Gets a boolean indicating that the engine supports uniform buffers
  10331. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10332. */
  10333. readonly supportsUniformBuffers: boolean;
  10334. /**
  10335. * Observable raised when the engine begins a new frame
  10336. */
  10337. onBeginFrameObservable: Observable<Engine>;
  10338. /**
  10339. * If set, will be used to request the next animation frame for the render loop
  10340. */
  10341. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10342. /**
  10343. * Observable raised when the engine ends the current frame
  10344. */
  10345. onEndFrameObservable: Observable<Engine>;
  10346. /**
  10347. * Observable raised when the engine is about to compile a shader
  10348. */
  10349. onBeforeShaderCompilationObservable: Observable<Engine>;
  10350. /**
  10351. * Observable raised when the engine has jsut compiled a shader
  10352. */
  10353. onAfterShaderCompilationObservable: Observable<Engine>;
  10354. /** @hidden */
  10355. _gl: WebGLRenderingContext;
  10356. private _renderingCanvas;
  10357. private _windowIsBackground;
  10358. private _webGLVersion;
  10359. /**
  10360. * Gets a boolean indicating that only power of 2 textures are supported
  10361. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10362. */
  10363. readonly needPOTTextures: boolean;
  10364. /** @hidden */
  10365. _badOS: boolean;
  10366. /** @hidden */
  10367. _badDesktopOS: boolean;
  10368. /**
  10369. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10370. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10371. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10372. */
  10373. disableTextureBindingOptimization: boolean;
  10374. /**
  10375. * Gets the audio engine
  10376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10377. * @ignorenaming
  10378. */
  10379. static audioEngine: IAudioEngine;
  10380. /**
  10381. * Default AudioEngine factory responsible of creating the Audio Engine.
  10382. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10383. */
  10384. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10385. /**
  10386. * Default offline support factory responsible of creating a tool used to store data locally.
  10387. * By default, this will create a Database object if the workload has been embedded.
  10388. */
  10389. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10390. private _onFocus;
  10391. private _onBlur;
  10392. private _onCanvasPointerOut;
  10393. private _onCanvasBlur;
  10394. private _onCanvasFocus;
  10395. private _onFullscreenChange;
  10396. private _onPointerLockChange;
  10397. private _onVRDisplayPointerRestricted;
  10398. private _onVRDisplayPointerUnrestricted;
  10399. private _onVrDisplayConnect;
  10400. private _onVrDisplayDisconnect;
  10401. private _onVrDisplayPresentChange;
  10402. /**
  10403. * Observable signaled when VR display mode changes
  10404. */
  10405. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10406. /**
  10407. * Observable signaled when VR request present is complete
  10408. */
  10409. onVRRequestPresentComplete: Observable<boolean>;
  10410. /**
  10411. * Observable signaled when VR request present starts
  10412. */
  10413. onVRRequestPresentStart: Observable<Engine>;
  10414. private _hardwareScalingLevel;
  10415. /** @hidden */
  10416. protected _caps: EngineCapabilities;
  10417. private _pointerLockRequested;
  10418. private _isStencilEnable;
  10419. private _colorWrite;
  10420. private _loadingScreen;
  10421. /** @hidden */
  10422. _drawCalls: PerfCounter;
  10423. /** @hidden */
  10424. _textureCollisions: PerfCounter;
  10425. private _glVersion;
  10426. private _glRenderer;
  10427. private _glVendor;
  10428. private _videoTextureSupported;
  10429. private _renderingQueueLaunched;
  10430. private _activeRenderLoops;
  10431. private _deterministicLockstep;
  10432. private _lockstepMaxSteps;
  10433. /**
  10434. * Observable signaled when a context lost event is raised
  10435. */
  10436. onContextLostObservable: Observable<Engine>;
  10437. /**
  10438. * Observable signaled when a context restored event is raised
  10439. */
  10440. onContextRestoredObservable: Observable<Engine>;
  10441. private _onContextLost;
  10442. private _onContextRestored;
  10443. private _contextWasLost;
  10444. private _doNotHandleContextLost;
  10445. /**
  10446. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10448. */
  10449. doNotHandleContextLost: boolean;
  10450. private _performanceMonitor;
  10451. private _fps;
  10452. private _deltaTime;
  10453. /**
  10454. * Turn this value on if you want to pause FPS computation when in background
  10455. */
  10456. disablePerformanceMonitorInBackground: boolean;
  10457. /**
  10458. * Gets the performance monitor attached to this engine
  10459. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10460. */
  10461. readonly performanceMonitor: PerformanceMonitor;
  10462. /** @hidden */
  10463. protected _depthCullingState: _DepthCullingState;
  10464. /** @hidden */
  10465. protected _stencilState: _StencilState;
  10466. /** @hidden */
  10467. protected _alphaState: _AlphaState;
  10468. /** @hidden */
  10469. protected _alphaMode: number;
  10470. protected _internalTexturesCache: InternalTexture[];
  10471. /** @hidden */
  10472. protected _activeChannel: number;
  10473. private _currentTextureChannel;
  10474. /** @hidden */
  10475. protected _boundTexturesCache: {
  10476. [key: string]: Nullable<InternalTexture>;
  10477. };
  10478. /** @hidden */
  10479. protected _currentEffect: Nullable<Effect>;
  10480. /** @hidden */
  10481. protected _currentProgram: Nullable<WebGLProgram>;
  10482. private _compiledEffects;
  10483. private _vertexAttribArraysEnabled;
  10484. /** @hidden */
  10485. protected _cachedViewport: Nullable<Viewport>;
  10486. private _cachedVertexArrayObject;
  10487. /** @hidden */
  10488. protected _cachedVertexBuffers: any;
  10489. /** @hidden */
  10490. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10491. /** @hidden */
  10492. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10493. /** @hidden */
  10494. protected _currentRenderTarget: Nullable<InternalTexture>;
  10495. private _uintIndicesCurrentlySet;
  10496. private _currentBoundBuffer;
  10497. /** @hidden */
  10498. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10499. private _currentBufferPointers;
  10500. private _currentInstanceLocations;
  10501. private _currentInstanceBuffers;
  10502. private _textureUnits;
  10503. private _firstBoundInternalTextureTracker;
  10504. private _lastBoundInternalTextureTracker;
  10505. private _workingCanvas;
  10506. private _workingContext;
  10507. private _rescalePostProcess;
  10508. private _dummyFramebuffer;
  10509. private _externalData;
  10510. private _bindedRenderFunction;
  10511. private _vaoRecordInProgress;
  10512. private _mustWipeVertexAttributes;
  10513. private _emptyTexture;
  10514. private _emptyCubeTexture;
  10515. private _emptyTexture3D;
  10516. /** @hidden */
  10517. _frameHandler: number;
  10518. private _nextFreeTextureSlots;
  10519. private _maxSimultaneousTextures;
  10520. private _activeRequests;
  10521. private _texturesSupported;
  10522. private _textureFormatInUse;
  10523. /**
  10524. * Gets the list of texture formats supported
  10525. */
  10526. readonly texturesSupported: Array<string>;
  10527. /**
  10528. * Gets the list of texture formats in use
  10529. */
  10530. readonly textureFormatInUse: Nullable<string>;
  10531. /**
  10532. * Gets the current viewport
  10533. */
  10534. readonly currentViewport: Nullable<Viewport>;
  10535. /**
  10536. * Gets the default empty texture
  10537. */
  10538. readonly emptyTexture: InternalTexture;
  10539. /**
  10540. * Gets the default empty 3D texture
  10541. */
  10542. readonly emptyTexture3D: InternalTexture;
  10543. /**
  10544. * Gets the default empty cube texture
  10545. */
  10546. readonly emptyCubeTexture: InternalTexture;
  10547. /**
  10548. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10549. */
  10550. readonly premultipliedAlpha: boolean;
  10551. /**
  10552. * Creates a new engine
  10553. * @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
  10554. * @param antialias defines enable antialiasing (default: false)
  10555. * @param options defines further options to be sent to the getContext() function
  10556. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10557. */
  10558. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10559. private _rebuildInternalTextures;
  10560. private _rebuildEffects;
  10561. /**
  10562. * Gets a boolean indicating if all created effects are ready
  10563. * @returns true if all effects are ready
  10564. */
  10565. areAllEffectsReady(): boolean;
  10566. private _rebuildBuffers;
  10567. private _initGLContext;
  10568. /**
  10569. * Gets version of the current webGL context
  10570. */
  10571. readonly webGLVersion: number;
  10572. /**
  10573. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10574. */
  10575. readonly isStencilEnable: boolean;
  10576. private _prepareWorkingCanvas;
  10577. /**
  10578. * Reset the texture cache to empty state
  10579. */
  10580. resetTextureCache(): void;
  10581. /**
  10582. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10583. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10584. * @returns true if engine is in deterministic lock step mode
  10585. */
  10586. isDeterministicLockStep(): boolean;
  10587. /**
  10588. * Gets the max steps when engine is running in deterministic lock step
  10589. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10590. * @returns the max steps
  10591. */
  10592. getLockstepMaxSteps(): number;
  10593. /**
  10594. * Gets an object containing information about the current webGL context
  10595. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10596. */
  10597. getGlInfo(): {
  10598. vendor: string;
  10599. renderer: string;
  10600. version: string;
  10601. };
  10602. /**
  10603. * Gets current aspect ratio
  10604. * @param camera defines the camera to use to get the aspect ratio
  10605. * @param useScreen defines if screen size must be used (or the current render target if any)
  10606. * @returns a number defining the aspect ratio
  10607. */
  10608. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10609. /**
  10610. * Gets current screen aspect ratio
  10611. * @returns a number defining the aspect ratio
  10612. */
  10613. getScreenAspectRatio(): number;
  10614. /**
  10615. * Gets the current render width
  10616. * @param useScreen defines if screen size must be used (or the current render target if any)
  10617. * @returns a number defining the current render width
  10618. */
  10619. getRenderWidth(useScreen?: boolean): number;
  10620. /**
  10621. * Gets the current render height
  10622. * @param useScreen defines if screen size must be used (or the current render target if any)
  10623. * @returns a number defining the current render height
  10624. */
  10625. getRenderHeight(useScreen?: boolean): number;
  10626. /**
  10627. * Gets the HTML canvas attached with the current webGL context
  10628. * @returns a HTML canvas
  10629. */
  10630. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10631. /**
  10632. * Gets the client rect of the HTML canvas attached with the current webGL context
  10633. * @returns a client rectanglee
  10634. */
  10635. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10636. /**
  10637. * Defines the hardware scaling level.
  10638. * By default the hardware scaling level is computed from the window device ratio.
  10639. * 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.
  10640. * @param level defines the level to use
  10641. */
  10642. setHardwareScalingLevel(level: number): void;
  10643. /**
  10644. * Gets the current hardware scaling level.
  10645. * By default the hardware scaling level is computed from the window device ratio.
  10646. * 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.
  10647. * @returns a number indicating the current hardware scaling level
  10648. */
  10649. getHardwareScalingLevel(): number;
  10650. /**
  10651. * Gets the list of loaded textures
  10652. * @returns an array containing all loaded textures
  10653. */
  10654. getLoadedTexturesCache(): InternalTexture[];
  10655. /**
  10656. * Gets the object containing all engine capabilities
  10657. * @returns the EngineCapabilities object
  10658. */
  10659. getCaps(): EngineCapabilities;
  10660. /**
  10661. * Gets the current depth function
  10662. * @returns a number defining the depth function
  10663. */
  10664. getDepthFunction(): Nullable<number>;
  10665. /**
  10666. * Sets the current depth function
  10667. * @param depthFunc defines the function to use
  10668. */
  10669. setDepthFunction(depthFunc: number): void;
  10670. /**
  10671. * Sets the current depth function to GREATER
  10672. */
  10673. setDepthFunctionToGreater(): void;
  10674. /**
  10675. * Sets the current depth function to GEQUAL
  10676. */
  10677. setDepthFunctionToGreaterOrEqual(): void;
  10678. /**
  10679. * Sets the current depth function to LESS
  10680. */
  10681. setDepthFunctionToLess(): void;
  10682. /**
  10683. * Sets the current depth function to LEQUAL
  10684. */
  10685. setDepthFunctionToLessOrEqual(): void;
  10686. /**
  10687. * Gets a boolean indicating if stencil buffer is enabled
  10688. * @returns the current stencil buffer state
  10689. */
  10690. getStencilBuffer(): boolean;
  10691. /**
  10692. * Enable or disable the stencil buffer
  10693. * @param enable defines if the stencil buffer must be enabled or disabled
  10694. */
  10695. setStencilBuffer(enable: boolean): void;
  10696. /**
  10697. * Gets the current stencil mask
  10698. * @returns a number defining the new stencil mask to use
  10699. */
  10700. getStencilMask(): number;
  10701. /**
  10702. * Sets the current stencil mask
  10703. * @param mask defines the new stencil mask to use
  10704. */
  10705. setStencilMask(mask: number): void;
  10706. /**
  10707. * Gets the current stencil function
  10708. * @returns a number defining the stencil function to use
  10709. */
  10710. getStencilFunction(): number;
  10711. /**
  10712. * Gets the current stencil reference value
  10713. * @returns a number defining the stencil reference value to use
  10714. */
  10715. getStencilFunctionReference(): number;
  10716. /**
  10717. * Gets the current stencil mask
  10718. * @returns a number defining the stencil mask to use
  10719. */
  10720. getStencilFunctionMask(): number;
  10721. /**
  10722. * Sets the current stencil function
  10723. * @param stencilFunc defines the new stencil function to use
  10724. */
  10725. setStencilFunction(stencilFunc: number): void;
  10726. /**
  10727. * Sets the current stencil reference
  10728. * @param reference defines the new stencil reference to use
  10729. */
  10730. setStencilFunctionReference(reference: number): void;
  10731. /**
  10732. * Sets the current stencil mask
  10733. * @param mask defines the new stencil mask to use
  10734. */
  10735. setStencilFunctionMask(mask: number): void;
  10736. /**
  10737. * Gets the current stencil operation when stencil fails
  10738. * @returns a number defining stencil operation to use when stencil fails
  10739. */
  10740. getStencilOperationFail(): number;
  10741. /**
  10742. * Gets the current stencil operation when depth fails
  10743. * @returns a number defining stencil operation to use when depth fails
  10744. */
  10745. getStencilOperationDepthFail(): number;
  10746. /**
  10747. * Gets the current stencil operation when stencil passes
  10748. * @returns a number defining stencil operation to use when stencil passes
  10749. */
  10750. getStencilOperationPass(): number;
  10751. /**
  10752. * Sets the stencil operation to use when stencil fails
  10753. * @param operation defines the stencil operation to use when stencil fails
  10754. */
  10755. setStencilOperationFail(operation: number): void;
  10756. /**
  10757. * Sets the stencil operation to use when depth fails
  10758. * @param operation defines the stencil operation to use when depth fails
  10759. */
  10760. setStencilOperationDepthFail(operation: number): void;
  10761. /**
  10762. * Sets the stencil operation to use when stencil passes
  10763. * @param operation defines the stencil operation to use when stencil passes
  10764. */
  10765. setStencilOperationPass(operation: number): void;
  10766. /**
  10767. * Sets a boolean indicating if the dithering state is enabled or disabled
  10768. * @param value defines the dithering state
  10769. */
  10770. setDitheringState(value: boolean): void;
  10771. /**
  10772. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10773. * @param value defines the rasterizer state
  10774. */
  10775. setRasterizerState(value: boolean): void;
  10776. /**
  10777. * stop executing a render loop function and remove it from the execution array
  10778. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10779. */
  10780. stopRenderLoop(renderFunction?: () => void): void;
  10781. /** @hidden */
  10782. _renderLoop(): void;
  10783. /**
  10784. * Register and execute a render loop. The engine can have more than one render function
  10785. * @param renderFunction defines the function to continuously execute
  10786. */
  10787. runRenderLoop(renderFunction: () => void): void;
  10788. /**
  10789. * Toggle full screen mode
  10790. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10791. */
  10792. switchFullscreen(requestPointerLock: boolean): void;
  10793. /**
  10794. * Clear the current render buffer or the current render target (if any is set up)
  10795. * @param color defines the color to use
  10796. * @param backBuffer defines if the back buffer must be cleared
  10797. * @param depth defines if the depth buffer must be cleared
  10798. * @param stencil defines if the stencil buffer must be cleared
  10799. */
  10800. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10801. /**
  10802. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10803. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10804. * @param y defines the y-coordinate of the corner of the clear rectangle
  10805. * @param width defines the width of the clear rectangle
  10806. * @param height defines the height of the clear rectangle
  10807. * @param clearColor defines the clear color
  10808. */
  10809. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10810. private _viewportCached;
  10811. /** @hidden */
  10812. _viewport(x: number, y: number, width: number, height: number): void;
  10813. /**
  10814. * Set the WebGL's viewport
  10815. * @param viewport defines the viewport element to be used
  10816. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10817. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10818. */
  10819. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10820. /**
  10821. * Directly set the WebGL Viewport
  10822. * @param x defines the x coordinate of the viewport (in screen space)
  10823. * @param y defines the y coordinate of the viewport (in screen space)
  10824. * @param width defines the width of the viewport (in screen space)
  10825. * @param height defines the height of the viewport (in screen space)
  10826. * @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
  10827. */
  10828. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10829. /**
  10830. * Begin a new frame
  10831. */
  10832. beginFrame(): void;
  10833. /**
  10834. * Enf the current frame
  10835. */
  10836. endFrame(): void;
  10837. /**
  10838. * Resize the view according to the canvas' size
  10839. */
  10840. resize(): void;
  10841. /**
  10842. * Force a specific size of the canvas
  10843. * @param width defines the new canvas' width
  10844. * @param height defines the new canvas' height
  10845. */
  10846. setSize(width: number, height: number): void;
  10847. /**
  10848. * Gets a boolean indicating if a webVR device was detected
  10849. * @returns true if a webVR device was detected
  10850. */
  10851. isVRDevicePresent(): boolean;
  10852. /**
  10853. * Gets the current webVR device
  10854. * @returns the current webVR device (or null)
  10855. */
  10856. getVRDevice(): any;
  10857. /**
  10858. * Initializes a webVR display and starts listening to display change events
  10859. * The onVRDisplayChangedObservable will be notified upon these changes
  10860. * @returns The onVRDisplayChangedObservable
  10861. */
  10862. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10863. /**
  10864. * Initializes a webVR display and starts listening to display change events
  10865. * The onVRDisplayChangedObservable will be notified upon these changes
  10866. * @returns A promise containing a VRDisplay and if vr is supported
  10867. */
  10868. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10869. /**
  10870. * Call this function to switch to webVR mode
  10871. * Will do nothing if webVR is not supported or if there is no webVR device
  10872. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10873. */
  10874. enableVR(): void;
  10875. /**
  10876. * Call this function to leave webVR mode
  10877. * Will do nothing if webVR is not supported or if there is no webVR device
  10878. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10879. */
  10880. disableVR(): void;
  10881. private _onVRFullScreenTriggered;
  10882. private _getVRDisplaysAsync;
  10883. /**
  10884. * Binds the frame buffer to the specified texture.
  10885. * @param texture The texture to render to or null for the default canvas
  10886. * @param faceIndex The face of the texture to render to in case of cube texture
  10887. * @param requiredWidth The width of the target to render to
  10888. * @param requiredHeight The height of the target to render to
  10889. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10890. * @param depthStencilTexture The depth stencil texture to use to render
  10891. * @param lodLevel defines le lod level to bind to the frame buffer
  10892. */
  10893. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10894. private bindUnboundFramebuffer;
  10895. /**
  10896. * Unbind the current render target texture from the webGL context
  10897. * @param texture defines the render target texture to unbind
  10898. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10899. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10900. */
  10901. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10902. /**
  10903. * Unbind a list of render target textures from the webGL context
  10904. * This is used only when drawBuffer extension or webGL2 are active
  10905. * @param textures defines the render target textures to unbind
  10906. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10907. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10908. */
  10909. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10910. /**
  10911. * Force the mipmap generation for the given render target texture
  10912. * @param texture defines the render target texture to use
  10913. */
  10914. generateMipMapsForCubemap(texture: InternalTexture): void;
  10915. /**
  10916. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10917. */
  10918. flushFramebuffer(): void;
  10919. /**
  10920. * Unbind the current render target and bind the default framebuffer
  10921. */
  10922. restoreDefaultFramebuffer(): void;
  10923. /**
  10924. * Create an uniform buffer
  10925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10926. * @param elements defines the content of the uniform buffer
  10927. * @returns the webGL uniform buffer
  10928. */
  10929. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10930. /**
  10931. * Create a dynamic uniform buffer
  10932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10933. * @param elements defines the content of the uniform buffer
  10934. * @returns the webGL uniform buffer
  10935. */
  10936. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10937. /**
  10938. * Update an existing uniform buffer
  10939. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10940. * @param uniformBuffer defines the target uniform buffer
  10941. * @param elements defines the content to update
  10942. * @param offset defines the offset in the uniform buffer where update should start
  10943. * @param count defines the size of the data to update
  10944. */
  10945. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10946. private _resetVertexBufferBinding;
  10947. /**
  10948. * Creates a vertex buffer
  10949. * @param data the data for the vertex buffer
  10950. * @returns the new WebGL static buffer
  10951. */
  10952. createVertexBuffer(data: DataArray): WebGLBuffer;
  10953. /**
  10954. * Creates a dynamic vertex buffer
  10955. * @param data the data for the dynamic vertex buffer
  10956. * @returns the new WebGL dynamic buffer
  10957. */
  10958. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10959. /**
  10960. * Update a dynamic index buffer
  10961. * @param indexBuffer defines the target index buffer
  10962. * @param indices defines the data to update
  10963. * @param offset defines the offset in the target index buffer where update should start
  10964. */
  10965. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10966. /**
  10967. * Updates a dynamic vertex buffer.
  10968. * @param vertexBuffer the vertex buffer to update
  10969. * @param data the data used to update the vertex buffer
  10970. * @param byteOffset the byte offset of the data
  10971. * @param byteLength the byte length of the data
  10972. */
  10973. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10974. private _resetIndexBufferBinding;
  10975. /**
  10976. * Creates a new index buffer
  10977. * @param indices defines the content of the index buffer
  10978. * @param updatable defines if the index buffer must be updatable
  10979. * @returns a new webGL buffer
  10980. */
  10981. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10982. /**
  10983. * Bind a webGL buffer to the webGL context
  10984. * @param buffer defines the buffer to bind
  10985. */
  10986. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10987. /**
  10988. * Bind an uniform buffer to the current webGL context
  10989. * @param buffer defines the buffer to bind
  10990. */
  10991. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10992. /**
  10993. * Bind a buffer to the current webGL context at a given location
  10994. * @param buffer defines the buffer to bind
  10995. * @param location defines the index where to bind the buffer
  10996. */
  10997. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10998. /**
  10999. * Bind a specific block at a given index in a specific shader program
  11000. * @param shaderProgram defines the shader program
  11001. * @param blockName defines the block name
  11002. * @param index defines the index where to bind the block
  11003. */
  11004. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11005. private bindIndexBuffer;
  11006. private bindBuffer;
  11007. /**
  11008. * update the bound buffer with the given data
  11009. * @param data defines the data to update
  11010. */
  11011. updateArrayBuffer(data: Float32Array): void;
  11012. private _vertexAttribPointer;
  11013. private _bindIndexBufferWithCache;
  11014. private _bindVertexBuffersAttributes;
  11015. /**
  11016. * Records a vertex array object
  11017. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11018. * @param vertexBuffers defines the list of vertex buffers to store
  11019. * @param indexBuffer defines the index buffer to store
  11020. * @param effect defines the effect to store
  11021. * @returns the new vertex array object
  11022. */
  11023. recordVertexArrayObject(vertexBuffers: {
  11024. [key: string]: VertexBuffer;
  11025. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11026. /**
  11027. * Bind a specific vertex array object
  11028. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11029. * @param vertexArrayObject defines the vertex array object to bind
  11030. * @param indexBuffer defines the index buffer to bind
  11031. */
  11032. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11033. /**
  11034. * Bind webGl buffers directly to the webGL context
  11035. * @param vertexBuffer defines the vertex buffer to bind
  11036. * @param indexBuffer defines the index buffer to bind
  11037. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11038. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11039. * @param effect defines the effect associated with the vertex buffer
  11040. */
  11041. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11042. private _unbindVertexArrayObject;
  11043. /**
  11044. * Bind a list of vertex buffers to the webGL context
  11045. * @param vertexBuffers defines the list of vertex buffers to bind
  11046. * @param indexBuffer defines the index buffer to bind
  11047. * @param effect defines the effect associated with the vertex buffers
  11048. */
  11049. bindBuffers(vertexBuffers: {
  11050. [key: string]: Nullable<VertexBuffer>;
  11051. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11052. /**
  11053. * Unbind all instance attributes
  11054. */
  11055. unbindInstanceAttributes(): void;
  11056. /**
  11057. * Release and free the memory of a vertex array object
  11058. * @param vao defines the vertex array object to delete
  11059. */
  11060. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11061. /** @hidden */
  11062. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11063. /**
  11064. * Creates a webGL buffer to use with instanciation
  11065. * @param capacity defines the size of the buffer
  11066. * @returns the webGL buffer
  11067. */
  11068. createInstancesBuffer(capacity: number): WebGLBuffer;
  11069. /**
  11070. * Delete a webGL buffer used with instanciation
  11071. * @param buffer defines the webGL buffer to delete
  11072. */
  11073. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11074. /**
  11075. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11076. * @param instancesBuffer defines the webGL buffer to update and bind
  11077. * @param data defines the data to store in the buffer
  11078. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11079. */
  11080. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11081. /**
  11082. * Apply all cached states (depth, culling, stencil and alpha)
  11083. */
  11084. applyStates(): void;
  11085. /**
  11086. * Send a draw order
  11087. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11088. * @param indexStart defines the starting index
  11089. * @param indexCount defines the number of index to draw
  11090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11091. */
  11092. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11093. /**
  11094. * Draw a list of points
  11095. * @param verticesStart defines the index of first vertex to draw
  11096. * @param verticesCount defines the count of vertices to draw
  11097. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11098. */
  11099. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11100. /**
  11101. * Draw a list of unindexed primitives
  11102. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11103. * @param verticesStart defines the index of first vertex to draw
  11104. * @param verticesCount defines the count of vertices to draw
  11105. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11106. */
  11107. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11108. /**
  11109. * Draw a list of indexed primitives
  11110. * @param fillMode defines the primitive to use
  11111. * @param indexStart defines the starting index
  11112. * @param indexCount defines the number of index to draw
  11113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11114. */
  11115. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11116. /**
  11117. * Draw a list of unindexed primitives
  11118. * @param fillMode defines the primitive to use
  11119. * @param verticesStart defines the index of first vertex to draw
  11120. * @param verticesCount defines the count of vertices to draw
  11121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11122. */
  11123. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11124. private _drawMode;
  11125. /** @hidden */
  11126. _releaseEffect(effect: Effect): void;
  11127. /** @hidden */
  11128. _deleteProgram(program: WebGLProgram): void;
  11129. /**
  11130. * Create a new effect (used to store vertex/fragment shaders)
  11131. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11132. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11133. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11134. * @param samplers defines an array of string used to represent textures
  11135. * @param defines defines the string containing the defines to use to compile the shaders
  11136. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11137. * @param onCompiled defines a function to call when the effect creation is successful
  11138. * @param onError defines a function to call when the effect creation has failed
  11139. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11140. * @returns the new Effect
  11141. */
  11142. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  11143. private _compileShader;
  11144. private _compileRawShader;
  11145. /**
  11146. * Directly creates a webGL program
  11147. * @param vertexCode defines the vertex shader code to use
  11148. * @param fragmentCode defines the fragment shader code to use
  11149. * @param context defines the webGL context to use (if not set, the current one will be used)
  11150. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11151. * @returns the new webGL program
  11152. */
  11153. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11154. /**
  11155. * Creates a webGL program
  11156. * @param vertexCode defines the vertex shader code to use
  11157. * @param fragmentCode defines the fragment shader code to use
  11158. * @param defines defines the string containing the defines to use to compile the shaders
  11159. * @param context defines the webGL context to use (if not set, the current one will be used)
  11160. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11161. * @returns the new webGL program
  11162. */
  11163. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11164. private _createShaderProgram;
  11165. private _finalizeProgram;
  11166. /** @hidden */
  11167. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11168. /** @hidden */
  11169. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11170. /**
  11171. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11172. * @param shaderProgram defines the webGL program to use
  11173. * @param uniformsNames defines the list of uniform names
  11174. * @returns an array of webGL uniform locations
  11175. */
  11176. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11177. /**
  11178. * Gets the lsit of active attributes for a given webGL program
  11179. * @param shaderProgram defines the webGL program to use
  11180. * @param attributesNames defines the list of attribute names to get
  11181. * @returns an array of indices indicating the offset of each attribute
  11182. */
  11183. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11184. /**
  11185. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11186. * @param effect defines the effect to activate
  11187. */
  11188. enableEffect(effect: Nullable<Effect>): void;
  11189. /**
  11190. * Set the value of an uniform to an array of int32
  11191. * @param uniform defines the webGL uniform location where to store the value
  11192. * @param array defines the array of int32 to store
  11193. */
  11194. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11195. /**
  11196. * Set the value of an uniform to an array of int32 (stored as vec2)
  11197. * @param uniform defines the webGL uniform location where to store the value
  11198. * @param array defines the array of int32 to store
  11199. */
  11200. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11201. /**
  11202. * Set the value of an uniform to an array of int32 (stored as vec3)
  11203. * @param uniform defines the webGL uniform location where to store the value
  11204. * @param array defines the array of int32 to store
  11205. */
  11206. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11207. /**
  11208. * Set the value of an uniform to an array of int32 (stored as vec4)
  11209. * @param uniform defines the webGL uniform location where to store the value
  11210. * @param array defines the array of int32 to store
  11211. */
  11212. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11213. /**
  11214. * Set the value of an uniform to an array of float32
  11215. * @param uniform defines the webGL uniform location where to store the value
  11216. * @param array defines the array of float32 to store
  11217. */
  11218. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11219. /**
  11220. * Set the value of an uniform to an array of float32 (stored as vec2)
  11221. * @param uniform defines the webGL uniform location where to store the value
  11222. * @param array defines the array of float32 to store
  11223. */
  11224. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11225. /**
  11226. * Set the value of an uniform to an array of float32 (stored as vec3)
  11227. * @param uniform defines the webGL uniform location where to store the value
  11228. * @param array defines the array of float32 to store
  11229. */
  11230. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11231. /**
  11232. * Set the value of an uniform to an array of float32 (stored as vec4)
  11233. * @param uniform defines the webGL uniform location where to store the value
  11234. * @param array defines the array of float32 to store
  11235. */
  11236. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11237. /**
  11238. * Set the value of an uniform to an array of number
  11239. * @param uniform defines the webGL uniform location where to store the value
  11240. * @param array defines the array of number to store
  11241. */
  11242. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11243. /**
  11244. * Set the value of an uniform to an array of number (stored as vec2)
  11245. * @param uniform defines the webGL uniform location where to store the value
  11246. * @param array defines the array of number to store
  11247. */
  11248. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11249. /**
  11250. * Set the value of an uniform to an array of number (stored as vec3)
  11251. * @param uniform defines the webGL uniform location where to store the value
  11252. * @param array defines the array of number to store
  11253. */
  11254. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11255. /**
  11256. * Set the value of an uniform to an array of number (stored as vec4)
  11257. * @param uniform defines the webGL uniform location where to store the value
  11258. * @param array defines the array of number to store
  11259. */
  11260. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11261. /**
  11262. * Set the value of an uniform to an array of float32 (stored as matrices)
  11263. * @param uniform defines the webGL uniform location where to store the value
  11264. * @param matrices defines the array of float32 to store
  11265. */
  11266. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11267. /**
  11268. * Set the value of an uniform to a matrix
  11269. * @param uniform defines the webGL uniform location where to store the value
  11270. * @param matrix defines the matrix to store
  11271. */
  11272. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11273. /**
  11274. * Set the value of an uniform to a matrix (3x3)
  11275. * @param uniform defines the webGL uniform location where to store the value
  11276. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11277. */
  11278. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11279. /**
  11280. * Set the value of an uniform to a matrix (2x2)
  11281. * @param uniform defines the webGL uniform location where to store the value
  11282. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11283. */
  11284. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11285. /**
  11286. * Set the value of an uniform to a number (int)
  11287. * @param uniform defines the webGL uniform location where to store the value
  11288. * @param value defines the int number to store
  11289. */
  11290. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11291. /**
  11292. * Set the value of an uniform to a number (float)
  11293. * @param uniform defines the webGL uniform location where to store the value
  11294. * @param value defines the float number to store
  11295. */
  11296. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11297. /**
  11298. * Set the value of an uniform to a vec2
  11299. * @param uniform defines the webGL uniform location where to store the value
  11300. * @param x defines the 1st component of the value
  11301. * @param y defines the 2nd component of the value
  11302. */
  11303. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11304. /**
  11305. * Set the value of an uniform to a vec3
  11306. * @param uniform defines the webGL uniform location where to store the value
  11307. * @param x defines the 1st component of the value
  11308. * @param y defines the 2nd component of the value
  11309. * @param z defines the 3rd component of the value
  11310. */
  11311. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11312. /**
  11313. * Set the value of an uniform to a boolean
  11314. * @param uniform defines the webGL uniform location where to store the value
  11315. * @param bool defines the boolean to store
  11316. */
  11317. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11318. /**
  11319. * Set the value of an uniform to a vec4
  11320. * @param uniform defines the webGL uniform location where to store the value
  11321. * @param x defines the 1st component of the value
  11322. * @param y defines the 2nd component of the value
  11323. * @param z defines the 3rd component of the value
  11324. * @param w defines the 4th component of the value
  11325. */
  11326. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11327. /**
  11328. * Set the value of an uniform to a Color3
  11329. * @param uniform defines the webGL uniform location where to store the value
  11330. * @param color3 defines the color to store
  11331. */
  11332. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11333. /**
  11334. * Set the value of an uniform to a Color3 and an alpha value
  11335. * @param uniform defines the webGL uniform location where to store the value
  11336. * @param color3 defines the color to store
  11337. * @param alpha defines the alpha component to store
  11338. */
  11339. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11340. /**
  11341. * Sets a Color4 on a uniform variable
  11342. * @param uniform defines the uniform location
  11343. * @param color4 defines the value to be set
  11344. */
  11345. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11346. /**
  11347. * Set various states to the webGL context
  11348. * @param culling defines backface culling state
  11349. * @param zOffset defines the value to apply to zOffset (0 by default)
  11350. * @param force defines if states must be applied even if cache is up to date
  11351. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11352. */
  11353. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11354. /**
  11355. * Set the z offset to apply to current rendering
  11356. * @param value defines the offset to apply
  11357. */
  11358. setZOffset(value: number): void;
  11359. /**
  11360. * Gets the current value of the zOffset
  11361. * @returns the current zOffset state
  11362. */
  11363. getZOffset(): number;
  11364. /**
  11365. * Enable or disable depth buffering
  11366. * @param enable defines the state to set
  11367. */
  11368. setDepthBuffer(enable: boolean): void;
  11369. /**
  11370. * Gets a boolean indicating if depth writing is enabled
  11371. * @returns the current depth writing state
  11372. */
  11373. getDepthWrite(): boolean;
  11374. /**
  11375. * Enable or disable depth writing
  11376. * @param enable defines the state to set
  11377. */
  11378. setDepthWrite(enable: boolean): void;
  11379. /**
  11380. * Enable or disable color writing
  11381. * @param enable defines the state to set
  11382. */
  11383. setColorWrite(enable: boolean): void;
  11384. /**
  11385. * Gets a boolean indicating if color writing is enabled
  11386. * @returns the current color writing state
  11387. */
  11388. getColorWrite(): boolean;
  11389. /**
  11390. * Sets alpha constants used by some alpha blending modes
  11391. * @param r defines the red component
  11392. * @param g defines the green component
  11393. * @param b defines the blue component
  11394. * @param a defines the alpha component
  11395. */
  11396. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11397. /**
  11398. * Sets the current alpha mode
  11399. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11400. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11402. */
  11403. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11404. /**
  11405. * Gets the current alpha mode
  11406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11407. * @returns the current alpha mode
  11408. */
  11409. getAlphaMode(): number;
  11410. /**
  11411. * Clears the list of texture accessible through engine.
  11412. * This can help preventing texture load conflict due to name collision.
  11413. */
  11414. clearInternalTexturesCache(): void;
  11415. /**
  11416. * Force the entire cache to be cleared
  11417. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11418. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11419. */
  11420. wipeCaches(bruteForce?: boolean): void;
  11421. /**
  11422. * Set the compressed texture format to use, based on the formats you have, and the formats
  11423. * supported by the hardware / browser.
  11424. *
  11425. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11426. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11427. * to API arguments needed to compressed textures. This puts the burden on the container
  11428. * generator to house the arcane code for determining these for current & future formats.
  11429. *
  11430. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11431. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11432. *
  11433. * Note: The result of this call is not taken into account when a texture is base64.
  11434. *
  11435. * @param formatsAvailable defines the list of those format families you have created
  11436. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11437. *
  11438. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11439. * @returns The extension selected.
  11440. */
  11441. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11442. private _getSamplingParameters;
  11443. private _partialLoadImg;
  11444. private _cascadeLoadImgs;
  11445. /** @hidden */
  11446. _createTexture(): WebGLTexture;
  11447. /**
  11448. * Usually called from BABYLON.Texture.ts.
  11449. * Passed information to create a WebGLTexture
  11450. * @param urlArg defines a value which contains one of the following:
  11451. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11452. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11453. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11455. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11456. * @param scene needed for loading to the correct scene
  11457. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11458. * @param onLoad optional callback to be called upon successful completion
  11459. * @param onError optional callback to be called upon failure
  11460. * @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
  11461. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11462. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11463. * @param forcedExtension defines the extension to use to pick the right loader
  11464. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11465. */
  11466. 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>): InternalTexture;
  11467. private _rescaleTexture;
  11468. /**
  11469. * Update a raw texture
  11470. * @param texture defines the texture to update
  11471. * @param data defines the data to store in the texture
  11472. * @param format defines the format of the data
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. * @param compression defines the compression used (null by default)
  11475. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11476. */
  11477. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11478. /**
  11479. * Creates a raw texture
  11480. * @param data defines the data to store in the texture
  11481. * @param width defines the width of the texture
  11482. * @param height defines the height of the texture
  11483. * @param format defines the format of the data
  11484. * @param generateMipMaps defines if the engine should generate the mip levels
  11485. * @param invertY defines if data must be stored with Y axis inverted
  11486. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11487. * @param compression defines the compression used (null by default)
  11488. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11489. * @returns the raw texture inside an InternalTexture
  11490. */
  11491. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11492. private _unpackFlipYCached;
  11493. /**
  11494. * In case you are sharing the context with other applications, it might
  11495. * be interested to not cache the unpack flip y state to ensure a consistent
  11496. * value would be set.
  11497. */
  11498. enableUnpackFlipYCached: boolean;
  11499. /** @hidden */
  11500. _unpackFlipY(value: boolean): void;
  11501. /** @hidden */
  11502. _getUnpackAlignement(): number;
  11503. /**
  11504. * Creates a dynamic texture
  11505. * @param width defines the width of the texture
  11506. * @param height defines the height of the texture
  11507. * @param generateMipMaps defines if the engine should generate the mip levels
  11508. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11509. * @returns the dynamic texture inside an InternalTexture
  11510. */
  11511. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11512. /**
  11513. * Update the sampling mode of a given texture
  11514. * @param samplingMode defines the required sampling mode
  11515. * @param texture defines the texture to update
  11516. */
  11517. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11518. /**
  11519. * Update the content of a dynamic texture
  11520. * @param texture defines the texture to update
  11521. * @param canvas defines the canvas containing the source
  11522. * @param invertY defines if data must be stored with Y axis inverted
  11523. * @param premulAlpha defines if alpha is stored as premultiplied
  11524. * @param format defines the format of the data
  11525. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11526. */
  11527. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11528. /**
  11529. * Update a video texture
  11530. * @param texture defines the texture to update
  11531. * @param video defines the video element to use
  11532. * @param invertY defines if data must be stored with Y axis inverted
  11533. */
  11534. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11535. /**
  11536. * Updates a depth texture Comparison Mode and Function.
  11537. * If the comparison Function is equal to 0, the mode will be set to none.
  11538. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11539. * @param texture The texture to set the comparison function for
  11540. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11541. */
  11542. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11543. private _setupDepthStencilTexture;
  11544. /**
  11545. * Creates a depth stencil texture.
  11546. * This is only available in WebGL 2 or with the depth texture extension available.
  11547. * @param size The size of face edge in the texture.
  11548. * @param options The options defining the texture.
  11549. * @returns The texture
  11550. */
  11551. createDepthStencilTexture(size: number | {
  11552. width: number;
  11553. height: number;
  11554. }, options: DepthTextureCreationOptions): InternalTexture;
  11555. /**
  11556. * Creates a depth stencil texture.
  11557. * This is only available in WebGL 2 or with the depth texture extension available.
  11558. * @param size The size of face edge in the texture.
  11559. * @param options The options defining the texture.
  11560. * @returns The texture
  11561. */
  11562. private _createDepthStencilTexture;
  11563. /**
  11564. * Creates a depth stencil cube texture.
  11565. * This is only available in WebGL 2.
  11566. * @param size The size of face edge in the cube texture.
  11567. * @param options The options defining the cube texture.
  11568. * @returns The cube texture
  11569. */
  11570. private _createDepthStencilCubeTexture;
  11571. /**
  11572. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11573. * @param renderTarget The render target to set the frame buffer for
  11574. */
  11575. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11576. /**
  11577. * Creates a new render target texture
  11578. * @param size defines the size of the texture
  11579. * @param options defines the options used to create the texture
  11580. * @returns a new render target texture stored in an InternalTexture
  11581. */
  11582. createRenderTargetTexture(size: number | {
  11583. width: number;
  11584. height: number;
  11585. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11586. /**
  11587. * Create a multi render target texture
  11588. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11589. * @param size defines the size of the texture
  11590. * @param options defines the creation options
  11591. * @returns the cube texture as an InternalTexture
  11592. */
  11593. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11594. private _setupFramebufferDepthAttachments;
  11595. /**
  11596. * Updates the sample count of a render target texture
  11597. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11598. * @param texture defines the texture to update
  11599. * @param samples defines the sample count to set
  11600. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11601. */
  11602. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11603. /**
  11604. * Update the sample count for a given multiple render target texture
  11605. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11606. * @param textures defines the textures to update
  11607. * @param samples defines the sample count to set
  11608. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11609. */
  11610. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11611. /** @hidden */
  11612. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11613. /** @hidden */
  11614. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11615. /** @hidden */
  11616. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11617. /** @hidden */
  11618. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11619. /**
  11620. * Creates a new render target cube texture
  11621. * @param size defines the size of the texture
  11622. * @param options defines the options used to create the texture
  11623. * @returns a new render target cube texture stored in an InternalTexture
  11624. */
  11625. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11626. /**
  11627. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11628. * @param rootUrl defines the url where the file to load is located
  11629. * @param scene defines the current scene
  11630. * @param lodScale defines scale to apply to the mip map selection
  11631. * @param lodOffset defines offset to apply to the mip map selection
  11632. * @param onLoad defines an optional callback raised when the texture is loaded
  11633. * @param onError defines an optional callback raised if there is an issue to load the texture
  11634. * @param format defines the format of the data
  11635. * @param forcedExtension defines the extension to use to pick the right loader
  11636. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11637. * @returns the cube texture as an InternalTexture
  11638. */
  11639. 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;
  11640. /**
  11641. * Creates a cube texture
  11642. * @param rootUrl defines the url where the files to load is located
  11643. * @param scene defines the current scene
  11644. * @param files defines the list of files to load (1 per face)
  11645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11646. * @param onLoad defines an optional callback raised when the texture is loaded
  11647. * @param onError defines an optional callback raised if there is an issue to load the texture
  11648. * @param format defines the format of the data
  11649. * @param forcedExtension defines the extension to use to pick the right loader
  11650. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11653. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11654. * @returns the cube texture as an InternalTexture
  11655. */
  11656. 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>): InternalTexture;
  11657. /**
  11658. * @hidden
  11659. */
  11660. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11661. /**
  11662. * Update a raw cube texture
  11663. * @param texture defines the texture to udpdate
  11664. * @param data defines the data to store
  11665. * @param format defines the data format
  11666. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11667. * @param invertY defines if data must be stored with Y axis inverted
  11668. * @param compression defines the compression used (null by default)
  11669. * @param level defines which level of the texture to update
  11670. */
  11671. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11672. /**
  11673. * Creates a new raw cube texture
  11674. * @param data defines the array of data to use to create each face
  11675. * @param size defines the size of the textures
  11676. * @param format defines the format of the data
  11677. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11678. * @param generateMipMaps defines if the engine should generate the mip levels
  11679. * @param invertY defines if data must be stored with Y axis inverted
  11680. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11681. * @param compression defines the compression used (null by default)
  11682. * @returns the cube texture as an InternalTexture
  11683. */
  11684. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11685. /**
  11686. * Creates a new raw cube texture from a specified url
  11687. * @param url defines the url where the data is located
  11688. * @param scene defines the current scene
  11689. * @param size defines the size of the textures
  11690. * @param format defines the format of the data
  11691. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11692. * @param noMipmap defines if the engine should avoid generating the mip levels
  11693. * @param callback defines a callback used to extract texture data from loaded data
  11694. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11695. * @param onLoad defines a callback called when texture is loaded
  11696. * @param onError defines a callback called if there is an error
  11697. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @returns the cube texture as an InternalTexture
  11700. */
  11701. 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;
  11702. /**
  11703. * Update a raw 3D texture
  11704. * @param texture defines the texture to update
  11705. * @param data defines the data to store
  11706. * @param format defines the data format
  11707. * @param invertY defines if data must be stored with Y axis inverted
  11708. * @param compression defines the used compression (can be null)
  11709. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11710. */
  11711. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11712. /**
  11713. * Creates a new raw 3D texture
  11714. * @param data defines the data used to create the texture
  11715. * @param width defines the width of the texture
  11716. * @param height defines the height of the texture
  11717. * @param depth defines the depth of the texture
  11718. * @param format defines the format of the texture
  11719. * @param generateMipMaps defines if the engine must generate mip levels
  11720. * @param invertY defines if data must be stored with Y axis inverted
  11721. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11722. * @param compression defines the compressed used (can be null)
  11723. * @param textureType defines the compressed used (can be null)
  11724. * @returns a new raw 3D texture (stored in an InternalTexture)
  11725. */
  11726. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11727. private _prepareWebGLTextureContinuation;
  11728. private _prepareWebGLTexture;
  11729. private _convertRGBtoRGBATextureData;
  11730. /** @hidden */
  11731. _releaseFramebufferObjects(texture: InternalTexture): void;
  11732. /** @hidden */
  11733. _releaseTexture(texture: InternalTexture): void;
  11734. private setProgram;
  11735. private _boundUniforms;
  11736. /**
  11737. * Binds an effect to the webGL context
  11738. * @param effect defines the effect to bind
  11739. */
  11740. bindSamplers(effect: Effect): void;
  11741. private _moveBoundTextureOnTop;
  11742. private _getCorrectTextureChannel;
  11743. private _linkTrackers;
  11744. private _removeDesignatedSlot;
  11745. private _activateCurrentTexture;
  11746. /** @hidden */
  11747. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11748. /** @hidden */
  11749. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11750. /**
  11751. * Sets a texture to the webGL context from a postprocess
  11752. * @param channel defines the channel to use
  11753. * @param postProcess defines the source postprocess
  11754. */
  11755. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11756. /**
  11757. * Binds the output of the passed in post process to the texture channel specified
  11758. * @param channel The channel the texture should be bound to
  11759. * @param postProcess The post process which's output should be bound
  11760. */
  11761. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11762. /**
  11763. * Unbind all textures from the webGL context
  11764. */
  11765. unbindAllTextures(): void;
  11766. /**
  11767. * Sets a texture to the according uniform.
  11768. * @param channel The texture channel
  11769. * @param uniform The uniform to set
  11770. * @param texture The texture to apply
  11771. */
  11772. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11773. /**
  11774. * Sets a depth stencil texture from a render target to the according uniform.
  11775. * @param channel The texture channel
  11776. * @param uniform The uniform to set
  11777. * @param texture The render target texture containing the depth stencil texture to apply
  11778. */
  11779. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11780. private _bindSamplerUniformToChannel;
  11781. private _getTextureWrapMode;
  11782. private _setTexture;
  11783. /**
  11784. * Sets an array of texture to the webGL context
  11785. * @param channel defines the channel where the texture array must be set
  11786. * @param uniform defines the associated uniform location
  11787. * @param textures defines the array of textures to bind
  11788. */
  11789. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11790. /** @hidden */
  11791. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11792. private _setTextureParameterFloat;
  11793. private _setTextureParameterInteger;
  11794. /**
  11795. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11796. * @param x defines the x coordinate of the rectangle where pixels must be read
  11797. * @param y defines the y coordinate of the rectangle where pixels must be read
  11798. * @param width defines the width of the rectangle where pixels must be read
  11799. * @param height defines the height of the rectangle where pixels must be read
  11800. * @returns a Uint8Array containing RGBA colors
  11801. */
  11802. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11803. /**
  11804. * Add an externaly attached data from its key.
  11805. * This method call will fail and return false, if such key already exists.
  11806. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11807. * @param key the unique key that identifies the data
  11808. * @param data the data object to associate to the key for this Engine instance
  11809. * @return true if no such key were already present and the data was added successfully, false otherwise
  11810. */
  11811. addExternalData<T>(key: string, data: T): boolean;
  11812. /**
  11813. * Get an externaly attached data from its key
  11814. * @param key the unique key that identifies the data
  11815. * @return the associated data, if present (can be null), or undefined if not present
  11816. */
  11817. getExternalData<T>(key: string): T;
  11818. /**
  11819. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11820. * @param key the unique key that identifies the data
  11821. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11822. * @return the associated data, can be null if the factory returned null.
  11823. */
  11824. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11825. /**
  11826. * Remove an externaly attached data from the Engine instance
  11827. * @param key the unique key that identifies the data
  11828. * @return true if the data was successfully removed, false if it doesn't exist
  11829. */
  11830. removeExternalData(key: string): boolean;
  11831. /**
  11832. * Unbind all vertex attributes from the webGL context
  11833. */
  11834. unbindAllAttributes(): void;
  11835. /**
  11836. * 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
  11837. */
  11838. releaseEffects(): void;
  11839. /**
  11840. * Dispose and release all associated resources
  11841. */
  11842. dispose(): void;
  11843. /**
  11844. * Display the loading screen
  11845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11846. */
  11847. displayLoadingUI(): void;
  11848. /**
  11849. * Hide the loading screen
  11850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11851. */
  11852. hideLoadingUI(): void;
  11853. /**
  11854. * Gets the current loading screen object
  11855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11856. */
  11857. /**
  11858. * Sets the current loading screen object
  11859. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11860. */
  11861. loadingScreen: ILoadingScreen;
  11862. /**
  11863. * Sets the current loading screen text
  11864. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11865. */
  11866. loadingUIText: string;
  11867. /**
  11868. * Sets the current loading screen background color
  11869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11870. */
  11871. loadingUIBackgroundColor: string;
  11872. /**
  11873. * Attach a new callback raised when context lost event is fired
  11874. * @param callback defines the callback to call
  11875. */
  11876. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11877. /**
  11878. * Attach a new callback raised when context restored event is fired
  11879. * @param callback defines the callback to call
  11880. */
  11881. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11882. /**
  11883. * Gets the source code of the vertex shader associated with a specific webGL program
  11884. * @param program defines the program to use
  11885. * @returns a string containing the source code of the vertex shader associated with the program
  11886. */
  11887. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11888. /**
  11889. * Gets the source code of the fragment shader associated with a specific webGL program
  11890. * @param program defines the program to use
  11891. * @returns a string containing the source code of the fragment shader associated with the program
  11892. */
  11893. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11894. /**
  11895. * Get the current error code of the webGL context
  11896. * @returns the error code
  11897. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11898. */
  11899. getError(): number;
  11900. /**
  11901. * Gets the current framerate
  11902. * @returns a number representing the framerate
  11903. */
  11904. getFps(): number;
  11905. /**
  11906. * Gets the time spent between current and previous frame
  11907. * @returns a number representing the delta time in ms
  11908. */
  11909. getDeltaTime(): number;
  11910. private _measureFps;
  11911. /** @hidden */
  11912. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11913. private _canRenderToFloatFramebuffer;
  11914. private _canRenderToHalfFloatFramebuffer;
  11915. private _canRenderToFramebuffer;
  11916. /** @hidden */
  11917. _getWebGLTextureType(type: number): number;
  11918. private _getInternalFormat;
  11919. /** @hidden */
  11920. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11921. /** @hidden */
  11922. _getRGBAMultiSampleBufferFormat(type: number): number;
  11923. /** @hidden */
  11924. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  11925. /** @hidden */
  11926. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11927. private _partialLoadFile;
  11928. private _cascadeLoadFiles;
  11929. /**
  11930. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11931. * @returns true if the engine can be created
  11932. * @ignorenaming
  11933. */
  11934. static isSupported(): boolean;
  11935. }
  11936. }
  11937. declare module BABYLON {
  11938. /**
  11939. * Options to create the null engine
  11940. */
  11941. class NullEngineOptions {
  11942. /**
  11943. * Render width (Default: 512)
  11944. */
  11945. renderWidth: number;
  11946. /**
  11947. * Render height (Default: 256)
  11948. */
  11949. renderHeight: number;
  11950. /**
  11951. * Texture size (Default: 512)
  11952. */
  11953. textureSize: number;
  11954. /**
  11955. * If delta time between frames should be constant
  11956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11957. */
  11958. deterministicLockstep: boolean;
  11959. /**
  11960. * Maximum about of steps between frames (Default: 4)
  11961. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11962. */
  11963. lockstepMaxSteps: number;
  11964. }
  11965. /**
  11966. * The null engine class provides support for headless version of babylon.js.
  11967. * This can be used in server side scenario or for testing purposes
  11968. */
  11969. class NullEngine extends Engine {
  11970. private _options;
  11971. /**
  11972. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11973. */
  11974. isDeterministicLockStep(): boolean;
  11975. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11976. getLockstepMaxSteps(): number;
  11977. /**
  11978. * Sets hardware scaling, used to save performance if needed
  11979. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11980. */
  11981. getHardwareScalingLevel(): number;
  11982. constructor(options?: NullEngineOptions);
  11983. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11984. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11985. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11986. getRenderWidth(useScreen?: boolean): number;
  11987. getRenderHeight(useScreen?: boolean): number;
  11988. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11989. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11990. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11991. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11992. bindSamplers(effect: Effect): void;
  11993. enableEffect(effect: Effect): void;
  11994. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11995. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11996. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11997. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11998. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11999. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12000. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12001. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12002. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12003. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12004. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12005. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12006. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12007. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12008. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12009. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12010. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12011. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12012. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12013. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12014. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12015. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12016. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12017. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12018. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12019. bindBuffers(vertexBuffers: {
  12020. [key: string]: VertexBuffer;
  12021. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12022. wipeCaches(bruteForce?: boolean): void;
  12023. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12024. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12025. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12026. /** @hidden */
  12027. _createTexture(): WebGLTexture;
  12028. /** @hidden */
  12029. _releaseTexture(texture: InternalTexture): void;
  12030. 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;
  12031. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12032. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12033. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12034. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12035. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12036. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12037. areAllEffectsReady(): boolean;
  12038. /**
  12039. * @hidden
  12040. * Get the current error code of the webGL context
  12041. * @returns the error code
  12042. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12043. */
  12044. getError(): number;
  12045. /** @hidden */
  12046. _getUnpackAlignement(): number;
  12047. /** @hidden */
  12048. _unpackFlipY(value: boolean): void;
  12049. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12050. /**
  12051. * Updates a dynamic vertex buffer.
  12052. * @param vertexBuffer the vertex buffer to update
  12053. * @param data the data used to update the vertex buffer
  12054. * @param byteOffset the byte offset of the data (optional)
  12055. * @param byteLength the byte length of the data (optional)
  12056. */
  12057. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12058. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12059. /** @hidden */
  12060. _bindTexture(channel: number, texture: InternalTexture): void;
  12061. /** @hidden */
  12062. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12063. releaseEffects(): void;
  12064. displayLoadingUI(): void;
  12065. hideLoadingUI(): void;
  12066. /** @hidden */
  12067. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12068. /** @hidden */
  12069. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12070. /** @hidden */
  12071. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12072. /** @hidden */
  12073. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12074. }
  12075. }
  12076. interface WebGLRenderingContext {
  12077. readonly RASTERIZER_DISCARD: number;
  12078. readonly DEPTH_COMPONENT24: number;
  12079. readonly TEXTURE_3D: number;
  12080. readonly TEXTURE_2D_ARRAY: number;
  12081. readonly TEXTURE_COMPARE_FUNC: number;
  12082. readonly TEXTURE_COMPARE_MODE: number;
  12083. readonly COMPARE_REF_TO_TEXTURE: number;
  12084. readonly TEXTURE_WRAP_R: number;
  12085. readonly HALF_FLOAT: number;
  12086. readonly RGB8: number;
  12087. readonly RED_INTEGER: number;
  12088. readonly RG_INTEGER: number;
  12089. readonly RGB_INTEGER: number;
  12090. readonly RGBA_INTEGER: number;
  12091. readonly R8_SNORM: number;
  12092. readonly RG8_SNORM: number;
  12093. readonly RGB8_SNORM: number;
  12094. readonly RGBA8_SNORM: number;
  12095. readonly R8I: number;
  12096. readonly RG8I: number;
  12097. readonly RGB8I: number;
  12098. readonly RGBA8I: number;
  12099. readonly R8UI: number;
  12100. readonly RG8UI: number;
  12101. readonly RGB8UI: number;
  12102. readonly RGBA8UI: number;
  12103. readonly R16I: number;
  12104. readonly RG16I: number;
  12105. readonly RGB16I: number;
  12106. readonly RGBA16I: number;
  12107. readonly R16UI: number;
  12108. readonly RG16UI: number;
  12109. readonly RGB16UI: number;
  12110. readonly RGBA16UI: number;
  12111. readonly R32I: number;
  12112. readonly RG32I: number;
  12113. readonly RGB32I: number;
  12114. readonly RGBA32I: number;
  12115. readonly R32UI: number;
  12116. readonly RG32UI: number;
  12117. readonly RGB32UI: number;
  12118. readonly RGBA32UI: number;
  12119. readonly RGB10_A2UI: number;
  12120. readonly R11F_G11F_B10F: number;
  12121. readonly RGB9_E5: number;
  12122. readonly RGB10_A2: number;
  12123. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12124. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12125. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12126. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12127. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12128. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12129. 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;
  12130. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12131. readonly TRANSFORM_FEEDBACK: number;
  12132. readonly INTERLEAVED_ATTRIBS: number;
  12133. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12134. createTransformFeedback(): WebGLTransformFeedback;
  12135. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12136. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12137. beginTransformFeedback(primitiveMode: number): void;
  12138. endTransformFeedback(): void;
  12139. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12140. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12141. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12142. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12143. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12144. }
  12145. interface ImageBitmap {
  12146. readonly width: number;
  12147. readonly height: number;
  12148. close(): void;
  12149. }
  12150. interface WebGLQuery extends WebGLObject {
  12151. }
  12152. declare var WebGLQuery: {
  12153. prototype: WebGLQuery;
  12154. new (): WebGLQuery;
  12155. };
  12156. interface WebGLSampler extends WebGLObject {
  12157. }
  12158. declare var WebGLSampler: {
  12159. prototype: WebGLSampler;
  12160. new (): WebGLSampler;
  12161. };
  12162. interface WebGLSync extends WebGLObject {
  12163. }
  12164. declare var WebGLSync: {
  12165. prototype: WebGLSync;
  12166. new (): WebGLSync;
  12167. };
  12168. interface WebGLTransformFeedback extends WebGLObject {
  12169. }
  12170. declare var WebGLTransformFeedback: {
  12171. prototype: WebGLTransformFeedback;
  12172. new (): WebGLTransformFeedback;
  12173. };
  12174. interface WebGLVertexArrayObject extends WebGLObject {
  12175. }
  12176. declare var WebGLVertexArrayObject: {
  12177. prototype: WebGLVertexArrayObject;
  12178. new (): WebGLVertexArrayObject;
  12179. };
  12180. declare module BABYLON {
  12181. /**
  12182. * Gather the list of keyboard event types as constants.
  12183. */
  12184. class KeyboardEventTypes {
  12185. /**
  12186. * The keydown event is fired when a key becomes active (pressed).
  12187. */
  12188. static readonly KEYDOWN: number;
  12189. /**
  12190. * The keyup event is fired when a key has been released.
  12191. */
  12192. static readonly KEYUP: number;
  12193. }
  12194. /**
  12195. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12196. */
  12197. class KeyboardInfo {
  12198. /**
  12199. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12200. */
  12201. type: number;
  12202. /**
  12203. * Defines the related dom event
  12204. */
  12205. event: KeyboardEvent;
  12206. /**
  12207. * Instantiates a new keyboard info.
  12208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12209. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12210. * @param event Defines the related dom event
  12211. */
  12212. constructor(
  12213. /**
  12214. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12215. */
  12216. type: number,
  12217. /**
  12218. * Defines the related dom event
  12219. */
  12220. event: KeyboardEvent);
  12221. }
  12222. /**
  12223. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12224. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12225. */
  12226. class KeyboardInfoPre extends KeyboardInfo {
  12227. /**
  12228. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12229. */
  12230. type: number;
  12231. /**
  12232. * Defines the related dom event
  12233. */
  12234. event: KeyboardEvent;
  12235. /**
  12236. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12237. */
  12238. skipOnPointerObservable: boolean;
  12239. /**
  12240. * Instantiates a new keyboard pre info.
  12241. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12242. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12243. * @param event Defines the related dom event
  12244. */
  12245. constructor(
  12246. /**
  12247. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12248. */
  12249. type: number,
  12250. /**
  12251. * Defines the related dom event
  12252. */
  12253. event: KeyboardEvent);
  12254. }
  12255. }
  12256. declare module BABYLON {
  12257. /**
  12258. * Gather the list of pointer event types as constants.
  12259. */
  12260. class PointerEventTypes {
  12261. /**
  12262. * 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.
  12263. */
  12264. static readonly POINTERDOWN: number;
  12265. /**
  12266. * The pointerup event is fired when a pointer is no longer active.
  12267. */
  12268. static readonly POINTERUP: number;
  12269. /**
  12270. * The pointermove event is fired when a pointer changes coordinates.
  12271. */
  12272. static readonly POINTERMOVE: number;
  12273. /**
  12274. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12275. */
  12276. static readonly POINTERWHEEL: number;
  12277. /**
  12278. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12279. */
  12280. static readonly POINTERPICK: number;
  12281. /**
  12282. * The pointertap event is fired when a the object has been touched and released without drag.
  12283. */
  12284. static readonly POINTERTAP: number;
  12285. /**
  12286. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12287. */
  12288. static readonly POINTERDOUBLETAP: number;
  12289. }
  12290. /**
  12291. * Base class of pointer info types.
  12292. */
  12293. class PointerInfoBase {
  12294. /**
  12295. * Defines the type of event (BABYLON.PointerEventTypes)
  12296. */
  12297. type: number;
  12298. /**
  12299. * Defines the related dom event
  12300. */
  12301. event: PointerEvent | MouseWheelEvent;
  12302. /**
  12303. * Instantiates the base class of pointers info.
  12304. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12305. * @param event Defines the related dom event
  12306. */
  12307. constructor(
  12308. /**
  12309. * Defines the type of event (BABYLON.PointerEventTypes)
  12310. */
  12311. type: number,
  12312. /**
  12313. * Defines the related dom event
  12314. */
  12315. event: PointerEvent | MouseWheelEvent);
  12316. }
  12317. /**
  12318. * This class is used to store pointer related info for the onPrePointerObservable event.
  12319. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12320. */
  12321. class PointerInfoPre extends PointerInfoBase {
  12322. /**
  12323. * Ray from a pointer if availible (eg. 6dof controller)
  12324. */
  12325. ray: Nullable<Ray>;
  12326. /**
  12327. * Defines the local position of the pointer on the canvas.
  12328. */
  12329. localPosition: Vector2;
  12330. /**
  12331. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12332. */
  12333. skipOnPointerObservable: boolean;
  12334. /**
  12335. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12336. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12337. * @param event Defines the related dom event
  12338. * @param localX Defines the local x coordinates of the pointer when the event occured
  12339. * @param localY Defines the local y coordinates of the pointer when the event occured
  12340. */
  12341. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12342. }
  12343. /**
  12344. * This type contains all the data related to a pointer event in Babylon.js.
  12345. * 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.
  12346. */
  12347. class PointerInfo extends PointerInfoBase {
  12348. /**
  12349. * Defines the picking info associated to the info (if any)\
  12350. */
  12351. pickInfo: Nullable<PickingInfo>;
  12352. /**
  12353. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12354. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12355. * @param event Defines the related dom event
  12356. * @param pickInfo Defines the picking info associated to the info (if any)\
  12357. */
  12358. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12359. /**
  12360. * Defines the picking info associated to the info (if any)\
  12361. */
  12362. pickInfo: Nullable<PickingInfo>);
  12363. }
  12364. }
  12365. declare module BABYLON {
  12366. /**
  12367. * Represents a gamepad control stick position
  12368. */
  12369. class StickValues {
  12370. /**
  12371. * The x component of the control stick
  12372. */
  12373. x: number;
  12374. /**
  12375. * The y component of the control stick
  12376. */
  12377. y: number;
  12378. /**
  12379. * Initializes the gamepad x and y control stick values
  12380. * @param x The x component of the gamepad control stick value
  12381. * @param y The y component of the gamepad control stick value
  12382. */
  12383. constructor(
  12384. /**
  12385. * The x component of the control stick
  12386. */
  12387. x: number,
  12388. /**
  12389. * The y component of the control stick
  12390. */
  12391. y: number);
  12392. }
  12393. /**
  12394. * An interface which manages callbacks for gamepad button changes
  12395. */
  12396. interface GamepadButtonChanges {
  12397. /**
  12398. * Called when a gamepad has been changed
  12399. */
  12400. changed: boolean;
  12401. /**
  12402. * Called when a gamepad press event has been triggered
  12403. */
  12404. pressChanged: boolean;
  12405. /**
  12406. * Called when a touch event has been triggered
  12407. */
  12408. touchChanged: boolean;
  12409. /**
  12410. * Called when a value has changed
  12411. */
  12412. valueChanged: boolean;
  12413. }
  12414. /**
  12415. * Represents a gamepad
  12416. */
  12417. class Gamepad {
  12418. /**
  12419. * The id of the gamepad
  12420. */
  12421. id: string;
  12422. /**
  12423. * The index of the gamepad
  12424. */
  12425. index: number;
  12426. /**
  12427. * The browser gamepad
  12428. */
  12429. browserGamepad: any;
  12430. /**
  12431. * Specifies what type of gamepad this represents
  12432. */
  12433. type: number;
  12434. private _leftStick;
  12435. private _rightStick;
  12436. /** @hidden */
  12437. _isConnected: boolean;
  12438. private _leftStickAxisX;
  12439. private _leftStickAxisY;
  12440. private _rightStickAxisX;
  12441. private _rightStickAxisY;
  12442. /**
  12443. * Triggered when the left control stick has been changed
  12444. */
  12445. private _onleftstickchanged;
  12446. /**
  12447. * Triggered when the right control stick has been changed
  12448. */
  12449. private _onrightstickchanged;
  12450. /**
  12451. * Represents a gamepad controller
  12452. */
  12453. static GAMEPAD: number;
  12454. /**
  12455. * Represents a generic controller
  12456. */
  12457. static GENERIC: number;
  12458. /**
  12459. * Represents an XBox controller
  12460. */
  12461. static XBOX: number;
  12462. /**
  12463. * Represents a pose-enabled controller
  12464. */
  12465. static POSE_ENABLED: number;
  12466. /**
  12467. * Specifies whether the left control stick should be Y-inverted
  12468. */
  12469. protected _invertLeftStickY: boolean;
  12470. /**
  12471. * Specifies if the gamepad has been connected
  12472. */
  12473. readonly isConnected: boolean;
  12474. /**
  12475. * Initializes the gamepad
  12476. * @param id The id of the gamepad
  12477. * @param index The index of the gamepad
  12478. * @param browserGamepad The browser gamepad
  12479. * @param leftStickX The x component of the left joystick
  12480. * @param leftStickY The y component of the left joystick
  12481. * @param rightStickX The x component of the right joystick
  12482. * @param rightStickY The y component of the right joystick
  12483. */
  12484. constructor(
  12485. /**
  12486. * The id of the gamepad
  12487. */
  12488. id: string,
  12489. /**
  12490. * The index of the gamepad
  12491. */
  12492. index: number,
  12493. /**
  12494. * The browser gamepad
  12495. */
  12496. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12497. /**
  12498. * Callback triggered when the left joystick has changed
  12499. * @param callback
  12500. */
  12501. onleftstickchanged(callback: (values: StickValues) => void): void;
  12502. /**
  12503. * Callback triggered when the right joystick has changed
  12504. * @param callback
  12505. */
  12506. onrightstickchanged(callback: (values: StickValues) => void): void;
  12507. /**
  12508. * Gets the left joystick
  12509. */
  12510. /**
  12511. * Sets the left joystick values
  12512. */
  12513. leftStick: StickValues;
  12514. /**
  12515. * Gets the right joystick
  12516. */
  12517. /**
  12518. * Sets the right joystick value
  12519. */
  12520. rightStick: StickValues;
  12521. /**
  12522. * Updates the gamepad joystick positions
  12523. */
  12524. update(): void;
  12525. /**
  12526. * Disposes the gamepad
  12527. */
  12528. dispose(): void;
  12529. }
  12530. /**
  12531. * Represents a generic gamepad
  12532. */
  12533. class GenericPad extends Gamepad {
  12534. private _buttons;
  12535. private _onbuttondown;
  12536. private _onbuttonup;
  12537. /**
  12538. * Observable triggered when a button has been pressed
  12539. */
  12540. onButtonDownObservable: Observable<number>;
  12541. /**
  12542. * Observable triggered when a button has been released
  12543. */
  12544. onButtonUpObservable: Observable<number>;
  12545. /**
  12546. * Callback triggered when a button has been pressed
  12547. * @param callback Called when a button has been pressed
  12548. */
  12549. onbuttondown(callback: (buttonPressed: number) => void): void;
  12550. /**
  12551. * Callback triggered when a button has been released
  12552. * @param callback Called when a button has been released
  12553. */
  12554. onbuttonup(callback: (buttonReleased: number) => void): void;
  12555. /**
  12556. * Initializes the generic gamepad
  12557. * @param id The id of the generic gamepad
  12558. * @param index The index of the generic gamepad
  12559. * @param browserGamepad The browser gamepad
  12560. */
  12561. constructor(id: string, index: number, browserGamepad: any);
  12562. private _setButtonValue;
  12563. /**
  12564. * Updates the generic gamepad
  12565. */
  12566. update(): void;
  12567. /**
  12568. * Disposes the generic gamepad
  12569. */
  12570. dispose(): void;
  12571. }
  12572. }
  12573. declare module BABYLON {
  12574. /**
  12575. * Manager for handling gamepads
  12576. */
  12577. class GamepadManager {
  12578. private _scene?;
  12579. private _babylonGamepads;
  12580. private _oneGamepadConnected;
  12581. /** @hidden */
  12582. _isMonitoring: boolean;
  12583. private _gamepadEventSupported;
  12584. private _gamepadSupport;
  12585. /**
  12586. * observable to be triggered when the gamepad controller has been connected
  12587. */
  12588. onGamepadConnectedObservable: Observable<Gamepad>;
  12589. /**
  12590. * observable to be triggered when the gamepad controller has been disconnected
  12591. */
  12592. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12593. private _onGamepadConnectedEvent;
  12594. private _onGamepadDisconnectedEvent;
  12595. /**
  12596. * Initializes the gamepad manager
  12597. * @param _scene BabylonJS scene
  12598. */
  12599. constructor(_scene?: Scene | undefined);
  12600. /**
  12601. * The gamepads in the game pad manager
  12602. */
  12603. readonly gamepads: Gamepad[];
  12604. /**
  12605. * Get the gamepad controllers based on type
  12606. * @param type The type of gamepad controller
  12607. * @returns Nullable gamepad
  12608. */
  12609. getGamepadByType(type?: number): Nullable<Gamepad>;
  12610. /**
  12611. * Disposes the gamepad manager
  12612. */
  12613. dispose(): void;
  12614. private _addNewGamepad;
  12615. private _startMonitoringGamepads;
  12616. private _stopMonitoringGamepads;
  12617. /** @hidden */
  12618. _checkGamepadsStatus(): void;
  12619. private _updateGamepadObjects;
  12620. }
  12621. }
  12622. declare module BABYLON {
  12623. interface Scene {
  12624. /** @hidden */
  12625. _gamepadManager: Nullable<GamepadManager>;
  12626. /**
  12627. * Gets the gamepad manager associated with the scene
  12628. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12629. */
  12630. gamepadManager: GamepadManager;
  12631. }
  12632. /**
  12633. * Interface representing a free camera inputs manager
  12634. */
  12635. interface FreeCameraInputsManager {
  12636. /**
  12637. * Adds gamepad input support to the FreeCameraInputsManager.
  12638. * @returns the FreeCameraInputsManager
  12639. */
  12640. addGamepad(): FreeCameraInputsManager;
  12641. }
  12642. /**
  12643. * Interface representing an arc rotate camera inputs manager
  12644. */
  12645. interface ArcRotateCameraInputsManager {
  12646. /**
  12647. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12648. * @returns the camera inputs manager
  12649. */
  12650. addGamepad(): ArcRotateCameraInputsManager;
  12651. }
  12652. /**
  12653. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12654. */
  12655. class GamepadSystemSceneComponent implements ISceneComponent {
  12656. /**
  12657. * The component name helpfull to identify the component in the list of scene components.
  12658. */
  12659. readonly name: string;
  12660. /**
  12661. * The scene the component belongs to.
  12662. */
  12663. scene: Scene;
  12664. /**
  12665. * Creates a new instance of the component for the given scene
  12666. * @param scene Defines the scene to register the component in
  12667. */
  12668. constructor(scene: Scene);
  12669. /**
  12670. * Registers the component in a given scene
  12671. */
  12672. register(): void;
  12673. /**
  12674. * Rebuilds the elements related to this component in case of
  12675. * context lost for instance.
  12676. */
  12677. rebuild(): void;
  12678. /**
  12679. * Disposes the component and the associated ressources
  12680. */
  12681. dispose(): void;
  12682. private _beforeCameraUpdate;
  12683. }
  12684. }
  12685. declare module BABYLON {
  12686. /**
  12687. * Defines supported buttons for XBox360 compatible gamepads
  12688. */
  12689. enum Xbox360Button {
  12690. /** A */
  12691. A = 0,
  12692. /** B */
  12693. B = 1,
  12694. /** X */
  12695. X = 2,
  12696. /** Y */
  12697. Y = 3,
  12698. /** Start */
  12699. Start = 4,
  12700. /** Back */
  12701. Back = 5,
  12702. /** Left button */
  12703. LB = 6,
  12704. /** Right button */
  12705. RB = 7,
  12706. /** Left stick */
  12707. LeftStick = 8,
  12708. /** Right stick */
  12709. RightStick = 9
  12710. }
  12711. /** Defines values for XBox360 DPad */
  12712. enum Xbox360Dpad {
  12713. /** Up */
  12714. Up = 0,
  12715. /** Down */
  12716. Down = 1,
  12717. /** Left */
  12718. Left = 2,
  12719. /** Right */
  12720. Right = 3
  12721. }
  12722. /**
  12723. * Defines a XBox360 gamepad
  12724. */
  12725. class Xbox360Pad extends Gamepad {
  12726. private _leftTrigger;
  12727. private _rightTrigger;
  12728. private _onlefttriggerchanged;
  12729. private _onrighttriggerchanged;
  12730. private _onbuttondown;
  12731. private _onbuttonup;
  12732. private _ondpaddown;
  12733. private _ondpadup;
  12734. /** Observable raised when a button is pressed */
  12735. onButtonDownObservable: Observable<Xbox360Button>;
  12736. /** Observable raised when a button is released */
  12737. onButtonUpObservable: Observable<Xbox360Button>;
  12738. /** Observable raised when a pad is pressed */
  12739. onPadDownObservable: Observable<Xbox360Dpad>;
  12740. /** Observable raised when a pad is released */
  12741. onPadUpObservable: Observable<Xbox360Dpad>;
  12742. private _buttonA;
  12743. private _buttonB;
  12744. private _buttonX;
  12745. private _buttonY;
  12746. private _buttonBack;
  12747. private _buttonStart;
  12748. private _buttonLB;
  12749. private _buttonRB;
  12750. private _buttonLeftStick;
  12751. private _buttonRightStick;
  12752. private _dPadUp;
  12753. private _dPadDown;
  12754. private _dPadLeft;
  12755. private _dPadRight;
  12756. private _isXboxOnePad;
  12757. /**
  12758. * Creates a new XBox360 gamepad object
  12759. * @param id defines the id of this gamepad
  12760. * @param index defines its index
  12761. * @param gamepad defines the internal HTML gamepad object
  12762. * @param xboxOne defines if it is a XBox One gamepad
  12763. */
  12764. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12765. /**
  12766. * Defines the callback to call when left trigger is pressed
  12767. * @param callback defines the callback to use
  12768. */
  12769. onlefttriggerchanged(callback: (value: number) => void): void;
  12770. /**
  12771. * Defines the callback to call when right trigger is pressed
  12772. * @param callback defines the callback to use
  12773. */
  12774. onrighttriggerchanged(callback: (value: number) => void): void;
  12775. /**
  12776. * Gets the left trigger value
  12777. */
  12778. /**
  12779. * Sets the left trigger value
  12780. */
  12781. leftTrigger: number;
  12782. /**
  12783. * Gets the right trigger value
  12784. */
  12785. /**
  12786. * Sets the right trigger value
  12787. */
  12788. rightTrigger: number;
  12789. /**
  12790. * Defines the callback to call when a button is pressed
  12791. * @param callback defines the callback to use
  12792. */
  12793. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12794. /**
  12795. * Defines the callback to call when a button is released
  12796. * @param callback defines the callback to use
  12797. */
  12798. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12799. /**
  12800. * Defines the callback to call when a pad is pressed
  12801. * @param callback defines the callback to use
  12802. */
  12803. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12804. /**
  12805. * Defines the callback to call when a pad is released
  12806. * @param callback defines the callback to use
  12807. */
  12808. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12809. private _setButtonValue;
  12810. private _setDPadValue;
  12811. /**
  12812. * Gets the value of the `A` button
  12813. */
  12814. /**
  12815. * Sets the value of the `A` button
  12816. */
  12817. buttonA: number;
  12818. /**
  12819. * Gets the value of the `B` button
  12820. */
  12821. /**
  12822. * Sets the value of the `B` button
  12823. */
  12824. buttonB: number;
  12825. /**
  12826. * Gets the value of the `X` button
  12827. */
  12828. /**
  12829. * Sets the value of the `X` button
  12830. */
  12831. buttonX: number;
  12832. /**
  12833. * Gets the value of the `Y` button
  12834. */
  12835. /**
  12836. * Sets the value of the `Y` button
  12837. */
  12838. buttonY: number;
  12839. /**
  12840. * Gets the value of the `Start` button
  12841. */
  12842. /**
  12843. * Sets the value of the `Start` button
  12844. */
  12845. buttonStart: number;
  12846. /**
  12847. * Gets the value of the `Back` button
  12848. */
  12849. /**
  12850. * Sets the value of the `Back` button
  12851. */
  12852. buttonBack: number;
  12853. /**
  12854. * Gets the value of the `Left` button
  12855. */
  12856. /**
  12857. * Sets the value of the `Left` button
  12858. */
  12859. buttonLB: number;
  12860. /**
  12861. * Gets the value of the `Right` button
  12862. */
  12863. /**
  12864. * Sets the value of the `Right` button
  12865. */
  12866. buttonRB: number;
  12867. /**
  12868. * Gets the value of the Left joystick
  12869. */
  12870. /**
  12871. * Sets the value of the Left joystick
  12872. */
  12873. buttonLeftStick: number;
  12874. /**
  12875. * Gets the value of the Right joystick
  12876. */
  12877. /**
  12878. * Sets the value of the Right joystick
  12879. */
  12880. buttonRightStick: number;
  12881. /**
  12882. * Gets the value of D-pad up
  12883. */
  12884. /**
  12885. * Sets the value of D-pad up
  12886. */
  12887. dPadUp: number;
  12888. /**
  12889. * Gets the value of D-pad down
  12890. */
  12891. /**
  12892. * Sets the value of D-pad down
  12893. */
  12894. dPadDown: number;
  12895. /**
  12896. * Gets the value of D-pad left
  12897. */
  12898. /**
  12899. * Sets the value of D-pad left
  12900. */
  12901. dPadLeft: number;
  12902. /**
  12903. * Gets the value of D-pad right
  12904. */
  12905. /**
  12906. * Sets the value of D-pad right
  12907. */
  12908. dPadRight: number;
  12909. /**
  12910. * Force the gamepad to synchronize with device values
  12911. */
  12912. update(): void;
  12913. /**
  12914. * Disposes the gamepad
  12915. */
  12916. dispose(): void;
  12917. }
  12918. }
  12919. declare module BABYLON {
  12920. /**
  12921. * Represents the different options available during the creation of
  12922. * a Environment helper.
  12923. *
  12924. * This can control the default ground, skybox and image processing setup of your scene.
  12925. */
  12926. interface IEnvironmentHelperOptions {
  12927. /**
  12928. * Specifies wether or not to create a ground.
  12929. * True by default.
  12930. */
  12931. createGround: boolean;
  12932. /**
  12933. * Specifies the ground size.
  12934. * 15 by default.
  12935. */
  12936. groundSize: number;
  12937. /**
  12938. * The texture used on the ground for the main color.
  12939. * Comes from the BabylonJS CDN by default.
  12940. *
  12941. * Remarks: Can be either a texture or a url.
  12942. */
  12943. groundTexture: string | BaseTexture;
  12944. /**
  12945. * The color mixed in the ground texture by default.
  12946. * BabylonJS clearColor by default.
  12947. */
  12948. groundColor: Color3;
  12949. /**
  12950. * Specifies the ground opacity.
  12951. * 1 by default.
  12952. */
  12953. groundOpacity: number;
  12954. /**
  12955. * Enables the ground to receive shadows.
  12956. * True by default.
  12957. */
  12958. enableGroundShadow: boolean;
  12959. /**
  12960. * Helps preventing the shadow to be fully black on the ground.
  12961. * 0.5 by default.
  12962. */
  12963. groundShadowLevel: number;
  12964. /**
  12965. * Creates a mirror texture attach to the ground.
  12966. * false by default.
  12967. */
  12968. enableGroundMirror: boolean;
  12969. /**
  12970. * Specifies the ground mirror size ratio.
  12971. * 0.3 by default as the default kernel is 64.
  12972. */
  12973. groundMirrorSizeRatio: number;
  12974. /**
  12975. * Specifies the ground mirror blur kernel size.
  12976. * 64 by default.
  12977. */
  12978. groundMirrorBlurKernel: number;
  12979. /**
  12980. * Specifies the ground mirror visibility amount.
  12981. * 1 by default
  12982. */
  12983. groundMirrorAmount: number;
  12984. /**
  12985. * Specifies the ground mirror reflectance weight.
  12986. * This uses the standard weight of the background material to setup the fresnel effect
  12987. * of the mirror.
  12988. * 1 by default.
  12989. */
  12990. groundMirrorFresnelWeight: number;
  12991. /**
  12992. * Specifies the ground mirror Falloff distance.
  12993. * This can helps reducing the size of the reflection.
  12994. * 0 by Default.
  12995. */
  12996. groundMirrorFallOffDistance: number;
  12997. /**
  12998. * Specifies the ground mirror texture type.
  12999. * Unsigned Int by Default.
  13000. */
  13001. groundMirrorTextureType: number;
  13002. /**
  13003. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13004. * the shown objects.
  13005. */
  13006. groundYBias: number;
  13007. /**
  13008. * Specifies wether or not to create a skybox.
  13009. * True by default.
  13010. */
  13011. createSkybox: boolean;
  13012. /**
  13013. * Specifies the skybox size.
  13014. * 20 by default.
  13015. */
  13016. skyboxSize: number;
  13017. /**
  13018. * The texture used on the skybox for the main color.
  13019. * Comes from the BabylonJS CDN by default.
  13020. *
  13021. * Remarks: Can be either a texture or a url.
  13022. */
  13023. skyboxTexture: string | BaseTexture;
  13024. /**
  13025. * The color mixed in the skybox texture by default.
  13026. * BabylonJS clearColor by default.
  13027. */
  13028. skyboxColor: Color3;
  13029. /**
  13030. * The background rotation around the Y axis of the scene.
  13031. * This helps aligning the key lights of your scene with the background.
  13032. * 0 by default.
  13033. */
  13034. backgroundYRotation: number;
  13035. /**
  13036. * Compute automatically the size of the elements to best fit with the scene.
  13037. */
  13038. sizeAuto: boolean;
  13039. /**
  13040. * Default position of the rootMesh if autoSize is not true.
  13041. */
  13042. rootPosition: Vector3;
  13043. /**
  13044. * Sets up the image processing in the scene.
  13045. * true by default.
  13046. */
  13047. setupImageProcessing: boolean;
  13048. /**
  13049. * The texture used as your environment texture in the scene.
  13050. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13051. *
  13052. * Remarks: Can be either a texture or a url.
  13053. */
  13054. environmentTexture: string | BaseTexture;
  13055. /**
  13056. * The value of the exposure to apply to the scene.
  13057. * 0.6 by default if setupImageProcessing is true.
  13058. */
  13059. cameraExposure: number;
  13060. /**
  13061. * The value of the contrast to apply to the scene.
  13062. * 1.6 by default if setupImageProcessing is true.
  13063. */
  13064. cameraContrast: number;
  13065. /**
  13066. * Specifies wether or not tonemapping should be enabled in the scene.
  13067. * true by default if setupImageProcessing is true.
  13068. */
  13069. toneMappingEnabled: boolean;
  13070. }
  13071. /**
  13072. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13073. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13074. * It also helps with the default setup of your imageProcessing configuration.
  13075. */
  13076. class EnvironmentHelper {
  13077. /**
  13078. * Default ground texture URL.
  13079. */
  13080. private static _groundTextureCDNUrl;
  13081. /**
  13082. * Default skybox texture URL.
  13083. */
  13084. private static _skyboxTextureCDNUrl;
  13085. /**
  13086. * Default environment texture URL.
  13087. */
  13088. private static _environmentTextureCDNUrl;
  13089. /**
  13090. * Creates the default options for the helper.
  13091. */
  13092. private static _getDefaultOptions;
  13093. private _rootMesh;
  13094. /**
  13095. * Gets the root mesh created by the helper.
  13096. */
  13097. readonly rootMesh: Mesh;
  13098. private _skybox;
  13099. /**
  13100. * Gets the skybox created by the helper.
  13101. */
  13102. readonly skybox: Nullable<Mesh>;
  13103. private _skyboxTexture;
  13104. /**
  13105. * Gets the skybox texture created by the helper.
  13106. */
  13107. readonly skyboxTexture: Nullable<BaseTexture>;
  13108. private _skyboxMaterial;
  13109. /**
  13110. * Gets the skybox material created by the helper.
  13111. */
  13112. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13113. private _ground;
  13114. /**
  13115. * Gets the ground mesh created by the helper.
  13116. */
  13117. readonly ground: Nullable<Mesh>;
  13118. private _groundTexture;
  13119. /**
  13120. * Gets the ground texture created by the helper.
  13121. */
  13122. readonly groundTexture: Nullable<BaseTexture>;
  13123. private _groundMirror;
  13124. /**
  13125. * Gets the ground mirror created by the helper.
  13126. */
  13127. readonly groundMirror: Nullable<MirrorTexture>;
  13128. /**
  13129. * Gets the ground mirror render list to helps pushing the meshes
  13130. * you wish in the ground reflection.
  13131. */
  13132. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13133. private _groundMaterial;
  13134. /**
  13135. * Gets the ground material created by the helper.
  13136. */
  13137. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13138. /**
  13139. * Stores the creation options.
  13140. */
  13141. private readonly _scene;
  13142. private _options;
  13143. /**
  13144. * This observable will be notified with any error during the creation of the environment,
  13145. * mainly texture creation errors.
  13146. */
  13147. onErrorObservable: Observable<{
  13148. message?: string;
  13149. exception?: any;
  13150. }>;
  13151. /**
  13152. * constructor
  13153. * @param options
  13154. * @param scene The scene to add the material to
  13155. */
  13156. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13157. /**
  13158. * Updates the background according to the new options
  13159. * @param options
  13160. */
  13161. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13162. /**
  13163. * Sets the primary color of all the available elements.
  13164. * @param color the main color to affect to the ground and the background
  13165. */
  13166. setMainColor(color: Color3): void;
  13167. /**
  13168. * Setup the image processing according to the specified options.
  13169. */
  13170. private _setupImageProcessing;
  13171. /**
  13172. * Setup the environment texture according to the specified options.
  13173. */
  13174. private _setupEnvironmentTexture;
  13175. /**
  13176. * Setup the background according to the specified options.
  13177. */
  13178. private _setupBackground;
  13179. /**
  13180. * Get the scene sizes according to the setup.
  13181. */
  13182. private _getSceneSize;
  13183. /**
  13184. * Setup the ground according to the specified options.
  13185. */
  13186. private _setupGround;
  13187. /**
  13188. * Setup the ground material according to the specified options.
  13189. */
  13190. private _setupGroundMaterial;
  13191. /**
  13192. * Setup the ground diffuse texture according to the specified options.
  13193. */
  13194. private _setupGroundDiffuseTexture;
  13195. /**
  13196. * Setup the ground mirror texture according to the specified options.
  13197. */
  13198. private _setupGroundMirrorTexture;
  13199. /**
  13200. * Setup the ground to receive the mirror texture.
  13201. */
  13202. private _setupMirrorInGroundMaterial;
  13203. /**
  13204. * Setup the skybox according to the specified options.
  13205. */
  13206. private _setupSkybox;
  13207. /**
  13208. * Setup the skybox material according to the specified options.
  13209. */
  13210. private _setupSkyboxMaterial;
  13211. /**
  13212. * Setup the skybox reflection texture according to the specified options.
  13213. */
  13214. private _setupSkyboxReflectionTexture;
  13215. private _errorHandler;
  13216. /**
  13217. * Dispose all the elements created by the Helper.
  13218. */
  13219. dispose(): void;
  13220. }
  13221. }
  13222. declare module BABYLON {
  13223. /**
  13224. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13225. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13226. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13227. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13228. */
  13229. class PhotoDome extends TransformNode {
  13230. private _useDirectMapping;
  13231. /**
  13232. * The texture being displayed on the sphere
  13233. */
  13234. protected _photoTexture: Texture;
  13235. /**
  13236. * Gets or sets the texture being displayed on the sphere
  13237. */
  13238. photoTexture: Texture;
  13239. /**
  13240. * Observable raised when an error occured while loading the 360 image
  13241. */
  13242. onLoadErrorObservable: Observable<string>;
  13243. /**
  13244. * The skybox material
  13245. */
  13246. protected _material: BackgroundMaterial;
  13247. /**
  13248. * The surface used for the skybox
  13249. */
  13250. protected _mesh: Mesh;
  13251. /**
  13252. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13253. * Also see the options.resolution property.
  13254. */
  13255. fovMultiplier: number;
  13256. /**
  13257. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13258. * @param name Element's name, child elements will append suffixes for their own names.
  13259. * @param urlsOfPhoto defines the url of the photo to display
  13260. * @param options defines an object containing optional or exposed sub element properties
  13261. * @param onError defines a callback called when an error occured while loading the texture
  13262. */
  13263. constructor(name: string, urlOfPhoto: string, options: {
  13264. resolution?: number;
  13265. size?: number;
  13266. useDirectMapping?: boolean;
  13267. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13268. /**
  13269. * Releases resources associated with this node.
  13270. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13271. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13272. */
  13273. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. interface Scene {
  13278. /**
  13279. * Creates a default light for the scene.
  13280. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13281. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13282. */
  13283. createDefaultLight(replace?: boolean): void;
  13284. /**
  13285. * Creates a default camera for the scene.
  13286. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13287. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13288. * @param replace has default false, when true replaces the active camera in the scene
  13289. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13290. */
  13291. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13292. /**
  13293. * Creates a default camera and a default light.
  13294. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13295. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13296. * @param replace has the default false, when true replaces the active camera/light in the scene
  13297. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13298. */
  13299. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13300. /**
  13301. * Creates a new sky box
  13302. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13303. * @param environmentTexture defines the texture to use as environment texture
  13304. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13305. * @param scale defines the overall scale of the skybox
  13306. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13307. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13308. * @returns a new mesh holding the sky box
  13309. */
  13310. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13311. /**
  13312. * Creates a new environment
  13313. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13314. * @param options defines the options you can use to configure the environment
  13315. * @returns the new EnvironmentHelper
  13316. */
  13317. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13318. /**
  13319. * Creates a new VREXperienceHelper
  13320. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13321. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13322. * @returns a new VREXperienceHelper
  13323. */
  13324. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13325. /**
  13326. * Creates a new XREXperienceHelper
  13327. * @see http://doc.babylonjs.com/how_to/webxr
  13328. * @returns a promise for a new XREXperienceHelper
  13329. */
  13330. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13331. }
  13332. }
  13333. declare module BABYLON {
  13334. /**
  13335. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13336. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13337. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13338. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13339. */
  13340. class VideoDome extends TransformNode {
  13341. private _useDirectMapping;
  13342. /**
  13343. * The video texture being displayed on the sphere
  13344. */
  13345. protected _videoTexture: VideoTexture;
  13346. /**
  13347. * Gets the video texture being displayed on the sphere
  13348. */
  13349. readonly videoTexture: VideoTexture;
  13350. /**
  13351. * The skybox material
  13352. */
  13353. protected _material: BackgroundMaterial;
  13354. /**
  13355. * The surface used for the skybox
  13356. */
  13357. protected _mesh: Mesh;
  13358. /**
  13359. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13360. * Also see the options.resolution property.
  13361. */
  13362. fovMultiplier: number;
  13363. /**
  13364. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13365. * @param name Element's name, child elements will append suffixes for their own names.
  13366. * @param urlsOrVideo defines the url(s) or the video element to use
  13367. * @param options An object containing optional or exposed sub element properties
  13368. */
  13369. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13370. resolution?: number;
  13371. clickToPlay?: boolean;
  13372. autoPlay?: boolean;
  13373. loop?: boolean;
  13374. size?: number;
  13375. poster?: string;
  13376. useDirectMapping?: boolean;
  13377. }, scene: Scene);
  13378. /**
  13379. * Releases resources associated with this node.
  13380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13382. */
  13383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13384. }
  13385. }
  13386. declare module BABYLON {
  13387. /**
  13388. * Single axis drag gizmo
  13389. */
  13390. class AxisDragGizmo extends Gizmo {
  13391. /**
  13392. * Drag behavior responsible for the gizmos dragging interactions
  13393. */
  13394. dragBehavior: PointerDragBehavior;
  13395. private _pointerObserver;
  13396. /**
  13397. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13398. */
  13399. snapDistance: number;
  13400. /**
  13401. * Event that fires each time the gizmo snaps to a new location.
  13402. * * snapDistance is the the change in distance
  13403. */
  13404. onSnapObservable: Observable<{
  13405. snapDistance: number;
  13406. }>;
  13407. /**
  13408. * Creates an AxisDragGizmo
  13409. * @param gizmoLayer The utility layer the gizmo will be added to
  13410. * @param dragAxis The axis which the gizmo will be able to drag on
  13411. * @param color The color of the gizmo
  13412. */
  13413. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13414. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13415. /**
  13416. * Disposes of the gizmo
  13417. */
  13418. dispose(): void;
  13419. }
  13420. }
  13421. declare module BABYLON {
  13422. /**
  13423. * Single axis scale gizmo
  13424. */
  13425. class AxisScaleGizmo extends Gizmo {
  13426. private _coloredMaterial;
  13427. /**
  13428. * Drag behavior responsible for the gizmos dragging interactions
  13429. */
  13430. dragBehavior: PointerDragBehavior;
  13431. private _pointerObserver;
  13432. /**
  13433. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13434. */
  13435. snapDistance: number;
  13436. /**
  13437. * Event that fires each time the gizmo snaps to a new location.
  13438. * * snapDistance is the the change in distance
  13439. */
  13440. onSnapObservable: Observable<{
  13441. snapDistance: number;
  13442. }>;
  13443. /**
  13444. * If the scaling operation should be done on all axis (default: false)
  13445. */
  13446. uniformScaling: boolean;
  13447. /**
  13448. * Creates an AxisScaleGizmo
  13449. * @param gizmoLayer The utility layer the gizmo will be added to
  13450. * @param dragAxis The axis which the gizmo will be able to scale on
  13451. * @param color The color of the gizmo
  13452. */
  13453. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13454. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13455. /**
  13456. * Disposes of the gizmo
  13457. */
  13458. dispose(): void;
  13459. /**
  13460. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13461. * @param mesh The mesh to replace the default mesh of the gizmo
  13462. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13463. */
  13464. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13465. }
  13466. }
  13467. declare module BABYLON {
  13468. /**
  13469. * Bounding box gizmo
  13470. */
  13471. class BoundingBoxGizmo extends Gizmo {
  13472. private _lineBoundingBox;
  13473. private _rotateSpheresParent;
  13474. private _scaleBoxesParent;
  13475. private _boundingDimensions;
  13476. private _renderObserver;
  13477. private _pointerObserver;
  13478. private _scaleDragSpeed;
  13479. private _tmpQuaternion;
  13480. private _tmpVector;
  13481. private _tmpRotationMatrix;
  13482. /**
  13483. * 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)
  13484. */
  13485. ignoreChildren: boolean;
  13486. /**
  13487. * 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)
  13488. */
  13489. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13490. /**
  13491. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13492. */
  13493. rotationSphereSize: number;
  13494. /**
  13495. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13496. */
  13497. scaleBoxSize: number;
  13498. /**
  13499. * 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)
  13500. */
  13501. fixedDragMeshScreenSize: boolean;
  13502. /**
  13503. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13504. */
  13505. fixedDragMeshScreenSizeDistanceFactor: number;
  13506. /**
  13507. * Fired when a rotation sphere or scale box is dragged
  13508. */
  13509. onDragStartObservable: Observable<{}>;
  13510. /**
  13511. * Fired when a scale box is dragged
  13512. */
  13513. onScaleBoxDragObservable: Observable<{}>;
  13514. /**
  13515. * Fired when a scale box drag is ended
  13516. */
  13517. onScaleBoxDragEndObservable: Observable<{}>;
  13518. /**
  13519. * Fired when a rotation sphere is dragged
  13520. */
  13521. onRotationSphereDragObservable: Observable<{}>;
  13522. /**
  13523. * Fired when a rotation sphere drag is ended
  13524. */
  13525. onRotationSphereDragEndObservable: Observable<{}>;
  13526. /**
  13527. * 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)
  13528. */
  13529. scalePivot: Nullable<Vector3>;
  13530. private _anchorMesh;
  13531. private _existingMeshScale;
  13532. private static _PivotCached;
  13533. private static _OldPivotPoint;
  13534. private static _PivotTranslation;
  13535. private static _PivotTmpVector;
  13536. /** @hidden */
  13537. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13538. /** @hidden */
  13539. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13540. /**
  13541. * Creates an BoundingBoxGizmo
  13542. * @param gizmoLayer The utility layer the gizmo will be added to
  13543. * @param color The color of the gizmo
  13544. */
  13545. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13546. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13547. private _selectNode;
  13548. /**
  13549. * Updates the bounding box information for the Gizmo
  13550. */
  13551. updateBoundingBox(): void;
  13552. /**
  13553. * Enables rotation on the specified axis and disables rotation on the others
  13554. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13555. */
  13556. setEnabledRotationAxis(axis: string): void;
  13557. /**
  13558. * Disposes of the gizmo
  13559. */
  13560. dispose(): void;
  13561. /**
  13562. * 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)
  13563. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13564. * @returns the bounding box mesh with the passed in mesh as a child
  13565. */
  13566. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13567. /**
  13568. * CustomMeshes are not supported by this gizmo
  13569. * @param mesh The mesh to replace the default mesh of the gizmo
  13570. */
  13571. setCustomMesh(mesh: Mesh): void;
  13572. }
  13573. }
  13574. declare module BABYLON {
  13575. /**
  13576. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13577. */
  13578. class Gizmo implements IDisposable {
  13579. /** The utility layer the gizmo will be added to */
  13580. gizmoLayer: UtilityLayerRenderer;
  13581. /**
  13582. * The root mesh of the gizmo
  13583. */
  13584. protected _rootMesh: Mesh;
  13585. private _attachedMesh;
  13586. /**
  13587. * Ratio for the scale of the gizmo (Default: 1)
  13588. */
  13589. scaleRatio: number;
  13590. private _tmpMatrix;
  13591. /**
  13592. * If a custom mesh has been set (Default: false)
  13593. */
  13594. protected _customMeshSet: boolean;
  13595. /**
  13596. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13597. * * When set, interactions will be enabled
  13598. */
  13599. attachedMesh: Nullable<AbstractMesh>;
  13600. /**
  13601. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13602. * @param mesh The mesh to replace the default mesh of the gizmo
  13603. */
  13604. setCustomMesh(mesh: Mesh): void;
  13605. /**
  13606. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13607. */
  13608. updateGizmoRotationToMatchAttachedMesh: boolean;
  13609. /**
  13610. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13611. */
  13612. updateGizmoPositionToMatchAttachedMesh: boolean;
  13613. /**
  13614. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13615. */
  13616. protected _updateScale: boolean;
  13617. protected _interactionsEnabled: boolean;
  13618. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13619. private _beforeRenderObserver;
  13620. /**
  13621. * Creates a gizmo
  13622. * @param gizmoLayer The utility layer the gizmo will be added to
  13623. */
  13624. constructor(
  13625. /** The utility layer the gizmo will be added to */
  13626. gizmoLayer?: UtilityLayerRenderer);
  13627. private _tempVector;
  13628. /**
  13629. * @hidden
  13630. * Updates the gizmo to match the attached mesh's position/rotation
  13631. */
  13632. protected _update(): void;
  13633. /**
  13634. * Disposes of the gizmo
  13635. */
  13636. dispose(): void;
  13637. }
  13638. }
  13639. declare module BABYLON {
  13640. /**
  13641. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13642. */
  13643. class GizmoManager implements IDisposable {
  13644. private scene;
  13645. /**
  13646. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13647. */
  13648. gizmos: {
  13649. positionGizmo: Nullable<PositionGizmo>;
  13650. rotationGizmo: Nullable<RotationGizmo>;
  13651. scaleGizmo: Nullable<ScaleGizmo>;
  13652. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13653. };
  13654. private _gizmosEnabled;
  13655. private _pointerObserver;
  13656. private _attachedMesh;
  13657. private _boundingBoxColor;
  13658. private _defaultUtilityLayer;
  13659. private _defaultKeepDepthUtilityLayer;
  13660. /**
  13661. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13662. */
  13663. boundingBoxDragBehavior: SixDofDragBehavior;
  13664. /**
  13665. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13666. */
  13667. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13668. /**
  13669. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13670. */
  13671. usePointerToAttachGizmos: boolean;
  13672. /**
  13673. * Instatiates a gizmo manager
  13674. * @param scene the scene to overlay the gizmos on top of
  13675. */
  13676. constructor(scene: Scene);
  13677. /**
  13678. * Attaches a set of gizmos to the specified mesh
  13679. * @param mesh The mesh the gizmo's should be attached to
  13680. */
  13681. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13682. /**
  13683. * If the position gizmo is enabled
  13684. */
  13685. positionGizmoEnabled: boolean;
  13686. /**
  13687. * If the rotation gizmo is enabled
  13688. */
  13689. rotationGizmoEnabled: boolean;
  13690. /**
  13691. * If the scale gizmo is enabled
  13692. */
  13693. scaleGizmoEnabled: boolean;
  13694. /**
  13695. * If the boundingBox gizmo is enabled
  13696. */
  13697. boundingBoxGizmoEnabled: boolean;
  13698. /**
  13699. * Disposes of the gizmo manager
  13700. */
  13701. dispose(): void;
  13702. }
  13703. }
  13704. declare module BABYLON {
  13705. /**
  13706. * Single plane rotation gizmo
  13707. */
  13708. class PlaneRotationGizmo extends Gizmo {
  13709. /**
  13710. * Drag behavior responsible for the gizmos dragging interactions
  13711. */
  13712. dragBehavior: PointerDragBehavior;
  13713. private _pointerObserver;
  13714. /**
  13715. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13716. */
  13717. snapDistance: number;
  13718. /**
  13719. * Event that fires each time the gizmo snaps to a new location.
  13720. * * snapDistance is the the change in distance
  13721. */
  13722. onSnapObservable: Observable<{
  13723. snapDistance: number;
  13724. }>;
  13725. /**
  13726. * Creates a PlaneRotationGizmo
  13727. * @param gizmoLayer The utility layer the gizmo will be added to
  13728. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13729. * @param color The color of the gizmo
  13730. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13731. */
  13732. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13733. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13734. /**
  13735. * Disposes of the gizmo
  13736. */
  13737. dispose(): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Gizmo that enables dragging a mesh along 3 axis
  13743. */
  13744. class PositionGizmo extends Gizmo {
  13745. /**
  13746. * Internal gizmo used for interactions on the x axis
  13747. */
  13748. xGizmo: AxisDragGizmo;
  13749. /**
  13750. * Internal gizmo used for interactions on the y axis
  13751. */
  13752. yGizmo: AxisDragGizmo;
  13753. /**
  13754. * Internal gizmo used for interactions on the z axis
  13755. */
  13756. zGizmo: AxisDragGizmo;
  13757. /** Fires an event when any of it's sub gizmos are dragged */
  13758. onDragStartObservable: Observable<{}>;
  13759. /** Fires an event when any of it's sub gizmos are released from dragging */
  13760. onDragEndObservable: Observable<{}>;
  13761. attachedMesh: Nullable<AbstractMesh>;
  13762. /**
  13763. * Creates a PositionGizmo
  13764. * @param gizmoLayer The utility layer the gizmo will be added to
  13765. */
  13766. constructor(gizmoLayer?: UtilityLayerRenderer);
  13767. updateGizmoRotationToMatchAttachedMesh: boolean;
  13768. /**
  13769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13770. */
  13771. snapDistance: number;
  13772. /**
  13773. * Ratio for the scale of the gizmo (Default: 1)
  13774. */
  13775. scaleRatio: number;
  13776. /**
  13777. * Disposes of the gizmo
  13778. */
  13779. dispose(): void;
  13780. /**
  13781. * CustomMeshes are not supported by this gizmo
  13782. * @param mesh The mesh to replace the default mesh of the gizmo
  13783. */
  13784. setCustomMesh(mesh: Mesh): void;
  13785. }
  13786. }
  13787. declare module BABYLON {
  13788. /**
  13789. * Gizmo that enables rotating a mesh along 3 axis
  13790. */
  13791. class RotationGizmo extends Gizmo {
  13792. /**
  13793. * Internal gizmo used for interactions on the x axis
  13794. */
  13795. xGizmo: PlaneRotationGizmo;
  13796. /**
  13797. * Internal gizmo used for interactions on the y axis
  13798. */
  13799. yGizmo: PlaneRotationGizmo;
  13800. /**
  13801. * Internal gizmo used for interactions on the z axis
  13802. */
  13803. zGizmo: PlaneRotationGizmo;
  13804. /** Fires an event when any of it's sub gizmos are dragged */
  13805. onDragStartObservable: Observable<{}>;
  13806. /** Fires an event when any of it's sub gizmos are released from dragging */
  13807. onDragEndObservable: Observable<{}>;
  13808. attachedMesh: Nullable<AbstractMesh>;
  13809. /**
  13810. * Creates a RotationGizmo
  13811. * @param gizmoLayer The utility layer the gizmo will be added to
  13812. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13813. */
  13814. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13815. updateGizmoRotationToMatchAttachedMesh: boolean;
  13816. /**
  13817. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13818. */
  13819. snapDistance: number;
  13820. /**
  13821. * Ratio for the scale of the gizmo (Default: 1)
  13822. */
  13823. scaleRatio: number;
  13824. /**
  13825. * Disposes of the gizmo
  13826. */
  13827. dispose(): void;
  13828. /**
  13829. * CustomMeshes are not supported by this gizmo
  13830. * @param mesh The mesh to replace the default mesh of the gizmo
  13831. */
  13832. setCustomMesh(mesh: Mesh): void;
  13833. }
  13834. }
  13835. declare module BABYLON {
  13836. /**
  13837. * Gizmo that enables scaling a mesh along 3 axis
  13838. */
  13839. class ScaleGizmo extends Gizmo {
  13840. /**
  13841. * Internal gizmo used for interactions on the x axis
  13842. */
  13843. xGizmo: AxisScaleGizmo;
  13844. /**
  13845. * Internal gizmo used for interactions on the y axis
  13846. */
  13847. yGizmo: AxisScaleGizmo;
  13848. /**
  13849. * Internal gizmo used for interactions on the z axis
  13850. */
  13851. zGizmo: AxisScaleGizmo;
  13852. /**
  13853. * Internal gizmo used to scale all axis equally
  13854. */
  13855. uniformScaleGizmo: AxisScaleGizmo;
  13856. /** Fires an event when any of it's sub gizmos are dragged */
  13857. onDragStartObservable: Observable<{}>;
  13858. /** Fires an event when any of it's sub gizmos are released from dragging */
  13859. onDragEndObservable: Observable<{}>;
  13860. attachedMesh: Nullable<AbstractMesh>;
  13861. /**
  13862. * Creates a ScaleGizmo
  13863. * @param gizmoLayer The utility layer the gizmo will be added to
  13864. */
  13865. constructor(gizmoLayer?: UtilityLayerRenderer);
  13866. updateGizmoRotationToMatchAttachedMesh: boolean;
  13867. /**
  13868. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13869. */
  13870. snapDistance: number;
  13871. /**
  13872. * Ratio for the scale of the gizmo (Default: 1)
  13873. */
  13874. scaleRatio: number;
  13875. /**
  13876. * Disposes of the gizmo
  13877. */
  13878. dispose(): void;
  13879. }
  13880. }
  13881. declare module BABYLON {
  13882. /**
  13883. * This class can be used to get instrumentation data from a Babylon engine
  13884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13885. */
  13886. class EngineInstrumentation implements IDisposable {
  13887. /**
  13888. * Define the instrumented engine.
  13889. */
  13890. engine: Engine;
  13891. private _captureGPUFrameTime;
  13892. private _gpuFrameTimeToken;
  13893. private _gpuFrameTime;
  13894. private _captureShaderCompilationTime;
  13895. private _shaderCompilationTime;
  13896. private _onBeginFrameObserver;
  13897. private _onEndFrameObserver;
  13898. private _onBeforeShaderCompilationObserver;
  13899. private _onAfterShaderCompilationObserver;
  13900. /**
  13901. * Gets the perf counter used for GPU frame time
  13902. */
  13903. readonly gpuFrameTimeCounter: PerfCounter;
  13904. /**
  13905. * Gets the GPU frame time capture status
  13906. */
  13907. /**
  13908. * Enable or disable the GPU frame time capture
  13909. */
  13910. captureGPUFrameTime: boolean;
  13911. /**
  13912. * Gets the perf counter used for shader compilation time
  13913. */
  13914. readonly shaderCompilationTimeCounter: PerfCounter;
  13915. /**
  13916. * Gets the shader compilation time capture status
  13917. */
  13918. /**
  13919. * Enable or disable the shader compilation time capture
  13920. */
  13921. captureShaderCompilationTime: boolean;
  13922. /**
  13923. * Instantiates a new engine instrumentation.
  13924. * This class can be used to get instrumentation data from a Babylon engine
  13925. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13926. * @param engine Defines the engine to instrument
  13927. */
  13928. constructor(
  13929. /**
  13930. * Define the instrumented engine.
  13931. */
  13932. engine: Engine);
  13933. /**
  13934. * Dispose and release associated resources.
  13935. */
  13936. dispose(): void;
  13937. }
  13938. }
  13939. declare module BABYLON {
  13940. /**
  13941. * This class can be used to get instrumentation data from a Babylon engine
  13942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13943. */
  13944. class SceneInstrumentation implements IDisposable {
  13945. /**
  13946. * Defines the scene to instrument
  13947. */
  13948. scene: Scene;
  13949. private _captureActiveMeshesEvaluationTime;
  13950. private _activeMeshesEvaluationTime;
  13951. private _captureRenderTargetsRenderTime;
  13952. private _renderTargetsRenderTime;
  13953. private _captureFrameTime;
  13954. private _frameTime;
  13955. private _captureRenderTime;
  13956. private _renderTime;
  13957. private _captureInterFrameTime;
  13958. private _interFrameTime;
  13959. private _captureParticlesRenderTime;
  13960. private _particlesRenderTime;
  13961. private _captureSpritesRenderTime;
  13962. private _spritesRenderTime;
  13963. private _capturePhysicsTime;
  13964. private _physicsTime;
  13965. private _captureAnimationsTime;
  13966. private _animationsTime;
  13967. private _captureCameraRenderTime;
  13968. private _cameraRenderTime;
  13969. private _onBeforeActiveMeshesEvaluationObserver;
  13970. private _onAfterActiveMeshesEvaluationObserver;
  13971. private _onBeforeRenderTargetsRenderObserver;
  13972. private _onAfterRenderTargetsRenderObserver;
  13973. private _onAfterRenderObserver;
  13974. private _onBeforeDrawPhaseObserver;
  13975. private _onAfterDrawPhaseObserver;
  13976. private _onBeforeAnimationsObserver;
  13977. private _onBeforeParticlesRenderingObserver;
  13978. private _onAfterParticlesRenderingObserver;
  13979. private _onBeforeSpritesRenderingObserver;
  13980. private _onAfterSpritesRenderingObserver;
  13981. private _onBeforePhysicsObserver;
  13982. private _onAfterPhysicsObserver;
  13983. private _onAfterAnimationsObserver;
  13984. private _onBeforeCameraRenderObserver;
  13985. private _onAfterCameraRenderObserver;
  13986. /**
  13987. * Gets the perf counter used for active meshes evaluation time
  13988. */
  13989. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13990. /**
  13991. * Gets the active meshes evaluation time capture status
  13992. */
  13993. /**
  13994. * Enable or disable the active meshes evaluation time capture
  13995. */
  13996. captureActiveMeshesEvaluationTime: boolean;
  13997. /**
  13998. * Gets the perf counter used for render targets render time
  13999. */
  14000. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14001. /**
  14002. * Gets the render targets render time capture status
  14003. */
  14004. /**
  14005. * Enable or disable the render targets render time capture
  14006. */
  14007. captureRenderTargetsRenderTime: boolean;
  14008. /**
  14009. * Gets the perf counter used for particles render time
  14010. */
  14011. readonly particlesRenderTimeCounter: PerfCounter;
  14012. /**
  14013. * Gets the particles render time capture status
  14014. */
  14015. /**
  14016. * Enable or disable the particles render time capture
  14017. */
  14018. captureParticlesRenderTime: boolean;
  14019. /**
  14020. * Gets the perf counter used for sprites render time
  14021. */
  14022. readonly spritesRenderTimeCounter: PerfCounter;
  14023. /**
  14024. * Gets the sprites render time capture status
  14025. */
  14026. /**
  14027. * Enable or disable the sprites render time capture
  14028. */
  14029. captureSpritesRenderTime: boolean;
  14030. /**
  14031. * Gets the perf counter used for physics time
  14032. */
  14033. readonly physicsTimeCounter: PerfCounter;
  14034. /**
  14035. * Gets the physics time capture status
  14036. */
  14037. /**
  14038. * Enable or disable the physics time capture
  14039. */
  14040. capturePhysicsTime: boolean;
  14041. /**
  14042. * Gets the perf counter used for animations time
  14043. */
  14044. readonly animationsTimeCounter: PerfCounter;
  14045. /**
  14046. * Gets the animations time capture status
  14047. */
  14048. /**
  14049. * Enable or disable the animations time capture
  14050. */
  14051. captureAnimationsTime: boolean;
  14052. /**
  14053. * Gets the perf counter used for frame time capture
  14054. */
  14055. readonly frameTimeCounter: PerfCounter;
  14056. /**
  14057. * Gets the frame time capture status
  14058. */
  14059. /**
  14060. * Enable or disable the frame time capture
  14061. */
  14062. captureFrameTime: boolean;
  14063. /**
  14064. * Gets the perf counter used for inter-frames time capture
  14065. */
  14066. readonly interFrameTimeCounter: PerfCounter;
  14067. /**
  14068. * Gets the inter-frames time capture status
  14069. */
  14070. /**
  14071. * Enable or disable the inter-frames time capture
  14072. */
  14073. captureInterFrameTime: boolean;
  14074. /**
  14075. * Gets the perf counter used for render time capture
  14076. */
  14077. readonly renderTimeCounter: PerfCounter;
  14078. /**
  14079. * Gets the render time capture status
  14080. */
  14081. /**
  14082. * Enable or disable the render time capture
  14083. */
  14084. captureRenderTime: boolean;
  14085. /**
  14086. * Gets the perf counter used for camera render time capture
  14087. */
  14088. readonly cameraRenderTimeCounter: PerfCounter;
  14089. /**
  14090. * Gets the camera render time capture status
  14091. */
  14092. /**
  14093. * Enable or disable the camera render time capture
  14094. */
  14095. captureCameraRenderTime: boolean;
  14096. /**
  14097. * Gets the perf counter used for draw calls
  14098. */
  14099. readonly drawCallsCounter: PerfCounter;
  14100. /**
  14101. * Gets the perf counter used for texture collisions
  14102. */
  14103. readonly textureCollisionsCounter: PerfCounter;
  14104. /**
  14105. * Instantiates a new scene instrumentation.
  14106. * This class can be used to get instrumentation data from a Babylon engine
  14107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14108. * @param scene Defines the scene to instrument
  14109. */
  14110. constructor(
  14111. /**
  14112. * Defines the scene to instrument
  14113. */
  14114. scene: Scene);
  14115. /**
  14116. * Dispose and release associated resources.
  14117. */
  14118. dispose(): void;
  14119. }
  14120. }
  14121. declare module BABYLON {
  14122. /**
  14123. * @hidden
  14124. **/
  14125. class _TimeToken {
  14126. _startTimeQuery: Nullable<WebGLQuery>;
  14127. _endTimeQuery: Nullable<WebGLQuery>;
  14128. _timeElapsedQuery: Nullable<WebGLQuery>;
  14129. _timeElapsedQueryEnded: boolean;
  14130. }
  14131. }
  14132. declare module BABYLON {
  14133. /**
  14134. * Effect layer options. This helps customizing the behaviour
  14135. * of the effect layer.
  14136. */
  14137. interface IEffectLayerOptions {
  14138. /**
  14139. * Multiplication factor apply to the canvas size to compute the render target size
  14140. * used to generated the objects (the smaller the faster).
  14141. */
  14142. mainTextureRatio: number;
  14143. /**
  14144. * Enforces a fixed size texture to ensure effect stability across devices.
  14145. */
  14146. mainTextureFixedSize?: number;
  14147. /**
  14148. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14149. */
  14150. alphaBlendingMode: number;
  14151. /**
  14152. * The camera attached to the layer.
  14153. */
  14154. camera: Nullable<Camera>;
  14155. /**
  14156. * The rendering group to draw the layer in.
  14157. */
  14158. renderingGroupId: number;
  14159. }
  14160. /**
  14161. * The effect layer Helps adding post process effect blended with the main pass.
  14162. *
  14163. * This can be for instance use to generate glow or higlight effects on the scene.
  14164. *
  14165. * The effect layer class can not be used directly and is intented to inherited from to be
  14166. * customized per effects.
  14167. */
  14168. abstract class EffectLayer {
  14169. private _vertexBuffers;
  14170. private _indexBuffer;
  14171. private _cachedDefines;
  14172. private _effectLayerMapGenerationEffect;
  14173. private _effectLayerOptions;
  14174. private _mergeEffect;
  14175. protected _scene: Scene;
  14176. protected _engine: Engine;
  14177. protected _maxSize: number;
  14178. protected _mainTextureDesiredSize: ISize;
  14179. protected _mainTexture: RenderTargetTexture;
  14180. protected _shouldRender: boolean;
  14181. protected _postProcesses: PostProcess[];
  14182. protected _textures: BaseTexture[];
  14183. protected _emissiveTextureAndColor: {
  14184. texture: Nullable<BaseTexture>;
  14185. color: Color4;
  14186. };
  14187. /**
  14188. * The name of the layer
  14189. */
  14190. name: string;
  14191. /**
  14192. * The clear color of the texture used to generate the glow map.
  14193. */
  14194. neutralColor: Color4;
  14195. /**
  14196. * Specifies wether the highlight layer is enabled or not.
  14197. */
  14198. isEnabled: boolean;
  14199. /**
  14200. * Gets the camera attached to the layer.
  14201. */
  14202. readonly camera: Nullable<Camera>;
  14203. /**
  14204. * Gets the rendering group id the layer should render in.
  14205. */
  14206. readonly renderingGroupId: number;
  14207. /**
  14208. * An event triggered when the effect layer has been disposed.
  14209. */
  14210. onDisposeObservable: Observable<EffectLayer>;
  14211. /**
  14212. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14213. */
  14214. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14215. /**
  14216. * An event triggered when the generated texture is being merged in the scene.
  14217. */
  14218. onBeforeComposeObservable: Observable<EffectLayer>;
  14219. /**
  14220. * An event triggered when the generated texture has been merged in the scene.
  14221. */
  14222. onAfterComposeObservable: Observable<EffectLayer>;
  14223. /**
  14224. * An event triggered when the efffect layer changes its size.
  14225. */
  14226. onSizeChangedObservable: Observable<EffectLayer>;
  14227. /**
  14228. * Instantiates a new effect Layer and references it in the scene.
  14229. * @param name The name of the layer
  14230. * @param scene The scene to use the layer in
  14231. */
  14232. constructor(
  14233. /** The Friendly of the effect in the scene */
  14234. name: string, scene: Scene);
  14235. /**
  14236. * Get the effect name of the layer.
  14237. * @return The effect name
  14238. */
  14239. abstract getEffectName(): string;
  14240. /**
  14241. * Checks for the readiness of the element composing the layer.
  14242. * @param subMesh the mesh to check for
  14243. * @param useInstances specify wether or not to use instances to render the mesh
  14244. * @return true if ready otherwise, false
  14245. */
  14246. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14247. /**
  14248. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14249. * @returns true if the effect requires stencil during the main canvas render pass.
  14250. */
  14251. abstract needStencil(): boolean;
  14252. /**
  14253. * Create the merge effect. This is the shader use to blit the information back
  14254. * to the main canvas at the end of the scene rendering.
  14255. * @returns The effect containing the shader used to merge the effect on the main canvas
  14256. */
  14257. protected abstract _createMergeEffect(): Effect;
  14258. /**
  14259. * Creates the render target textures and post processes used in the effect layer.
  14260. */
  14261. protected abstract _createTextureAndPostProcesses(): void;
  14262. /**
  14263. * Implementation specific of rendering the generating effect on the main canvas.
  14264. * @param effect The effect used to render through
  14265. */
  14266. protected abstract _internalRender(effect: Effect): void;
  14267. /**
  14268. * Sets the required values for both the emissive texture and and the main color.
  14269. */
  14270. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14271. /**
  14272. * Free any resources and references associated to a mesh.
  14273. * Internal use
  14274. * @param mesh The mesh to free.
  14275. */
  14276. abstract _disposeMesh(mesh: Mesh): void;
  14277. /**
  14278. * Serializes this layer (Glow or Highlight for example)
  14279. * @returns a serialized layer object
  14280. */
  14281. abstract serialize?(): any;
  14282. /**
  14283. * Initializes the effect layer with the required options.
  14284. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14285. */
  14286. protected _init(options: Partial<IEffectLayerOptions>): void;
  14287. /**
  14288. * Generates the index buffer of the full screen quad blending to the main canvas.
  14289. */
  14290. private _generateIndexBuffer;
  14291. /**
  14292. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14293. */
  14294. private _genrateVertexBuffer;
  14295. /**
  14296. * Sets the main texture desired size which is the closest power of two
  14297. * of the engine canvas size.
  14298. */
  14299. private _setMainTextureSize;
  14300. /**
  14301. * Creates the main texture for the effect layer.
  14302. */
  14303. protected _createMainTexture(): void;
  14304. /**
  14305. * Checks for the readiness of the element composing the layer.
  14306. * @param subMesh the mesh to check for
  14307. * @param useInstances specify wether or not to use instances to render the mesh
  14308. * @param emissiveTexture the associated emissive texture used to generate the glow
  14309. * @return true if ready otherwise, false
  14310. */
  14311. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14312. /**
  14313. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14314. */
  14315. render(): void;
  14316. /**
  14317. * Determine if a given mesh will be used in the current effect.
  14318. * @param mesh mesh to test
  14319. * @returns true if the mesh will be used
  14320. */
  14321. hasMesh(mesh: AbstractMesh): boolean;
  14322. /**
  14323. * Returns true if the layer contains information to display, otherwise false.
  14324. * @returns true if the glow layer should be rendered
  14325. */
  14326. shouldRender(): boolean;
  14327. /**
  14328. * Returns true if the mesh should render, otherwise false.
  14329. * @param mesh The mesh to render
  14330. * @returns true if it should render otherwise false
  14331. */
  14332. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14333. /**
  14334. * Returns true if the mesh should render, otherwise false.
  14335. * @param mesh The mesh to render
  14336. * @returns true if it should render otherwise false
  14337. */
  14338. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14339. /**
  14340. * Renders the submesh passed in parameter to the generation map.
  14341. */
  14342. protected _renderSubMesh(subMesh: SubMesh): void;
  14343. /**
  14344. * Rebuild the required buffers.
  14345. * @hidden Internal use only.
  14346. */
  14347. _rebuild(): void;
  14348. /**
  14349. * Dispose only the render target textures and post process.
  14350. */
  14351. private _disposeTextureAndPostProcesses;
  14352. /**
  14353. * Dispose the highlight layer and free resources.
  14354. */
  14355. dispose(): void;
  14356. /**
  14357. * Gets the class name of the effect layer
  14358. * @returns the string with the class name of the effect layer
  14359. */
  14360. getClassName(): string;
  14361. /**
  14362. * Creates an effect layer from parsed effect layer data
  14363. * @param parsedEffectLayer defines effect layer data
  14364. * @param scene defines the current scene
  14365. * @param rootUrl defines the root URL containing the effect layer information
  14366. * @returns a parsed effect Layer
  14367. */
  14368. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14369. }
  14370. }
  14371. declare module BABYLON {
  14372. interface AbstractScene {
  14373. /**
  14374. * The list of effect layers (highlights/glow) added to the scene
  14375. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14376. * @see http://doc.babylonjs.com/how_to/glow_layer
  14377. */
  14378. effectLayers: Array<EffectLayer>;
  14379. /**
  14380. * Removes the given effect layer from this scene.
  14381. * @param toRemove defines the effect layer to remove
  14382. * @returns the index of the removed effect layer
  14383. */
  14384. removeEffectLayer(toRemove: EffectLayer): number;
  14385. /**
  14386. * Adds the given effect layer to this scene
  14387. * @param newEffectLayer defines the effect layer to add
  14388. */
  14389. addEffectLayer(newEffectLayer: EffectLayer): void;
  14390. }
  14391. /**
  14392. * Defines the layer scene component responsible to manage any effect layers
  14393. * in a given scene.
  14394. */
  14395. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14396. /**
  14397. * The component name helpfull to identify the component in the list of scene components.
  14398. */
  14399. readonly name: string;
  14400. /**
  14401. * The scene the component belongs to.
  14402. */
  14403. scene: Scene;
  14404. private _engine;
  14405. private _renderEffects;
  14406. private _needStencil;
  14407. private _previousStencilState;
  14408. /**
  14409. * Creates a new instance of the component for the given scene
  14410. * @param scene Defines the scene to register the component in
  14411. */
  14412. constructor(scene: Scene);
  14413. /**
  14414. * Registers the component in a given scene
  14415. */
  14416. register(): void;
  14417. /**
  14418. * Rebuilds the elements related to this component in case of
  14419. * context lost for instance.
  14420. */
  14421. rebuild(): void;
  14422. /**
  14423. * Serializes the component data to the specified json object
  14424. * @param serializationObject The object to serialize to
  14425. */
  14426. serialize(serializationObject: any): void;
  14427. /**
  14428. * Adds all the element from the container to the scene
  14429. * @param container the container holding the elements
  14430. */
  14431. addFromContainer(container: AbstractScene): void;
  14432. /**
  14433. * Removes all the elements in the container from the scene
  14434. * @param container contains the elements to remove
  14435. */
  14436. removeFromContainer(container: AbstractScene): void;
  14437. /**
  14438. * Disposes the component and the associated ressources.
  14439. */
  14440. dispose(): void;
  14441. private _isReadyForMesh;
  14442. private _renderMainTexture;
  14443. private _setStencil;
  14444. private _setStencilBack;
  14445. private _draw;
  14446. private _drawCamera;
  14447. private _drawRenderingGroup;
  14448. }
  14449. }
  14450. declare module BABYLON {
  14451. interface AbstractScene {
  14452. /**
  14453. * Return a the first highlight layer of the scene with a given name.
  14454. * @param name The name of the highlight layer to look for.
  14455. * @return The highlight layer if found otherwise null.
  14456. */
  14457. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14458. }
  14459. /**
  14460. * Glow layer options. This helps customizing the behaviour
  14461. * of the glow layer.
  14462. */
  14463. interface IGlowLayerOptions {
  14464. /**
  14465. * Multiplication factor apply to the canvas size to compute the render target size
  14466. * used to generated the glowing objects (the smaller the faster).
  14467. */
  14468. mainTextureRatio: number;
  14469. /**
  14470. * Enforces a fixed size texture to ensure resize independant blur.
  14471. */
  14472. mainTextureFixedSize?: number;
  14473. /**
  14474. * How big is the kernel of the blur texture.
  14475. */
  14476. blurKernelSize: number;
  14477. /**
  14478. * The camera attached to the layer.
  14479. */
  14480. camera: Nullable<Camera>;
  14481. /**
  14482. * Enable MSAA by chosing the number of samples.
  14483. */
  14484. mainTextureSamples?: number;
  14485. /**
  14486. * The rendering group to draw the layer in.
  14487. */
  14488. renderingGroupId: number;
  14489. }
  14490. /**
  14491. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14492. *
  14493. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14494. * glowy meshes to your scene.
  14495. *
  14496. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14497. */
  14498. class GlowLayer extends EffectLayer {
  14499. /**
  14500. * Effect Name of the layer.
  14501. */
  14502. static readonly EffectName: string;
  14503. /**
  14504. * The default blur kernel size used for the glow.
  14505. */
  14506. static DefaultBlurKernelSize: number;
  14507. /**
  14508. * The default texture size ratio used for the glow.
  14509. */
  14510. static DefaultTextureRatio: number;
  14511. /**
  14512. * Sets the kernel size of the blur.
  14513. */
  14514. /**
  14515. * Gets the kernel size of the blur.
  14516. */
  14517. blurKernelSize: number;
  14518. /**
  14519. * Sets the glow intensity.
  14520. */
  14521. /**
  14522. * Gets the glow intensity.
  14523. */
  14524. intensity: number;
  14525. private _options;
  14526. private _intensity;
  14527. private _horizontalBlurPostprocess1;
  14528. private _verticalBlurPostprocess1;
  14529. private _horizontalBlurPostprocess2;
  14530. private _verticalBlurPostprocess2;
  14531. private _blurTexture1;
  14532. private _blurTexture2;
  14533. private _postProcesses1;
  14534. private _postProcesses2;
  14535. private _includedOnlyMeshes;
  14536. private _excludedMeshes;
  14537. /**
  14538. * Callback used to let the user override the color selection on a per mesh basis
  14539. */
  14540. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14541. /**
  14542. * Callback used to let the user override the texture selection on a per mesh basis
  14543. */
  14544. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14545. /**
  14546. * Instantiates a new glow Layer and references it to the scene.
  14547. * @param name The name of the layer
  14548. * @param scene The scene to use the layer in
  14549. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14550. */
  14551. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14552. /**
  14553. * Get the effect name of the layer.
  14554. * @return The effect name
  14555. */
  14556. getEffectName(): string;
  14557. /**
  14558. * Create the merge effect. This is the shader use to blit the information back
  14559. * to the main canvas at the end of the scene rendering.
  14560. */
  14561. protected _createMergeEffect(): Effect;
  14562. /**
  14563. * Creates the render target textures and post processes used in the glow layer.
  14564. */
  14565. protected _createTextureAndPostProcesses(): void;
  14566. /**
  14567. * Checks for the readiness of the element composing the layer.
  14568. * @param subMesh the mesh to check for
  14569. * @param useInstances specify wether or not to use instances to render the mesh
  14570. * @param emissiveTexture the associated emissive texture used to generate the glow
  14571. * @return true if ready otherwise, false
  14572. */
  14573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14574. /**
  14575. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14576. */
  14577. needStencil(): boolean;
  14578. /**
  14579. * Implementation specific of rendering the generating effect on the main canvas.
  14580. * @param effect The effect used to render through
  14581. */
  14582. protected _internalRender(effect: Effect): void;
  14583. /**
  14584. * Sets the required values for both the emissive texture and and the main color.
  14585. */
  14586. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14587. /**
  14588. * Returns true if the mesh should render, otherwise false.
  14589. * @param mesh The mesh to render
  14590. * @returns true if it should render otherwise false
  14591. */
  14592. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14593. /**
  14594. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14595. * @param mesh The mesh to exclude from the glow layer
  14596. */
  14597. addExcludedMesh(mesh: Mesh): void;
  14598. /**
  14599. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14600. * @param mesh The mesh to remove
  14601. */
  14602. removeExcludedMesh(mesh: Mesh): void;
  14603. /**
  14604. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14605. * @param mesh The mesh to include in the glow layer
  14606. */
  14607. addIncludedOnlyMesh(mesh: Mesh): void;
  14608. /**
  14609. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14610. * @param mesh The mesh to remove
  14611. */
  14612. removeIncludedOnlyMesh(mesh: Mesh): void;
  14613. /**
  14614. * Determine if a given mesh will be used in the glow layer
  14615. * @param mesh The mesh to test
  14616. * @returns true if the mesh will be highlighted by the current glow layer
  14617. */
  14618. hasMesh(mesh: AbstractMesh): boolean;
  14619. /**
  14620. * Free any resources and references associated to a mesh.
  14621. * Internal use
  14622. * @param mesh The mesh to free.
  14623. * @hidden
  14624. */
  14625. _disposeMesh(mesh: Mesh): void;
  14626. /**
  14627. * Gets the class name of the effect layer
  14628. * @returns the string with the class name of the effect layer
  14629. */
  14630. getClassName(): string;
  14631. /**
  14632. * Serializes this glow layer
  14633. * @returns a serialized glow layer object
  14634. */
  14635. serialize(): any;
  14636. /**
  14637. * Creates a Glow Layer from parsed glow layer data
  14638. * @param parsedGlowLayer defines glow layer data
  14639. * @param scene defines the current scene
  14640. * @param rootUrl defines the root URL containing the glow layer information
  14641. * @returns a parsed Glow Layer
  14642. */
  14643. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14644. }
  14645. }
  14646. declare module BABYLON {
  14647. interface AbstractScene {
  14648. /**
  14649. * Return a the first highlight layer of the scene with a given name.
  14650. * @param name The name of the highlight layer to look for.
  14651. * @return The highlight layer if found otherwise null.
  14652. */
  14653. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14654. }
  14655. /**
  14656. * Highlight layer options. This helps customizing the behaviour
  14657. * of the highlight layer.
  14658. */
  14659. interface IHighlightLayerOptions {
  14660. /**
  14661. * Multiplication factor apply to the canvas size to compute the render target size
  14662. * used to generated the glowing objects (the smaller the faster).
  14663. */
  14664. mainTextureRatio: number;
  14665. /**
  14666. * Enforces a fixed size texture to ensure resize independant blur.
  14667. */
  14668. mainTextureFixedSize?: number;
  14669. /**
  14670. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14671. * of the picture to blur (the smaller the faster).
  14672. */
  14673. blurTextureSizeRatio: number;
  14674. /**
  14675. * How big in texel of the blur texture is the vertical blur.
  14676. */
  14677. blurVerticalSize: number;
  14678. /**
  14679. * How big in texel of the blur texture is the horizontal blur.
  14680. */
  14681. blurHorizontalSize: number;
  14682. /**
  14683. * Alpha blending mode used to apply the blur. Default is combine.
  14684. */
  14685. alphaBlendingMode: number;
  14686. /**
  14687. * The camera attached to the layer.
  14688. */
  14689. camera: Nullable<Camera>;
  14690. /**
  14691. * Should we display highlight as a solid stroke?
  14692. */
  14693. isStroke?: boolean;
  14694. /**
  14695. * The rendering group to draw the layer in.
  14696. */
  14697. renderingGroupId: number;
  14698. }
  14699. /**
  14700. * The highlight layer Helps adding a glow effect around a mesh.
  14701. *
  14702. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14703. * glowy meshes to your scene.
  14704. *
  14705. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14706. */
  14707. class HighlightLayer extends EffectLayer {
  14708. name: string;
  14709. /**
  14710. * Effect Name of the highlight layer.
  14711. */
  14712. static readonly EffectName: string;
  14713. /**
  14714. * The neutral color used during the preparation of the glow effect.
  14715. * This is black by default as the blend operation is a blend operation.
  14716. */
  14717. static NeutralColor: Color4;
  14718. /**
  14719. * Stencil value used for glowing meshes.
  14720. */
  14721. static GlowingMeshStencilReference: number;
  14722. /**
  14723. * Stencil value used for the other meshes in the scene.
  14724. */
  14725. static NormalMeshStencilReference: number;
  14726. /**
  14727. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14728. */
  14729. innerGlow: boolean;
  14730. /**
  14731. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14732. */
  14733. outerGlow: boolean;
  14734. /**
  14735. * Specifies the horizontal size of the blur.
  14736. */
  14737. /**
  14738. * Gets the horizontal size of the blur.
  14739. */
  14740. blurHorizontalSize: number;
  14741. /**
  14742. * Specifies the vertical size of the blur.
  14743. */
  14744. /**
  14745. * Gets the vertical size of the blur.
  14746. */
  14747. blurVerticalSize: number;
  14748. /**
  14749. * An event triggered when the highlight layer is being blurred.
  14750. */
  14751. onBeforeBlurObservable: Observable<HighlightLayer>;
  14752. /**
  14753. * An event triggered when the highlight layer has been blurred.
  14754. */
  14755. onAfterBlurObservable: Observable<HighlightLayer>;
  14756. private _instanceGlowingMeshStencilReference;
  14757. private _options;
  14758. private _downSamplePostprocess;
  14759. private _horizontalBlurPostprocess;
  14760. private _verticalBlurPostprocess;
  14761. private _blurTexture;
  14762. private _meshes;
  14763. private _excludedMeshes;
  14764. /**
  14765. * Instantiates a new highlight Layer and references it to the scene..
  14766. * @param name The name of the layer
  14767. * @param scene The scene to use the layer in
  14768. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14769. */
  14770. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14771. /**
  14772. * Get the effect name of the layer.
  14773. * @return The effect name
  14774. */
  14775. getEffectName(): string;
  14776. /**
  14777. * Create the merge effect. This is the shader use to blit the information back
  14778. * to the main canvas at the end of the scene rendering.
  14779. */
  14780. protected _createMergeEffect(): Effect;
  14781. /**
  14782. * Creates the render target textures and post processes used in the highlight layer.
  14783. */
  14784. protected _createTextureAndPostProcesses(): void;
  14785. /**
  14786. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14787. */
  14788. needStencil(): boolean;
  14789. /**
  14790. * Checks for the readiness of the element composing the layer.
  14791. * @param subMesh the mesh to check for
  14792. * @param useInstances specify wether or not to use instances to render the mesh
  14793. * @param emissiveTexture the associated emissive texture used to generate the glow
  14794. * @return true if ready otherwise, false
  14795. */
  14796. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14797. /**
  14798. * Implementation specific of rendering the generating effect on the main canvas.
  14799. * @param effect The effect used to render through
  14800. */
  14801. protected _internalRender(effect: Effect): void;
  14802. /**
  14803. * Returns true if the layer contains information to display, otherwise false.
  14804. */
  14805. shouldRender(): boolean;
  14806. /**
  14807. * Returns true if the mesh should render, otherwise false.
  14808. * @param mesh The mesh to render
  14809. * @returns true if it should render otherwise false
  14810. */
  14811. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14812. /**
  14813. * Sets the required values for both the emissive texture and and the main color.
  14814. */
  14815. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14816. /**
  14817. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14818. * @param mesh The mesh to exclude from the highlight layer
  14819. */
  14820. addExcludedMesh(mesh: Mesh): void;
  14821. /**
  14822. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14823. * @param mesh The mesh to highlight
  14824. */
  14825. removeExcludedMesh(mesh: Mesh): void;
  14826. /**
  14827. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14828. * @param mesh mesh to test
  14829. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14830. */
  14831. hasMesh(mesh: AbstractMesh): boolean;
  14832. /**
  14833. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14834. * @param mesh The mesh to highlight
  14835. * @param color The color of the highlight
  14836. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14837. */
  14838. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14839. /**
  14840. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14841. * @param mesh The mesh to highlight
  14842. */
  14843. removeMesh(mesh: Mesh): void;
  14844. /**
  14845. * Force the stencil to the normal expected value for none glowing parts
  14846. */
  14847. private _defaultStencilReference;
  14848. /**
  14849. * Free any resources and references associated to a mesh.
  14850. * Internal use
  14851. * @param mesh The mesh to free.
  14852. * @hidden
  14853. */
  14854. _disposeMesh(mesh: Mesh): void;
  14855. /**
  14856. * Dispose the highlight layer and free resources.
  14857. */
  14858. dispose(): void;
  14859. /**
  14860. * Gets the class name of the effect layer
  14861. * @returns the string with the class name of the effect layer
  14862. */
  14863. getClassName(): string;
  14864. /**
  14865. * Serializes this Highlight layer
  14866. * @returns a serialized Highlight layer object
  14867. */
  14868. serialize(): any;
  14869. /**
  14870. * Creates a Highlight layer from parsed Highlight layer data
  14871. * @param parsedHightlightLayer defines the Highlight layer data
  14872. * @param scene defines the current scene
  14873. * @param rootUrl defines the root URL containing the Highlight layer information
  14874. * @returns a parsed Highlight layer
  14875. */
  14876. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14877. }
  14878. }
  14879. declare module BABYLON {
  14880. /**
  14881. * This represents a full screen 2d layer.
  14882. * This can be usefull to display a picture in the background of your scene for instance.
  14883. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14884. */
  14885. class Layer {
  14886. /**
  14887. * Define the name of the layer.
  14888. */
  14889. name: string;
  14890. /**
  14891. * Define the texture the layer should display.
  14892. */
  14893. texture: Nullable<Texture>;
  14894. /**
  14895. * Is the layer in background or foreground.
  14896. */
  14897. isBackground: boolean;
  14898. /**
  14899. * Define the color of the layer (instead of texture).
  14900. */
  14901. color: Color4;
  14902. /**
  14903. * Define the scale of the layer in order to zoom in out of the texture.
  14904. */
  14905. scale: Vector2;
  14906. /**
  14907. * Define an offset for the layer in order to shift the texture.
  14908. */
  14909. offset: Vector2;
  14910. /**
  14911. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14912. */
  14913. alphaBlendingMode: number;
  14914. /**
  14915. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14916. * Alpha test will not mix with the background color in case of transparency.
  14917. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14918. */
  14919. alphaTest: boolean;
  14920. /**
  14921. * Define a mask to restrict the layer to only some of the scene cameras.
  14922. */
  14923. layerMask: number;
  14924. private _scene;
  14925. private _vertexBuffers;
  14926. private _indexBuffer;
  14927. private _effect;
  14928. private _alphaTestEffect;
  14929. /**
  14930. * An event triggered when the layer is disposed.
  14931. */
  14932. onDisposeObservable: Observable<Layer>;
  14933. private _onDisposeObserver;
  14934. /**
  14935. * Back compatibility with callback before the onDisposeObservable existed.
  14936. * The set callback will be triggered when the layer has been disposed.
  14937. */
  14938. onDispose: () => void;
  14939. /**
  14940. * An event triggered before rendering the scene
  14941. */
  14942. onBeforeRenderObservable: Observable<Layer>;
  14943. private _onBeforeRenderObserver;
  14944. /**
  14945. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14946. * The set callback will be triggered just before rendering the layer.
  14947. */
  14948. onBeforeRender: () => void;
  14949. /**
  14950. * An event triggered after rendering the scene
  14951. */
  14952. onAfterRenderObservable: Observable<Layer>;
  14953. private _onAfterRenderObserver;
  14954. /**
  14955. * Back compatibility with callback before the onAfterRenderObservable existed.
  14956. * The set callback will be triggered just after rendering the layer.
  14957. */
  14958. onAfterRender: () => void;
  14959. /**
  14960. * Instantiates a new layer.
  14961. * This represents a full screen 2d layer.
  14962. * This can be usefull to display a picture in the background of your scene for instance.
  14963. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14964. * @param name Define the name of the layer in the scene
  14965. * @param imgUrl Define the url of the texture to display in the layer
  14966. * @param scene Define the scene the layer belongs to
  14967. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14968. * @param color Defines a color for the layer
  14969. */
  14970. constructor(
  14971. /**
  14972. * Define the name of the layer.
  14973. */
  14974. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14975. private _createIndexBuffer;
  14976. /** @hidden */
  14977. _rebuild(): void;
  14978. /**
  14979. * Renders the layer in the scene.
  14980. */
  14981. render(): void;
  14982. /**
  14983. * Disposes and releases the associated ressources.
  14984. */
  14985. dispose(): void;
  14986. }
  14987. }
  14988. declare module BABYLON {
  14989. interface AbstractScene {
  14990. /**
  14991. * The list of layers (background and foreground) of the scene
  14992. */
  14993. layers: Array<Layer>;
  14994. }
  14995. /**
  14996. * Defines the layer scene component responsible to manage any layers
  14997. * in a given scene.
  14998. */
  14999. class LayerSceneComponent implements ISceneComponent {
  15000. /**
  15001. * The component name helpfull to identify the component in the list of scene components.
  15002. */
  15003. readonly name: string;
  15004. /**
  15005. * The scene the component belongs to.
  15006. */
  15007. scene: Scene;
  15008. private _engine;
  15009. /**
  15010. * Creates a new instance of the component for the given scene
  15011. * @param scene Defines the scene to register the component in
  15012. */
  15013. constructor(scene: Scene);
  15014. /**
  15015. * Registers the component in a given scene
  15016. */
  15017. register(): void;
  15018. /**
  15019. * Rebuilds the elements related to this component in case of
  15020. * context lost for instance.
  15021. */
  15022. rebuild(): void;
  15023. /**
  15024. * Disposes the component and the associated ressources.
  15025. */
  15026. dispose(): void;
  15027. private _draw;
  15028. private _drawBackground;
  15029. private _drawForeground;
  15030. }
  15031. }
  15032. declare module BABYLON {
  15033. /**
  15034. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15035. * It controls one of the indiviual texture used in the effect.
  15036. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15037. */
  15038. class LensFlare {
  15039. /**
  15040. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15041. */
  15042. size: number;
  15043. /**
  15044. * 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.
  15045. */
  15046. position: number;
  15047. /**
  15048. * Define the lens color.
  15049. */
  15050. color: Color3;
  15051. /**
  15052. * Define the lens texture.
  15053. */
  15054. texture: Nullable<Texture>;
  15055. /**
  15056. * Define the alpha mode to render this particular lens.
  15057. */
  15058. alphaMode: number;
  15059. private _system;
  15060. /**
  15061. * Creates a new Lens Flare.
  15062. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15063. * It controls one of the indiviual texture used in the effect.
  15064. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15065. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15066. * @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.
  15067. * @param color Define the lens color
  15068. * @param imgUrl Define the lens texture url
  15069. * @param system Define the `lensFlareSystem` this flare is part of
  15070. * @returns The newly created Lens Flare
  15071. */
  15072. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15073. /**
  15074. * Instantiates a new Lens Flare.
  15075. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15076. * It controls one of the indiviual texture used in the effect.
  15077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15078. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15079. * @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.
  15080. * @param color Define the lens color
  15081. * @param imgUrl Define the lens texture url
  15082. * @param system Define the `lensFlareSystem` this flare is part of
  15083. */
  15084. constructor(
  15085. /**
  15086. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15087. */
  15088. size: number,
  15089. /**
  15090. * 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.
  15091. */
  15092. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15093. /**
  15094. * Dispose and release the lens flare with its associated resources.
  15095. */
  15096. dispose(): void;
  15097. }
  15098. }
  15099. declare module BABYLON {
  15100. /**
  15101. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15102. * It is usually composed of several `BABYLON.lensFlare`.
  15103. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15104. */
  15105. class LensFlareSystem {
  15106. /**
  15107. * Define the name of the lens flare system
  15108. */
  15109. name: string;
  15110. /**
  15111. * List of lens flares used in this system.
  15112. */
  15113. lensFlares: LensFlare[];
  15114. /**
  15115. * Define a limit from the border the lens flare can be visible.
  15116. */
  15117. borderLimit: number;
  15118. /**
  15119. * Define a viewport border we do not want to see the lens flare in.
  15120. */
  15121. viewportBorder: number;
  15122. /**
  15123. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15124. */
  15125. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15126. /**
  15127. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15128. */
  15129. layerMask: number;
  15130. /**
  15131. * Define the id of the lens flare system in the scene.
  15132. * (equal to name by default)
  15133. */
  15134. id: string;
  15135. private _scene;
  15136. private _emitter;
  15137. private _vertexBuffers;
  15138. private _indexBuffer;
  15139. private _effect;
  15140. private _positionX;
  15141. private _positionY;
  15142. private _isEnabled;
  15143. /**
  15144. * Instantiates a lens flare system.
  15145. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15146. * It is usually composed of several `BABYLON.lensFlare`.
  15147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15148. * @param name Define the name of the lens flare system in the scene
  15149. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15150. * @param scene Define the scene the lens flare system belongs to
  15151. */
  15152. constructor(
  15153. /**
  15154. * Define the name of the lens flare system
  15155. */
  15156. name: string, emitter: any, scene: Scene);
  15157. /**
  15158. * Define if the lens flare system is enabled.
  15159. */
  15160. isEnabled: boolean;
  15161. /**
  15162. * Get the scene the effects belongs to.
  15163. * @returns the scene holding the lens flare system
  15164. */
  15165. getScene(): Scene;
  15166. /**
  15167. * Get the emitter of the lens flare system.
  15168. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15169. * @returns the emitter of the lens flare system
  15170. */
  15171. getEmitter(): any;
  15172. /**
  15173. * Set the emitter of the lens flare system.
  15174. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15175. * @param newEmitter Define the new emitter of the system
  15176. */
  15177. setEmitter(newEmitter: any): void;
  15178. /**
  15179. * Get the lens flare system emitter position.
  15180. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15181. * @returns the position
  15182. */
  15183. getEmitterPosition(): Vector3;
  15184. /**
  15185. * @hidden
  15186. */
  15187. computeEffectivePosition(globalViewport: Viewport): boolean;
  15188. /** @hidden */
  15189. _isVisible(): boolean;
  15190. /**
  15191. * @hidden
  15192. */
  15193. render(): boolean;
  15194. /**
  15195. * Dispose and release the lens flare with its associated resources.
  15196. */
  15197. dispose(): void;
  15198. /**
  15199. * Parse a lens flare system from a JSON repressentation
  15200. * @param parsedLensFlareSystem Define the JSON to parse
  15201. * @param scene Define the scene the parsed system should be instantiated in
  15202. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15203. * @returns the parsed system
  15204. */
  15205. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15206. /**
  15207. * Serialize the current Lens Flare System into a JSON representation.
  15208. * @returns the serialized JSON
  15209. */
  15210. serialize(): any;
  15211. }
  15212. }
  15213. declare module BABYLON {
  15214. interface AbstractScene {
  15215. /**
  15216. * The list of lens flare system added to the scene
  15217. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15218. */
  15219. lensFlareSystems: Array<LensFlareSystem>;
  15220. /**
  15221. * Removes the given lens flare system from this scene.
  15222. * @param toRemove The lens flare system to remove
  15223. * @returns The index of the removed lens flare system
  15224. */
  15225. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15226. /**
  15227. * Adds the given lens flare system to this scene
  15228. * @param newLensFlareSystem The lens flare system to add
  15229. */
  15230. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15231. /**
  15232. * Gets a lens flare system using its name
  15233. * @param name defines the name to look for
  15234. * @returns the lens flare system or null if not found
  15235. */
  15236. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15237. /**
  15238. * Gets a lens flare system using its id
  15239. * @param id defines the id to look for
  15240. * @returns the lens flare system or null if not found
  15241. */
  15242. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15243. }
  15244. /**
  15245. * Defines the lens flare scene component responsible to manage any lens flares
  15246. * in a given scene.
  15247. */
  15248. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15249. /**
  15250. * The component name helpfull to identify the component in the list of scene components.
  15251. */
  15252. readonly name: string;
  15253. /**
  15254. * The scene the component belongs to.
  15255. */
  15256. scene: Scene;
  15257. /**
  15258. * Creates a new instance of the component for the given scene
  15259. * @param scene Defines the scene to register the component in
  15260. */
  15261. constructor(scene: Scene);
  15262. /**
  15263. * Registers the component in a given scene
  15264. */
  15265. register(): void;
  15266. /**
  15267. * Rebuilds the elements related to this component in case of
  15268. * context lost for instance.
  15269. */
  15270. rebuild(): void;
  15271. /**
  15272. * Adds all the element from the container to the scene
  15273. * @param container the container holding the elements
  15274. */
  15275. addFromContainer(container: AbstractScene): void;
  15276. /**
  15277. * Removes all the elements in the container from the scene
  15278. * @param container contains the elements to remove
  15279. */
  15280. removeFromContainer(container: AbstractScene): void;
  15281. /**
  15282. * Serializes the component data to the specified json object
  15283. * @param serializationObject The object to serialize to
  15284. */
  15285. serialize(serializationObject: any): void;
  15286. /**
  15287. * Disposes the component and the associated ressources.
  15288. */
  15289. dispose(): void;
  15290. private _draw;
  15291. }
  15292. }
  15293. declare module BABYLON {
  15294. /**
  15295. * A directional light is defined by a direction (what a surprise!).
  15296. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15297. * 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.
  15298. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15299. */
  15300. class DirectionalLight extends ShadowLight {
  15301. private _shadowFrustumSize;
  15302. /**
  15303. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15304. */
  15305. /**
  15306. * Specifies a fix frustum size for the shadow generation.
  15307. */
  15308. shadowFrustumSize: number;
  15309. private _shadowOrthoScale;
  15310. /**
  15311. * Gets the shadow projection scale against the optimal computed one.
  15312. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15313. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15314. */
  15315. /**
  15316. * Sets the shadow projection scale against the optimal computed one.
  15317. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15318. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15319. */
  15320. shadowOrthoScale: number;
  15321. /**
  15322. * Automatically compute the projection matrix to best fit (including all the casters)
  15323. * on each frame.
  15324. */
  15325. autoUpdateExtends: boolean;
  15326. private _orthoLeft;
  15327. private _orthoRight;
  15328. private _orthoTop;
  15329. private _orthoBottom;
  15330. /**
  15331. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15332. * The directional light is emitted from everywhere in the given direction.
  15333. * It can cast shadows.
  15334. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15335. * @param name The friendly name of the light
  15336. * @param direction The direction of the light
  15337. * @param scene The scene the light belongs to
  15338. */
  15339. constructor(name: string, direction: Vector3, scene: Scene);
  15340. /**
  15341. * Returns the string "DirectionalLight".
  15342. * @return The class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Returns the integer 1.
  15347. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15348. */
  15349. getTypeID(): number;
  15350. /**
  15351. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15352. * Returns the DirectionalLight Shadow projection matrix.
  15353. */
  15354. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15355. /**
  15356. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15357. * Returns the DirectionalLight Shadow projection matrix.
  15358. */
  15359. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15360. /**
  15361. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15362. * Returns the DirectionalLight Shadow projection matrix.
  15363. */
  15364. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15365. protected _buildUniformLayout(): void;
  15366. /**
  15367. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15368. * @param effect The effect to update
  15369. * @param lightIndex The index of the light in the effect to update
  15370. * @returns The directional light
  15371. */
  15372. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15373. /**
  15374. * Gets the minZ used for shadow according to both the scene and the light.
  15375. *
  15376. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15377. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15378. * @param activeCamera The camera we are returning the min for
  15379. * @returns the depth min z
  15380. */
  15381. getDepthMinZ(activeCamera: Camera): number;
  15382. /**
  15383. * Gets the maxZ used for shadow according to both the scene and the light.
  15384. *
  15385. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15386. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15387. * @param activeCamera The camera we are returning the max for
  15388. * @returns the depth max z
  15389. */
  15390. getDepthMaxZ(activeCamera: Camera): number;
  15391. /**
  15392. * Prepares the list of defines specific to the light type.
  15393. * @param defines the list of defines
  15394. * @param lightIndex defines the index of the light for the effect
  15395. */
  15396. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15397. }
  15398. }
  15399. declare module BABYLON {
  15400. /**
  15401. * The HemisphericLight simulates the ambient environment light,
  15402. * so the passed direction is the light reflection direction, not the incoming direction.
  15403. */
  15404. class HemisphericLight extends Light {
  15405. /**
  15406. * The groundColor is the light in the opposite direction to the one specified during creation.
  15407. * 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.
  15408. */
  15409. groundColor: Color3;
  15410. /**
  15411. * The light reflection direction, not the incoming direction.
  15412. */
  15413. direction: Vector3;
  15414. /**
  15415. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15416. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15417. * The HemisphericLight can't cast shadows.
  15418. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15419. * @param name The friendly name of the light
  15420. * @param direction The direction of the light reflection
  15421. * @param scene The scene the light belongs to
  15422. */
  15423. constructor(name: string, direction: Vector3, scene: Scene);
  15424. protected _buildUniformLayout(): void;
  15425. /**
  15426. * Returns the string "HemisphericLight".
  15427. * @return The class name
  15428. */
  15429. getClassName(): string;
  15430. /**
  15431. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15432. * Returns the updated direction.
  15433. * @param target The target the direction should point to
  15434. * @return The computed direction
  15435. */
  15436. setDirectionToTarget(target: Vector3): Vector3;
  15437. /**
  15438. * Returns the shadow generator associated to the light.
  15439. * @returns Always null for hemispheric lights because it does not support shadows.
  15440. */
  15441. getShadowGenerator(): Nullable<IShadowGenerator>;
  15442. /**
  15443. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15444. * @param effect The effect to update
  15445. * @param lightIndex The index of the light in the effect to update
  15446. * @returns The hemispheric light
  15447. */
  15448. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15449. /**
  15450. * Computes the world matrix of the node
  15451. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15452. * @param useWasUpdatedFlag defines a reserved property
  15453. * @returns the world matrix
  15454. */
  15455. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15456. /**
  15457. * Returns the integer 3.
  15458. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15459. */
  15460. getTypeID(): number;
  15461. /**
  15462. * Prepares the list of defines specific to the light type.
  15463. * @param defines the list of defines
  15464. * @param lightIndex defines the index of the light for the effect
  15465. */
  15466. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15467. }
  15468. }
  15469. declare module BABYLON {
  15470. /**
  15471. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15472. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15473. * 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.
  15474. */
  15475. abstract class Light extends Node {
  15476. /**
  15477. * Falloff Default: light is falling off following the material specification:
  15478. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15479. */
  15480. static readonly FALLOFF_DEFAULT: number;
  15481. /**
  15482. * Falloff Physical: light is falling off following the inverse squared distance law.
  15483. */
  15484. static readonly FALLOFF_PHYSICAL: number;
  15485. /**
  15486. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15487. * to enhance interoperability with other engines.
  15488. */
  15489. static readonly FALLOFF_GLTF: number;
  15490. /**
  15491. * Falloff Standard: light is falling off like in the standard material
  15492. * to enhance interoperability with other materials.
  15493. */
  15494. static readonly FALLOFF_STANDARD: number;
  15495. /**
  15496. * If every light affecting the material is in this lightmapMode,
  15497. * material.lightmapTexture adds or multiplies
  15498. * (depends on material.useLightmapAsShadowmap)
  15499. * after every other light calculations.
  15500. */
  15501. static readonly LIGHTMAP_DEFAULT: number;
  15502. /**
  15503. * material.lightmapTexture as only diffuse lighting from this light
  15504. * adds only specular lighting from this light
  15505. * adds dynamic shadows
  15506. */
  15507. static readonly LIGHTMAP_SPECULAR: number;
  15508. /**
  15509. * material.lightmapTexture as only lighting
  15510. * no light calculation from this light
  15511. * only adds dynamic shadows from this light
  15512. */
  15513. static readonly LIGHTMAP_SHADOWSONLY: number;
  15514. /**
  15515. * Each light type uses the default quantity according to its type:
  15516. * point/spot lights use luminous intensity
  15517. * directional lights use illuminance
  15518. */
  15519. static readonly INTENSITYMODE_AUTOMATIC: number;
  15520. /**
  15521. * lumen (lm)
  15522. */
  15523. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15524. /**
  15525. * candela (lm/sr)
  15526. */
  15527. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15528. /**
  15529. * lux (lm/m^2)
  15530. */
  15531. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15532. /**
  15533. * nit (cd/m^2)
  15534. */
  15535. static readonly INTENSITYMODE_LUMINANCE: number;
  15536. /**
  15537. * Light type const id of the point light.
  15538. */
  15539. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15540. /**
  15541. * Light type const id of the directional light.
  15542. */
  15543. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15544. /**
  15545. * Light type const id of the spot light.
  15546. */
  15547. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15548. /**
  15549. * Light type const id of the hemispheric light.
  15550. */
  15551. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15552. /**
  15553. * Diffuse gives the basic color to an object.
  15554. */
  15555. diffuse: Color3;
  15556. /**
  15557. * Specular produces a highlight color on an object.
  15558. * Note: This is note affecting PBR materials.
  15559. */
  15560. specular: Color3;
  15561. /**
  15562. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15563. * falling off base on range or angle.
  15564. * This can be set to any values in Light.FALLOFF_x.
  15565. *
  15566. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15567. * other types of materials.
  15568. */
  15569. falloffType: number;
  15570. /**
  15571. * Strength of the light.
  15572. * Note: By default it is define in the framework own unit.
  15573. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15574. */
  15575. intensity: number;
  15576. private _range;
  15577. protected _inverseSquaredRange: number;
  15578. /**
  15579. * Defines how far from the source the light is impacting in scene units.
  15580. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15581. */
  15582. /**
  15583. * Defines how far from the source the light is impacting in scene units.
  15584. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15585. */
  15586. range: number;
  15587. /**
  15588. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15589. * of light.
  15590. */
  15591. private _photometricScale;
  15592. private _intensityMode;
  15593. /**
  15594. * Gets the photometric scale used to interpret the intensity.
  15595. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15596. */
  15597. /**
  15598. * Sets the photometric scale used to interpret the intensity.
  15599. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15600. */
  15601. intensityMode: number;
  15602. private _radius;
  15603. /**
  15604. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15605. */
  15606. /**
  15607. * sets the light radius used by PBR Materials to simulate soft area lights.
  15608. */
  15609. radius: number;
  15610. private _renderPriority;
  15611. /**
  15612. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15613. * exceeding the number allowed of the materials.
  15614. */
  15615. renderPriority: number;
  15616. private _shadowEnabled;
  15617. /**
  15618. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15619. * the current shadow generator.
  15620. */
  15621. /**
  15622. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15623. * the current shadow generator.
  15624. */
  15625. shadowEnabled: boolean;
  15626. private _includedOnlyMeshes;
  15627. /**
  15628. * Gets the only meshes impacted by this light.
  15629. */
  15630. /**
  15631. * Sets the only meshes impacted by this light.
  15632. */
  15633. includedOnlyMeshes: AbstractMesh[];
  15634. private _excludedMeshes;
  15635. /**
  15636. * Gets the meshes not impacted by this light.
  15637. */
  15638. /**
  15639. * Sets the meshes not impacted by this light.
  15640. */
  15641. excludedMeshes: AbstractMesh[];
  15642. private _excludeWithLayerMask;
  15643. /**
  15644. * Gets the layer id use to find what meshes are not impacted by the light.
  15645. * Inactive if 0
  15646. */
  15647. /**
  15648. * Sets the layer id use to find what meshes are not impacted by the light.
  15649. * Inactive if 0
  15650. */
  15651. excludeWithLayerMask: number;
  15652. private _includeOnlyWithLayerMask;
  15653. /**
  15654. * Gets the layer id use to find what meshes are impacted by the light.
  15655. * Inactive if 0
  15656. */
  15657. /**
  15658. * Sets the layer id use to find what meshes are impacted by the light.
  15659. * Inactive if 0
  15660. */
  15661. includeOnlyWithLayerMask: number;
  15662. private _lightmapMode;
  15663. /**
  15664. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15665. */
  15666. /**
  15667. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15668. */
  15669. lightmapMode: number;
  15670. /**
  15671. * Shadow generator associted to the light.
  15672. * @hidden Internal use only.
  15673. */
  15674. _shadowGenerator: Nullable<IShadowGenerator>;
  15675. /**
  15676. * @hidden Internal use only.
  15677. */
  15678. _excludedMeshesIds: string[];
  15679. /**
  15680. * @hidden Internal use only.
  15681. */
  15682. _includedOnlyMeshesIds: string[];
  15683. /**
  15684. * The current light unifom buffer.
  15685. * @hidden Internal use only.
  15686. */
  15687. _uniformBuffer: UniformBuffer;
  15688. /**
  15689. * Creates a Light object in the scene.
  15690. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15691. * @param name The firendly name of the light
  15692. * @param scene The scene the light belongs too
  15693. */
  15694. constructor(name: string, scene: Scene);
  15695. protected abstract _buildUniformLayout(): void;
  15696. /**
  15697. * Sets the passed Effect "effect" with the Light information.
  15698. * @param effect The effect to update
  15699. * @param lightIndex The index of the light in the effect to update
  15700. * @returns The light
  15701. */
  15702. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15703. /**
  15704. * Returns the string "Light".
  15705. * @returns the class name
  15706. */
  15707. getClassName(): string;
  15708. /**
  15709. * Converts the light information to a readable string for debug purpose.
  15710. * @param fullDetails Supports for multiple levels of logging within scene loading
  15711. * @returns the human readable light info
  15712. */
  15713. toString(fullDetails?: boolean): string;
  15714. /** @hidden */
  15715. protected _syncParentEnabledState(): void;
  15716. /**
  15717. * Set the enabled state of this node.
  15718. * @param value - the new enabled state
  15719. */
  15720. setEnabled(value: boolean): void;
  15721. /**
  15722. * Returns the Light associated shadow generator if any.
  15723. * @return the associated shadow generator.
  15724. */
  15725. getShadowGenerator(): Nullable<IShadowGenerator>;
  15726. /**
  15727. * Returns a Vector3, the absolute light position in the World.
  15728. * @returns the world space position of the light
  15729. */
  15730. getAbsolutePosition(): Vector3;
  15731. /**
  15732. * Specifies if the light will affect the passed mesh.
  15733. * @param mesh The mesh to test against the light
  15734. * @return true the mesh is affected otherwise, false.
  15735. */
  15736. canAffectMesh(mesh: AbstractMesh): boolean;
  15737. /**
  15738. * Sort function to order lights for rendering.
  15739. * @param a First Light object to compare to second.
  15740. * @param b Second Light object to compare first.
  15741. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15742. */
  15743. static CompareLightsPriority(a: Light, b: Light): number;
  15744. /**
  15745. * Releases resources associated with this node.
  15746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15748. */
  15749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15750. /**
  15751. * Returns the light type ID (integer).
  15752. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15753. */
  15754. getTypeID(): number;
  15755. /**
  15756. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15757. * @returns the scaled intensity in intensity mode unit
  15758. */
  15759. getScaledIntensity(): number;
  15760. /**
  15761. * Returns a new Light object, named "name", from the current one.
  15762. * @param name The name of the cloned light
  15763. * @returns the new created light
  15764. */
  15765. clone(name: string): Nullable<Light>;
  15766. /**
  15767. * Serializes the current light into a Serialization object.
  15768. * @returns the serialized object.
  15769. */
  15770. serialize(): any;
  15771. /**
  15772. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15773. * This new light is named "name" and added to the passed scene.
  15774. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15775. * @param name The friendly name of the light
  15776. * @param scene The scene the new light will belong to
  15777. * @returns the constructor function
  15778. */
  15779. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15780. /**
  15781. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15782. * @param parsedLight The JSON representation of the light
  15783. * @param scene The scene to create the parsed light in
  15784. * @returns the created light after parsing
  15785. */
  15786. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15787. private _hookArrayForExcluded;
  15788. private _hookArrayForIncludedOnly;
  15789. private _resyncMeshes;
  15790. /**
  15791. * Forces the meshes to update their light related information in their rendering used effects
  15792. * @hidden Internal Use Only
  15793. */
  15794. _markMeshesAsLightDirty(): void;
  15795. /**
  15796. * Recomputes the cached photometric scale if needed.
  15797. */
  15798. private _computePhotometricScale;
  15799. /**
  15800. * Returns the Photometric Scale according to the light type and intensity mode.
  15801. */
  15802. private _getPhotometricScale;
  15803. /**
  15804. * Reorder the light in the scene according to their defined priority.
  15805. * @hidden Internal Use Only
  15806. */
  15807. _reorderLightsInScene(): void;
  15808. /**
  15809. * Prepares the list of defines specific to the light type.
  15810. * @param defines the list of defines
  15811. * @param lightIndex defines the index of the light for the effect
  15812. */
  15813. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15814. }
  15815. }
  15816. declare module BABYLON {
  15817. /**
  15818. * A point light is a light defined by an unique point in world space.
  15819. * The light is emitted in every direction from this point.
  15820. * A good example of a point light is a standard light bulb.
  15821. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15822. */
  15823. class PointLight extends ShadowLight {
  15824. private _shadowAngle;
  15825. /**
  15826. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15827. * This specifies what angle the shadow will use to be created.
  15828. *
  15829. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15830. */
  15831. /**
  15832. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15833. * This specifies what angle the shadow will use to be created.
  15834. *
  15835. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15836. */
  15837. shadowAngle: number;
  15838. /**
  15839. * Gets the direction if it has been set.
  15840. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15841. */
  15842. /**
  15843. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15844. */
  15845. direction: Vector3;
  15846. /**
  15847. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15848. * A PointLight emits the light in every direction.
  15849. * It can cast shadows.
  15850. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15851. * ```javascript
  15852. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15853. * ```
  15854. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15855. * @param name The light friendly name
  15856. * @param position The position of the point light in the scene
  15857. * @param scene The scene the lights belongs to
  15858. */
  15859. constructor(name: string, position: Vector3, scene: Scene);
  15860. /**
  15861. * Returns the string "PointLight"
  15862. * @returns the class name
  15863. */
  15864. getClassName(): string;
  15865. /**
  15866. * Returns the integer 0.
  15867. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15868. */
  15869. getTypeID(): number;
  15870. /**
  15871. * Specifies wether or not the shadowmap should be a cube texture.
  15872. * @returns true if the shadowmap needs to be a cube texture.
  15873. */
  15874. needCube(): boolean;
  15875. /**
  15876. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15877. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15878. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15879. */
  15880. getShadowDirection(faceIndex?: number): Vector3;
  15881. /**
  15882. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15883. * - fov = PI / 2
  15884. * - aspect ratio : 1.0
  15885. * - z-near and far equal to the active camera minZ and maxZ.
  15886. * Returns the PointLight.
  15887. */
  15888. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15889. protected _buildUniformLayout(): void;
  15890. /**
  15891. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15892. * @param effect The effect to update
  15893. * @param lightIndex The index of the light in the effect to update
  15894. * @returns The point light
  15895. */
  15896. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15897. /**
  15898. * Prepares the list of defines specific to the light type.
  15899. * @param defines the list of defines
  15900. * @param lightIndex defines the index of the light for the effect
  15901. */
  15902. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15903. }
  15904. }
  15905. declare module BABYLON {
  15906. /**
  15907. * Interface describing all the common properties and methods a shadow light needs to implement.
  15908. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15909. * as well as binding the different shadow properties to the effects.
  15910. */
  15911. interface IShadowLight extends Light {
  15912. /**
  15913. * The light id in the scene (used in scene.findLighById for instance)
  15914. */
  15915. id: string;
  15916. /**
  15917. * The position the shdow will be casted from.
  15918. */
  15919. position: Vector3;
  15920. /**
  15921. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15922. */
  15923. direction: Vector3;
  15924. /**
  15925. * The transformed position. Position of the light in world space taking parenting in account.
  15926. */
  15927. transformedPosition: Vector3;
  15928. /**
  15929. * The transformed direction. Direction of the light in world space taking parenting in account.
  15930. */
  15931. transformedDirection: Vector3;
  15932. /**
  15933. * The friendly name of the light in the scene.
  15934. */
  15935. name: string;
  15936. /**
  15937. * Defines the shadow projection clipping minimum z value.
  15938. */
  15939. shadowMinZ: number;
  15940. /**
  15941. * Defines the shadow projection clipping maximum z value.
  15942. */
  15943. shadowMaxZ: number;
  15944. /**
  15945. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15946. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15947. */
  15948. computeTransformedInformation(): boolean;
  15949. /**
  15950. * Gets the scene the light belongs to.
  15951. * @returns The scene
  15952. */
  15953. getScene(): Scene;
  15954. /**
  15955. * Callback defining a custom Projection Matrix Builder.
  15956. * This can be used to override the default projection matrix computation.
  15957. */
  15958. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15959. /**
  15960. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15961. * @param matrix The materix to updated with the projection information
  15962. * @param viewMatrix The transform matrix of the light
  15963. * @param renderList The list of mesh to render in the map
  15964. * @returns The current light
  15965. */
  15966. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15967. /**
  15968. * Gets the current depth scale used in ESM.
  15969. * @returns The scale
  15970. */
  15971. getDepthScale(): number;
  15972. /**
  15973. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15974. * @returns true if a cube texture needs to be use
  15975. */
  15976. needCube(): boolean;
  15977. /**
  15978. * Detects if the projection matrix requires to be recomputed this frame.
  15979. * @returns true if it requires to be recomputed otherwise, false.
  15980. */
  15981. needProjectionMatrixCompute(): boolean;
  15982. /**
  15983. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15984. */
  15985. forceProjectionMatrixCompute(): void;
  15986. /**
  15987. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15988. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15989. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15990. */
  15991. getShadowDirection(faceIndex?: number): Vector3;
  15992. /**
  15993. * Gets the minZ used for shadow according to both the scene and the light.
  15994. * @param activeCamera The camera we are returning the min for
  15995. * @returns the depth min z
  15996. */
  15997. getDepthMinZ(activeCamera: Camera): number;
  15998. /**
  15999. * Gets the maxZ used for shadow according to both the scene and the light.
  16000. * @param activeCamera The camera we are returning the max for
  16001. * @returns the depth max z
  16002. */
  16003. getDepthMaxZ(activeCamera: Camera): number;
  16004. }
  16005. /**
  16006. * Base implementation IShadowLight
  16007. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16008. */
  16009. abstract class ShadowLight extends Light implements IShadowLight {
  16010. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16011. protected _position: Vector3;
  16012. protected _setPosition(value: Vector3): void;
  16013. /**
  16014. * Sets the position the shadow will be casted from. Also use as the light position for both
  16015. * point and spot lights.
  16016. */
  16017. /**
  16018. * Sets the position the shadow will be casted from. Also use as the light position for both
  16019. * point and spot lights.
  16020. */
  16021. position: Vector3;
  16022. protected _direction: Vector3;
  16023. protected _setDirection(value: Vector3): void;
  16024. /**
  16025. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16026. * Also use as the light direction on spot and directional lights.
  16027. */
  16028. /**
  16029. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16030. * Also use as the light direction on spot and directional lights.
  16031. */
  16032. direction: Vector3;
  16033. private _shadowMinZ;
  16034. /**
  16035. * Gets the shadow projection clipping minimum z value.
  16036. */
  16037. /**
  16038. * Sets the shadow projection clipping minimum z value.
  16039. */
  16040. shadowMinZ: number;
  16041. private _shadowMaxZ;
  16042. /**
  16043. * Sets the shadow projection clipping maximum z value.
  16044. */
  16045. /**
  16046. * Gets the shadow projection clipping maximum z value.
  16047. */
  16048. shadowMaxZ: number;
  16049. /**
  16050. * Callback defining a custom Projection Matrix Builder.
  16051. * This can be used to override the default projection matrix computation.
  16052. */
  16053. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16054. /**
  16055. * The transformed position. Position of the light in world space taking parenting in account.
  16056. */
  16057. transformedPosition: Vector3;
  16058. /**
  16059. * The transformed direction. Direction of the light in world space taking parenting in account.
  16060. */
  16061. transformedDirection: Vector3;
  16062. private _needProjectionMatrixCompute;
  16063. /**
  16064. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16065. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16066. */
  16067. computeTransformedInformation(): boolean;
  16068. /**
  16069. * Return the depth scale used for the shadow map.
  16070. * @returns the depth scale.
  16071. */
  16072. getDepthScale(): number;
  16073. /**
  16074. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16075. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16076. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16077. */
  16078. getShadowDirection(faceIndex?: number): Vector3;
  16079. /**
  16080. * Returns the ShadowLight absolute position in the World.
  16081. * @returns the position vector in world space
  16082. */
  16083. getAbsolutePosition(): Vector3;
  16084. /**
  16085. * Sets the ShadowLight direction toward the passed target.
  16086. * @param target The point tot target in local space
  16087. * @returns the updated ShadowLight direction
  16088. */
  16089. setDirectionToTarget(target: Vector3): Vector3;
  16090. /**
  16091. * Returns the light rotation in euler definition.
  16092. * @returns the x y z rotation in local space.
  16093. */
  16094. getRotation(): Vector3;
  16095. /**
  16096. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16097. * @returns true if a cube texture needs to be use
  16098. */
  16099. needCube(): boolean;
  16100. /**
  16101. * Detects if the projection matrix requires to be recomputed this frame.
  16102. * @returns true if it requires to be recomputed otherwise, false.
  16103. */
  16104. needProjectionMatrixCompute(): boolean;
  16105. /**
  16106. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16107. */
  16108. forceProjectionMatrixCompute(): void;
  16109. /** @hidden */
  16110. _initCache(): void;
  16111. /** @hidden */
  16112. _isSynchronized(): boolean;
  16113. /**
  16114. * Computes the world matrix of the node
  16115. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16116. * @returns the world matrix
  16117. */
  16118. computeWorldMatrix(force?: boolean): Matrix;
  16119. /**
  16120. * Gets the minZ used for shadow according to both the scene and the light.
  16121. * @param activeCamera The camera we are returning the min for
  16122. * @returns the depth min z
  16123. */
  16124. getDepthMinZ(activeCamera: Camera): number;
  16125. /**
  16126. * Gets the maxZ used for shadow according to both the scene and the light.
  16127. * @param activeCamera The camera we are returning the max for
  16128. * @returns the depth max z
  16129. */
  16130. getDepthMaxZ(activeCamera: Camera): number;
  16131. /**
  16132. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16133. * @param matrix The materix to updated with the projection information
  16134. * @param viewMatrix The transform matrix of the light
  16135. * @param renderList The list of mesh to render in the map
  16136. * @returns The current light
  16137. */
  16138. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16139. }
  16140. }
  16141. declare module BABYLON {
  16142. /**
  16143. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16144. * These values define a cone of light starting from the position, emitting toward the direction.
  16145. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16146. * and the exponent defines the speed of the decay of the light with distance (reach).
  16147. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16148. */
  16149. class SpotLight extends ShadowLight {
  16150. private _angle;
  16151. private _innerAngle;
  16152. private _cosHalfAngle;
  16153. private _lightAngleScale;
  16154. private _lightAngleOffset;
  16155. /**
  16156. * Gets the cone angle of the spot light in Radians.
  16157. */
  16158. /**
  16159. * Sets the cone angle of the spot light in Radians.
  16160. */
  16161. angle: number;
  16162. /**
  16163. * Only used in gltf falloff mode, this defines the angle where
  16164. * the directional falloff will start before cutting at angle which could be seen
  16165. * as outer angle.
  16166. */
  16167. /**
  16168. * Only used in gltf falloff mode, this defines the angle where
  16169. * the directional falloff will start before cutting at angle which could be seen
  16170. * as outer angle.
  16171. */
  16172. innerAngle: number;
  16173. private _shadowAngleScale;
  16174. /**
  16175. * Allows scaling the angle of the light for shadow generation only.
  16176. */
  16177. /**
  16178. * Allows scaling the angle of the light for shadow generation only.
  16179. */
  16180. shadowAngleScale: number;
  16181. /**
  16182. * The light decay speed with the distance from the emission spot.
  16183. */
  16184. exponent: number;
  16185. private _projectionTextureMatrix;
  16186. /**
  16187. * Allows reading the projecton texture
  16188. */
  16189. readonly projectionTextureMatrix: Matrix;
  16190. protected _projectionTextureLightNear: number;
  16191. /**
  16192. * Gets the near clip of the Spotlight for texture projection.
  16193. */
  16194. /**
  16195. * Sets the near clip of the Spotlight for texture projection.
  16196. */
  16197. projectionTextureLightNear: number;
  16198. protected _projectionTextureLightFar: number;
  16199. /**
  16200. * Gets the far clip of the Spotlight for texture projection.
  16201. */
  16202. /**
  16203. * Sets the far clip of the Spotlight for texture projection.
  16204. */
  16205. projectionTextureLightFar: number;
  16206. protected _projectionTextureUpDirection: Vector3;
  16207. /**
  16208. * Gets the Up vector of the Spotlight for texture projection.
  16209. */
  16210. /**
  16211. * Sets the Up vector of the Spotlight for texture projection.
  16212. */
  16213. projectionTextureUpDirection: Vector3;
  16214. private _projectionTexture;
  16215. /**
  16216. * Gets the projection texture of the light.
  16217. */
  16218. /**
  16219. * Sets the projection texture of the light.
  16220. */
  16221. projectionTexture: Nullable<BaseTexture>;
  16222. private _projectionTextureViewLightDirty;
  16223. private _projectionTextureProjectionLightDirty;
  16224. private _projectionTextureDirty;
  16225. private _projectionTextureViewTargetVector;
  16226. private _projectionTextureViewLightMatrix;
  16227. private _projectionTextureProjectionLightMatrix;
  16228. private _projectionTextureScalingMatrix;
  16229. /**
  16230. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16231. * It can cast shadows.
  16232. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16233. * @param name The light friendly name
  16234. * @param position The position of the spot light in the scene
  16235. * @param direction The direction of the light in the scene
  16236. * @param angle The cone angle of the light in Radians
  16237. * @param exponent The light decay speed with the distance from the emission spot
  16238. * @param scene The scene the lights belongs to
  16239. */
  16240. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16241. /**
  16242. * Returns the string "SpotLight".
  16243. * @returns the class name
  16244. */
  16245. getClassName(): string;
  16246. /**
  16247. * Returns the integer 2.
  16248. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16249. */
  16250. getTypeID(): number;
  16251. /**
  16252. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16253. */
  16254. protected _setDirection(value: Vector3): void;
  16255. /**
  16256. * Overrides the position setter to recompute the projection texture view light Matrix.
  16257. */
  16258. protected _setPosition(value: Vector3): void;
  16259. /**
  16260. * 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.
  16261. * Returns the SpotLight.
  16262. */
  16263. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16264. protected _computeProjectionTextureViewLightMatrix(): void;
  16265. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16266. /**
  16267. * Main function for light texture projection matrix computing.
  16268. */
  16269. protected _computeProjectionTextureMatrix(): void;
  16270. protected _buildUniformLayout(): void;
  16271. private _computeAngleValues;
  16272. /**
  16273. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16274. * @param effect The effect to update
  16275. * @param lightIndex The index of the light in the effect to update
  16276. * @returns The spot light
  16277. */
  16278. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16279. /**
  16280. * Disposes the light and the associated resources.
  16281. */
  16282. dispose(): void;
  16283. /**
  16284. * Prepares the list of defines specific to the light type.
  16285. * @param defines the list of defines
  16286. * @param lightIndex defines the index of the light for the effect
  16287. */
  16288. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16289. }
  16290. }
  16291. declare module BABYLON {
  16292. /**
  16293. * Interface used to present a loading screen while loading a scene
  16294. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16295. */
  16296. interface ILoadingScreen {
  16297. /**
  16298. * Function called to display the loading screen
  16299. */
  16300. displayLoadingUI: () => void;
  16301. /**
  16302. * Function called to hide the loading screen
  16303. */
  16304. hideLoadingUI: () => void;
  16305. /**
  16306. * Gets or sets the color to use for the background
  16307. */
  16308. loadingUIBackgroundColor: string;
  16309. /**
  16310. * Gets or sets the text to display while loading
  16311. */
  16312. loadingUIText: string;
  16313. }
  16314. /**
  16315. * Class used for the default loading screen
  16316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16317. */
  16318. class DefaultLoadingScreen implements ILoadingScreen {
  16319. private _renderingCanvas;
  16320. private _loadingText;
  16321. private _loadingDivBackgroundColor;
  16322. private _loadingDiv;
  16323. private _loadingTextDiv;
  16324. /**
  16325. * Creates a new default loading screen
  16326. * @param _renderingCanvas defines the canvas used to render the scene
  16327. * @param _loadingText defines the default text to display
  16328. * @param _loadingDivBackgroundColor defines the default background color
  16329. */
  16330. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16331. /**
  16332. * Function called to display the loading screen
  16333. */
  16334. displayLoadingUI(): void;
  16335. /**
  16336. * Function called to hide the loading screen
  16337. */
  16338. hideLoadingUI(): void;
  16339. /**
  16340. * Gets or sets the text to display while loading
  16341. */
  16342. loadingUIText: string;
  16343. /**
  16344. * Gets or sets the color to use for the background
  16345. */
  16346. loadingUIBackgroundColor: string;
  16347. private _resizeLoadingUI;
  16348. }
  16349. }
  16350. declare module BABYLON {
  16351. /**
  16352. * Class used to represent data loading progression
  16353. */
  16354. class SceneLoaderProgressEvent {
  16355. /** defines if data length to load can be evaluated */
  16356. readonly lengthComputable: boolean;
  16357. /** defines the loaded data length */
  16358. readonly loaded: number;
  16359. /** defines the data length to load */
  16360. readonly total: number;
  16361. /**
  16362. * Create a new progress event
  16363. * @param lengthComputable defines if data length to load can be evaluated
  16364. * @param loaded defines the loaded data length
  16365. * @param total defines the data length to load
  16366. */
  16367. constructor(
  16368. /** defines if data length to load can be evaluated */
  16369. lengthComputable: boolean,
  16370. /** defines the loaded data length */
  16371. loaded: number,
  16372. /** defines the data length to load */
  16373. total: number);
  16374. /**
  16375. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16376. * @param event defines the source event
  16377. * @returns a new SceneLoaderProgressEvent
  16378. */
  16379. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16380. }
  16381. /**
  16382. * Interface used by SceneLoader plugins to define supported file extensions
  16383. */
  16384. interface ISceneLoaderPluginExtensions {
  16385. /**
  16386. * Defines the list of supported extensions
  16387. */
  16388. [extension: string]: {
  16389. isBinary: boolean;
  16390. };
  16391. }
  16392. /**
  16393. * Interface used by SceneLoader plugin factory
  16394. */
  16395. interface ISceneLoaderPluginFactory {
  16396. /**
  16397. * Defines the name of the factory
  16398. */
  16399. name: string;
  16400. /**
  16401. * Function called to create a new plugin
  16402. * @return the new plugin
  16403. */
  16404. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16405. /**
  16406. * Boolean indicating if the plugin can direct load specific data
  16407. */
  16408. canDirectLoad?: (data: string) => boolean;
  16409. }
  16410. /**
  16411. * Interface used to define a SceneLoader plugin
  16412. */
  16413. interface ISceneLoaderPlugin {
  16414. /**
  16415. * The friendly name of this plugin.
  16416. */
  16417. name: string;
  16418. /**
  16419. * The file extensions supported by this plugin.
  16420. */
  16421. extensions: string | ISceneLoaderPluginExtensions;
  16422. /**
  16423. * Import meshes into a scene.
  16424. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16425. * @param scene The scene to import into
  16426. * @param data The data to import
  16427. * @param rootUrl The root url for scene and resources
  16428. * @param meshes The meshes array to import into
  16429. * @param particleSystems The particle systems array to import into
  16430. * @param skeletons The skeletons array to import into
  16431. * @param onError The callback when import fails
  16432. * @returns True if successful or false otherwise
  16433. */
  16434. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16435. /**
  16436. * Load into a scene.
  16437. * @param scene The scene to load into
  16438. * @param data The data to import
  16439. * @param rootUrl The root url for scene and resources
  16440. * @param onError The callback when import fails
  16441. * @returns true if successful or false otherwise
  16442. */
  16443. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16444. /**
  16445. * The callback that returns true if the data can be directly loaded.
  16446. */
  16447. canDirectLoad?: (data: string) => boolean;
  16448. /**
  16449. * The callback that allows custom handling of the root url based on the response url.
  16450. */
  16451. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16452. /**
  16453. * Load into an asset container.
  16454. * @param scene The scene to load into
  16455. * @param data The data to import
  16456. * @param rootUrl The root url for scene and resources
  16457. * @param onError The callback when import fails
  16458. * @returns The loaded asset container
  16459. */
  16460. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16461. }
  16462. /**
  16463. * Interface used to define an async SceneLoader plugin
  16464. */
  16465. interface ISceneLoaderPluginAsync {
  16466. /**
  16467. * The friendly name of this plugin.
  16468. */
  16469. name: string;
  16470. /**
  16471. * The file extensions supported by this plugin.
  16472. */
  16473. extensions: string | ISceneLoaderPluginExtensions;
  16474. /**
  16475. * Import meshes into a scene.
  16476. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16477. * @param scene The scene to import into
  16478. * @param data The data to import
  16479. * @param rootUrl The root url for scene and resources
  16480. * @param onProgress The callback when the load progresses
  16481. * @param fileName Defines the name of the file to load
  16482. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16483. */
  16484. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16485. meshes: AbstractMesh[];
  16486. particleSystems: IParticleSystem[];
  16487. skeletons: Skeleton[];
  16488. animationGroups: AnimationGroup[];
  16489. }>;
  16490. /**
  16491. * Load into a scene.
  16492. * @param scene The scene to load into
  16493. * @param data The data to import
  16494. * @param rootUrl The root url for scene and resources
  16495. * @param onProgress The callback when the load progresses
  16496. * @param fileName Defines the name of the file to load
  16497. * @returns Nothing
  16498. */
  16499. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16500. /**
  16501. * The callback that returns true if the data can be directly loaded.
  16502. */
  16503. canDirectLoad?: (data: string) => boolean;
  16504. /**
  16505. * The callback that allows custom handling of the root url based on the response url.
  16506. */
  16507. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16508. /**
  16509. * Load into an asset container.
  16510. * @param scene The scene to load into
  16511. * @param data The data to import
  16512. * @param rootUrl The root url for scene and resources
  16513. * @param onProgress The callback when the load progresses
  16514. * @param fileName Defines the name of the file to load
  16515. * @returns The loaded asset container
  16516. */
  16517. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16518. }
  16519. /**
  16520. * Class used to load scene from various file formats using registered plugins
  16521. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16522. */
  16523. class SceneLoader {
  16524. private static _ForceFullSceneLoadingForIncremental;
  16525. private static _ShowLoadingScreen;
  16526. private static _CleanBoneMatrixWeights;
  16527. /**
  16528. * No logging while loading
  16529. */
  16530. static readonly NO_LOGGING: number;
  16531. /**
  16532. * Minimal logging while loading
  16533. */
  16534. static readonly MINIMAL_LOGGING: number;
  16535. /**
  16536. * Summary logging while loading
  16537. */
  16538. static readonly SUMMARY_LOGGING: number;
  16539. /**
  16540. * Detailled logging while loading
  16541. */
  16542. static readonly DETAILED_LOGGING: number;
  16543. private static _loggingLevel;
  16544. /**
  16545. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16546. */
  16547. static ForceFullSceneLoadingForIncremental: boolean;
  16548. /**
  16549. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16550. */
  16551. static ShowLoadingScreen: boolean;
  16552. /**
  16553. * Defines the current logging level (while loading the scene)
  16554. * @ignorenaming
  16555. */
  16556. static loggingLevel: number;
  16557. /**
  16558. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16559. */
  16560. static CleanBoneMatrixWeights: boolean;
  16561. /**
  16562. * Event raised when a plugin is used to load a scene
  16563. */
  16564. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16565. private static _registeredPlugins;
  16566. private static _getDefaultPlugin;
  16567. private static _getPluginForExtension;
  16568. private static _getPluginForDirectLoad;
  16569. private static _getPluginForFilename;
  16570. private static _getDirectLoad;
  16571. private static _loadData;
  16572. private static _getFileInfo;
  16573. /**
  16574. * Gets a plugin that can load the given extension
  16575. * @param extension defines the extension to load
  16576. * @returns a plugin or null if none works
  16577. */
  16578. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16579. /**
  16580. * Gets a boolean indicating that the given extension can be loaded
  16581. * @param extension defines the extension to load
  16582. * @returns true if the extension is supported
  16583. */
  16584. static IsPluginForExtensionAvailable(extension: string): boolean;
  16585. /**
  16586. * Adds a new plugin to the list of registered plugins
  16587. * @param plugin defines the plugin to add
  16588. */
  16589. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16590. /**
  16591. * Import meshes into a scene
  16592. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16593. * @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)
  16594. * @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)
  16595. * @param scene the instance of BABYLON.Scene to append to
  16596. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16597. * @param onProgress a callback with a progress event for each file being loaded
  16598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16599. * @param pluginExtension the extension used to determine the plugin
  16600. * @returns The loaded plugin
  16601. */
  16602. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, 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>;
  16603. /**
  16604. * Import meshes into a scene
  16605. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16606. * @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)
  16607. * @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)
  16608. * @param scene the instance of BABYLON.Scene to append to
  16609. * @param onProgress a callback with a progress event for each file being loaded
  16610. * @param pluginExtension the extension used to determine the plugin
  16611. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16612. */
  16613. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16614. meshes: AbstractMesh[];
  16615. particleSystems: IParticleSystem[];
  16616. skeletons: Skeleton[];
  16617. animationGroups: AnimationGroup[];
  16618. }>;
  16619. /**
  16620. * Load a scene
  16621. * @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)
  16622. * @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)
  16623. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16624. * @param onSuccess a callback with the scene when import succeeds
  16625. * @param onProgress a callback with a progress event for each file being loaded
  16626. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16627. * @param pluginExtension the extension used to determine the plugin
  16628. * @returns The loaded plugin
  16629. */
  16630. static Load(rootUrl: string, sceneFilename: string, engine: 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>;
  16631. /**
  16632. * Load a scene
  16633. * @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)
  16634. * @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)
  16635. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16636. * @param onProgress a callback with a progress event for each file being loaded
  16637. * @param pluginExtension the extension used to determine the plugin
  16638. * @returns The loaded scene
  16639. */
  16640. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16641. /**
  16642. * Append a scene
  16643. * @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)
  16644. * @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)
  16645. * @param scene is the instance of BABYLON.Scene to append to
  16646. * @param onSuccess a callback with the scene when import succeeds
  16647. * @param onProgress a callback with a progress event for each file being loaded
  16648. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16649. * @param pluginExtension the extension used to determine the plugin
  16650. * @returns The loaded plugin
  16651. */
  16652. static Append(rootUrl: string, sceneFilename?: string, 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>;
  16653. /**
  16654. * Append a scene
  16655. * @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)
  16656. * @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)
  16657. * @param scene is the instance of BABYLON.Scene to append to
  16658. * @param onProgress a callback with a progress event for each file being loaded
  16659. * @param pluginExtension the extension used to determine the plugin
  16660. * @returns The given scene
  16661. */
  16662. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16663. /**
  16664. * Load a scene into an asset container
  16665. * @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)
  16666. * @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)
  16667. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16668. * @param onSuccess a callback with the scene when import succeeds
  16669. * @param onProgress a callback with a progress event for each file being loaded
  16670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16671. * @param pluginExtension the extension used to determine the plugin
  16672. * @returns The loaded plugin
  16673. */
  16674. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, 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>;
  16675. /**
  16676. * Load a scene into an asset container
  16677. * @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)
  16678. * @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)
  16679. * @param scene is the instance of BABYLON.Scene to append to
  16680. * @param onProgress a callback with a progress event for each file being loaded
  16681. * @param pluginExtension the extension used to determine the plugin
  16682. * @returns The loaded asset container
  16683. */
  16684. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16685. }
  16686. }
  16687. declare module BABYLON {
  16688. /**
  16689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16691. * 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;
  16692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16693. */
  16694. class ColorCurves {
  16695. private _dirty;
  16696. private _tempColor;
  16697. private _globalCurve;
  16698. private _highlightsCurve;
  16699. private _midtonesCurve;
  16700. private _shadowsCurve;
  16701. private _positiveCurve;
  16702. private _negativeCurve;
  16703. private _globalHue;
  16704. private _globalDensity;
  16705. private _globalSaturation;
  16706. private _globalExposure;
  16707. /**
  16708. * Gets the global Hue value.
  16709. * 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).
  16710. */
  16711. /**
  16712. * Sets the global Hue value.
  16713. * 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).
  16714. */
  16715. globalHue: number;
  16716. /**
  16717. * Gets the global Density value.
  16718. * 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.
  16719. * Values less than zero provide a filter of opposite hue.
  16720. */
  16721. /**
  16722. * Sets the global Density value.
  16723. * 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.
  16724. * Values less than zero provide a filter of opposite hue.
  16725. */
  16726. globalDensity: number;
  16727. /**
  16728. * Gets the global Saturation value.
  16729. * 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.
  16730. */
  16731. /**
  16732. * Sets the global Saturation value.
  16733. * 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.
  16734. */
  16735. globalSaturation: number;
  16736. /**
  16737. * Gets the global Exposure value.
  16738. * 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.
  16739. */
  16740. /**
  16741. * Sets the global Exposure value.
  16742. * 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.
  16743. */
  16744. globalExposure: number;
  16745. private _highlightsHue;
  16746. private _highlightsDensity;
  16747. private _highlightsSaturation;
  16748. private _highlightsExposure;
  16749. /**
  16750. * Gets the highlights Hue value.
  16751. * 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).
  16752. */
  16753. /**
  16754. * Sets the highlights Hue value.
  16755. * 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).
  16756. */
  16757. highlightsHue: number;
  16758. /**
  16759. * Gets the highlights Density value.
  16760. * 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.
  16761. * Values less than zero provide a filter of opposite hue.
  16762. */
  16763. /**
  16764. * Sets the highlights Density value.
  16765. * 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.
  16766. * Values less than zero provide a filter of opposite hue.
  16767. */
  16768. highlightsDensity: number;
  16769. /**
  16770. * Gets the highlights Saturation value.
  16771. * 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.
  16772. */
  16773. /**
  16774. * Sets the highlights Saturation value.
  16775. * 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.
  16776. */
  16777. highlightsSaturation: number;
  16778. /**
  16779. * Gets the highlights Exposure value.
  16780. * 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.
  16781. */
  16782. /**
  16783. * Sets the highlights Exposure value.
  16784. * 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.
  16785. */
  16786. highlightsExposure: number;
  16787. private _midtonesHue;
  16788. private _midtonesDensity;
  16789. private _midtonesSaturation;
  16790. private _midtonesExposure;
  16791. /**
  16792. * Gets the midtones Hue value.
  16793. * 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).
  16794. */
  16795. /**
  16796. * Sets the midtones Hue value.
  16797. * 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).
  16798. */
  16799. midtonesHue: number;
  16800. /**
  16801. * Gets the midtones Density value.
  16802. * 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.
  16803. * Values less than zero provide a filter of opposite hue.
  16804. */
  16805. /**
  16806. * Sets the midtones Density value.
  16807. * 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.
  16808. * Values less than zero provide a filter of opposite hue.
  16809. */
  16810. midtonesDensity: number;
  16811. /**
  16812. * Gets the midtones Saturation value.
  16813. * 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.
  16814. */
  16815. /**
  16816. * Sets the midtones Saturation value.
  16817. * 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.
  16818. */
  16819. midtonesSaturation: number;
  16820. /**
  16821. * Gets the midtones Exposure value.
  16822. * 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.
  16823. */
  16824. /**
  16825. * Sets the midtones Exposure value.
  16826. * 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.
  16827. */
  16828. midtonesExposure: number;
  16829. private _shadowsHue;
  16830. private _shadowsDensity;
  16831. private _shadowsSaturation;
  16832. private _shadowsExposure;
  16833. /**
  16834. * Gets the shadows Hue value.
  16835. * 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).
  16836. */
  16837. /**
  16838. * Sets the shadows Hue value.
  16839. * 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).
  16840. */
  16841. shadowsHue: number;
  16842. /**
  16843. * Gets the shadows Density value.
  16844. * 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.
  16845. * Values less than zero provide a filter of opposite hue.
  16846. */
  16847. /**
  16848. * Sets the shadows Density value.
  16849. * 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.
  16850. * Values less than zero provide a filter of opposite hue.
  16851. */
  16852. shadowsDensity: number;
  16853. /**
  16854. * Gets the shadows Saturation value.
  16855. * 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.
  16856. */
  16857. /**
  16858. * Sets the shadows Saturation value.
  16859. * 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.
  16860. */
  16861. shadowsSaturation: number;
  16862. /**
  16863. * Gets the shadows Exposure value.
  16864. * 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.
  16865. */
  16866. /**
  16867. * Sets the shadows Exposure value.
  16868. * 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.
  16869. */
  16870. shadowsExposure: number;
  16871. /**
  16872. * Returns the class name
  16873. * @returns The class name
  16874. */
  16875. getClassName(): string;
  16876. /**
  16877. * Binds the color curves to the shader.
  16878. * @param colorCurves The color curve to bind
  16879. * @param effect The effect to bind to
  16880. * @param positiveUniform The positive uniform shader parameter
  16881. * @param neutralUniform The neutral uniform shader parameter
  16882. * @param negativeUniform The negative uniform shader parameter
  16883. */
  16884. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16885. /**
  16886. * Prepare the list of uniforms associated with the ColorCurves effects.
  16887. * @param uniformsList The list of uniforms used in the effect
  16888. */
  16889. static PrepareUniforms(uniformsList: string[]): void;
  16890. /**
  16891. * Returns color grading data based on a hue, density, saturation and exposure value.
  16892. * @param filterHue The hue of the color filter.
  16893. * @param filterDensity The density of the color filter.
  16894. * @param saturation The saturation.
  16895. * @param exposure The exposure.
  16896. * @param result The result data container.
  16897. */
  16898. private getColorGradingDataToRef;
  16899. /**
  16900. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16901. * @param value The input slider value in range [-100,100].
  16902. * @returns Adjusted value.
  16903. */
  16904. private static applyColorGradingSliderNonlinear;
  16905. /**
  16906. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16907. * @param hue The hue (H) input.
  16908. * @param saturation The saturation (S) input.
  16909. * @param brightness The brightness (B) input.
  16910. * @result An RGBA color represented as Vector4.
  16911. */
  16912. private static fromHSBToRef;
  16913. /**
  16914. * Returns a value clamped between min and max
  16915. * @param value The value to clamp
  16916. * @param min The minimum of value
  16917. * @param max The maximum of value
  16918. * @returns The clamped value.
  16919. */
  16920. private static clamp;
  16921. /**
  16922. * Clones the current color curve instance.
  16923. * @return The cloned curves
  16924. */
  16925. clone(): ColorCurves;
  16926. /**
  16927. * Serializes the current color curve instance to a json representation.
  16928. * @return a JSON representation
  16929. */
  16930. serialize(): any;
  16931. /**
  16932. * Parses the color curve from a json representation.
  16933. * @param source the JSON source to parse
  16934. * @return The parsed curves
  16935. */
  16936. static Parse(source: any): ColorCurves;
  16937. }
  16938. }
  16939. declare module BABYLON {
  16940. /**
  16941. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16942. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16943. */
  16944. class EffectFallbacks {
  16945. private _defines;
  16946. private _currentRank;
  16947. private _maxRank;
  16948. private _mesh;
  16949. /**
  16950. * Removes the fallback from the bound mesh.
  16951. */
  16952. unBindMesh(): void;
  16953. /**
  16954. * Adds a fallback on the specified property.
  16955. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16956. * @param define The name of the define in the shader
  16957. */
  16958. addFallback(rank: number, define: string): void;
  16959. /**
  16960. * Sets the mesh to use CPU skinning when needing to fallback.
  16961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16962. * @param mesh The mesh to use the fallbacks.
  16963. */
  16964. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16965. /**
  16966. * Checks to see if more fallbacks are still availible.
  16967. */
  16968. readonly isMoreFallbacks: boolean;
  16969. /**
  16970. * Removes the defines that shoould be removed when falling back.
  16971. * @param currentDefines defines the current define statements for the shader.
  16972. * @param effect defines the current effect we try to compile
  16973. * @returns The resulting defines with defines of the current rank removed.
  16974. */
  16975. reduce(currentDefines: string, effect: Effect): string;
  16976. }
  16977. /**
  16978. * Options to be used when creating an effect.
  16979. */
  16980. class EffectCreationOptions {
  16981. /**
  16982. * Atrributes that will be used in the shader.
  16983. */
  16984. attributes: string[];
  16985. /**
  16986. * Uniform varible names that will be set in the shader.
  16987. */
  16988. uniformsNames: string[];
  16989. /**
  16990. * Uniform buffer varible names that will be set in the shader.
  16991. */
  16992. uniformBuffersNames: string[];
  16993. /**
  16994. * Sampler texture variable names that will be set in the shader.
  16995. */
  16996. samplers: string[];
  16997. /**
  16998. * Define statements that will be set in the shader.
  16999. */
  17000. defines: any;
  17001. /**
  17002. * Possible fallbacks for this effect to improve performance when needed.
  17003. */
  17004. fallbacks: Nullable<EffectFallbacks>;
  17005. /**
  17006. * Callback that will be called when the shader is compiled.
  17007. */
  17008. onCompiled: Nullable<(effect: Effect) => void>;
  17009. /**
  17010. * Callback that will be called if an error occurs during shader compilation.
  17011. */
  17012. onError: Nullable<(effect: Effect, errors: string) => void>;
  17013. /**
  17014. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17015. */
  17016. indexParameters: any;
  17017. /**
  17018. * Max number of lights that can be used in the shader.
  17019. */
  17020. maxSimultaneousLights: number;
  17021. /**
  17022. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17023. */
  17024. transformFeedbackVaryings: Nullable<string[]>;
  17025. }
  17026. /**
  17027. * Effect containing vertex and fragment shader that can be executed on an object.
  17028. */
  17029. class Effect {
  17030. /**
  17031. * Name of the effect.
  17032. */
  17033. name: any;
  17034. /**
  17035. * String container all the define statements that should be set on the shader.
  17036. */
  17037. defines: string;
  17038. /**
  17039. * Callback that will be called when the shader is compiled.
  17040. */
  17041. onCompiled: Nullable<(effect: Effect) => void>;
  17042. /**
  17043. * Callback that will be called if an error occurs during shader compilation.
  17044. */
  17045. onError: Nullable<(effect: Effect, errors: string) => void>;
  17046. /**
  17047. * Callback that will be called when effect is bound.
  17048. */
  17049. onBind: Nullable<(effect: Effect) => void>;
  17050. /**
  17051. * Unique ID of the effect.
  17052. */
  17053. uniqueId: number;
  17054. /**
  17055. * Observable that will be called when the shader is compiled.
  17056. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17057. */
  17058. onCompileObservable: Observable<Effect>;
  17059. /**
  17060. * Observable that will be called if an error occurs during shader compilation.
  17061. */
  17062. onErrorObservable: Observable<Effect>;
  17063. /** @hidden */
  17064. _onBindObservable: Nullable<Observable<Effect>>;
  17065. /**
  17066. * Observable that will be called when effect is bound.
  17067. */
  17068. readonly onBindObservable: Observable<Effect>;
  17069. /** @hidden */
  17070. _bonesComputationForcedToCPU: boolean;
  17071. private static _uniqueIdSeed;
  17072. private _engine;
  17073. private _uniformBuffersNames;
  17074. private _uniformsNames;
  17075. private _samplers;
  17076. private _isReady;
  17077. private _compilationError;
  17078. private _attributesNames;
  17079. private _attributes;
  17080. private _uniforms;
  17081. /**
  17082. * Key for the effect.
  17083. * @hidden
  17084. */
  17085. _key: string;
  17086. private _indexParameters;
  17087. private _fallbacks;
  17088. private _vertexSourceCode;
  17089. private _fragmentSourceCode;
  17090. private _vertexSourceCodeOverride;
  17091. private _fragmentSourceCodeOverride;
  17092. private _transformFeedbackVaryings;
  17093. /**
  17094. * Compiled shader to webGL program.
  17095. * @hidden
  17096. */
  17097. _program: WebGLProgram;
  17098. private _valueCache;
  17099. private static _baseCache;
  17100. /**
  17101. * Instantiates an effect.
  17102. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17103. * @param baseName Name of the effect.
  17104. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17105. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17106. * @param samplers List of sampler variables that will be passed to the shader.
  17107. * @param engine Engine to be used to render the effect
  17108. * @param defines Define statements to be added to the shader.
  17109. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17110. * @param onCompiled Callback that will be called when the shader is compiled.
  17111. * @param onError Callback that will be called if an error occurs during shader compilation.
  17112. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17113. */
  17114. 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);
  17115. /**
  17116. * Unique key for this effect
  17117. */
  17118. readonly key: string;
  17119. /**
  17120. * If the effect has been compiled and prepared.
  17121. * @returns if the effect is compiled and prepared.
  17122. */
  17123. isReady(): boolean;
  17124. /**
  17125. * The engine the effect was initialized with.
  17126. * @returns the engine.
  17127. */
  17128. getEngine(): Engine;
  17129. /**
  17130. * The compiled webGL program for the effect
  17131. * @returns the webGL program.
  17132. */
  17133. getProgram(): WebGLProgram;
  17134. /**
  17135. * The set of names of attribute variables for the shader.
  17136. * @returns An array of attribute names.
  17137. */
  17138. getAttributesNames(): string[];
  17139. /**
  17140. * Returns the attribute at the given index.
  17141. * @param index The index of the attribute.
  17142. * @returns The location of the attribute.
  17143. */
  17144. getAttributeLocation(index: number): number;
  17145. /**
  17146. * Returns the attribute based on the name of the variable.
  17147. * @param name of the attribute to look up.
  17148. * @returns the attribute location.
  17149. */
  17150. getAttributeLocationByName(name: string): number;
  17151. /**
  17152. * The number of attributes.
  17153. * @returns the numnber of attributes.
  17154. */
  17155. getAttributesCount(): number;
  17156. /**
  17157. * Gets the index of a uniform variable.
  17158. * @param uniformName of the uniform to look up.
  17159. * @returns the index.
  17160. */
  17161. getUniformIndex(uniformName: string): number;
  17162. /**
  17163. * Returns the attribute based on the name of the variable.
  17164. * @param uniformName of the uniform to look up.
  17165. * @returns the location of the uniform.
  17166. */
  17167. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17168. /**
  17169. * Returns an array of sampler variable names
  17170. * @returns The array of sampler variable neames.
  17171. */
  17172. getSamplers(): string[];
  17173. /**
  17174. * The error from the last compilation.
  17175. * @returns the error string.
  17176. */
  17177. getCompilationError(): string;
  17178. /**
  17179. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17180. * @param func The callback to be used.
  17181. */
  17182. executeWhenCompiled(func: (effect: Effect) => void): void;
  17183. private _checkIsReady;
  17184. /** @hidden */
  17185. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17186. /** @hidden */
  17187. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17188. /** @hidden */
  17189. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17190. private _processShaderConversion;
  17191. private _processIncludes;
  17192. private _processPrecision;
  17193. /**
  17194. * Recompiles the webGL program
  17195. * @param vertexSourceCode The source code for the vertex shader.
  17196. * @param fragmentSourceCode The source code for the fragment shader.
  17197. * @param onCompiled Callback called when completed.
  17198. * @param onError Callback called on error.
  17199. * @hidden
  17200. */
  17201. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17202. /**
  17203. * Gets the uniform locations of the the specified variable names
  17204. * @param names THe names of the variables to lookup.
  17205. * @returns Array of locations in the same order as variable names.
  17206. */
  17207. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17208. /**
  17209. * Prepares the effect
  17210. * @hidden
  17211. */
  17212. _prepareEffect(): void;
  17213. /**
  17214. * Checks if the effect is supported. (Must be called after compilation)
  17215. */
  17216. readonly isSupported: boolean;
  17217. /**
  17218. * Binds a texture to the engine to be used as output of the shader.
  17219. * @param channel Name of the output variable.
  17220. * @param texture Texture to bind.
  17221. * @hidden
  17222. */
  17223. _bindTexture(channel: string, texture: InternalTexture): void;
  17224. /**
  17225. * Sets a texture on the engine to be used in the shader.
  17226. * @param channel Name of the sampler variable.
  17227. * @param texture Texture to set.
  17228. */
  17229. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17230. /**
  17231. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17232. * @param channel Name of the sampler variable.
  17233. * @param texture Texture to set.
  17234. */
  17235. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17236. /**
  17237. * Sets an array of textures on the engine to be used in the shader.
  17238. * @param channel Name of the variable.
  17239. * @param textures Textures to set.
  17240. */
  17241. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17242. /**
  17243. * 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)
  17244. * @param channel Name of the sampler variable.
  17245. * @param postProcess Post process to get the input texture from.
  17246. */
  17247. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17248. /**
  17249. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17250. * 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)
  17251. * @param channel Name of the sampler variable.
  17252. * @param postProcess Post process to get the output texture from.
  17253. */
  17254. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17255. /** @hidden */
  17256. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17257. /** @hidden */
  17258. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17259. /** @hidden */
  17260. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17261. /** @hidden */
  17262. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17263. /**
  17264. * Binds a buffer to a uniform.
  17265. * @param buffer Buffer to bind.
  17266. * @param name Name of the uniform variable to bind to.
  17267. */
  17268. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17269. /**
  17270. * Binds block to a uniform.
  17271. * @param blockName Name of the block to bind.
  17272. * @param index Index to bind.
  17273. */
  17274. bindUniformBlock(blockName: string, index: number): void;
  17275. /**
  17276. * Sets an interger value on a uniform variable.
  17277. * @param uniformName Name of the variable.
  17278. * @param value Value to be set.
  17279. * @returns this effect.
  17280. */
  17281. setInt(uniformName: string, value: number): Effect;
  17282. /**
  17283. * Sets an int array on a uniform variable.
  17284. * @param uniformName Name of the variable.
  17285. * @param array array to be set.
  17286. * @returns this effect.
  17287. */
  17288. setIntArray(uniformName: string, array: Int32Array): Effect;
  17289. /**
  17290. * 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)
  17291. * @param uniformName Name of the variable.
  17292. * @param array array to be set.
  17293. * @returns this effect.
  17294. */
  17295. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17296. /**
  17297. * 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)
  17298. * @param uniformName Name of the variable.
  17299. * @param array array to be set.
  17300. * @returns this effect.
  17301. */
  17302. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17303. /**
  17304. * 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)
  17305. * @param uniformName Name of the variable.
  17306. * @param array array to be set.
  17307. * @returns this effect.
  17308. */
  17309. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17310. /**
  17311. * Sets an float array on a uniform variable.
  17312. * @param uniformName Name of the variable.
  17313. * @param array array to be set.
  17314. * @returns this effect.
  17315. */
  17316. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17317. /**
  17318. * 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)
  17319. * @param uniformName Name of the variable.
  17320. * @param array array to be set.
  17321. * @returns this effect.
  17322. */
  17323. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17324. /**
  17325. * 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)
  17326. * @param uniformName Name of the variable.
  17327. * @param array array to be set.
  17328. * @returns this effect.
  17329. */
  17330. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17331. /**
  17332. * 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)
  17333. * @param uniformName Name of the variable.
  17334. * @param array array to be set.
  17335. * @returns this effect.
  17336. */
  17337. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17338. /**
  17339. * Sets an array on a uniform variable.
  17340. * @param uniformName Name of the variable.
  17341. * @param array array to be set.
  17342. * @returns this effect.
  17343. */
  17344. setArray(uniformName: string, array: number[]): Effect;
  17345. /**
  17346. * 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)
  17347. * @param uniformName Name of the variable.
  17348. * @param array array to be set.
  17349. * @returns this effect.
  17350. */
  17351. setArray2(uniformName: string, array: number[]): Effect;
  17352. /**
  17353. * 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)
  17354. * @param uniformName Name of the variable.
  17355. * @param array array to be set.
  17356. * @returns this effect.
  17357. */
  17358. setArray3(uniformName: string, array: number[]): Effect;
  17359. /**
  17360. * 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)
  17361. * @param uniformName Name of the variable.
  17362. * @param array array to be set.
  17363. * @returns this effect.
  17364. */
  17365. setArray4(uniformName: string, array: number[]): Effect;
  17366. /**
  17367. * Sets matrices on a uniform variable.
  17368. * @param uniformName Name of the variable.
  17369. * @param matrices matrices to be set.
  17370. * @returns this effect.
  17371. */
  17372. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17373. /**
  17374. * Sets matrix on a uniform variable.
  17375. * @param uniformName Name of the variable.
  17376. * @param matrix matrix to be set.
  17377. * @returns this effect.
  17378. */
  17379. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17380. /**
  17381. * 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)
  17382. * @param uniformName Name of the variable.
  17383. * @param matrix matrix to be set.
  17384. * @returns this effect.
  17385. */
  17386. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17387. /**
  17388. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17389. * @param uniformName Name of the variable.
  17390. * @param matrix matrix to be set.
  17391. * @returns this effect.
  17392. */
  17393. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17394. /**
  17395. * Sets a float on a uniform variable.
  17396. * @param uniformName Name of the variable.
  17397. * @param value value to be set.
  17398. * @returns this effect.
  17399. */
  17400. setFloat(uniformName: string, value: number): Effect;
  17401. /**
  17402. * Sets a boolean on a uniform variable.
  17403. * @param uniformName Name of the variable.
  17404. * @param bool value to be set.
  17405. * @returns this effect.
  17406. */
  17407. setBool(uniformName: string, bool: boolean): Effect;
  17408. /**
  17409. * Sets a Vector2 on a uniform variable.
  17410. * @param uniformName Name of the variable.
  17411. * @param vector2 vector2 to be set.
  17412. * @returns this effect.
  17413. */
  17414. setVector2(uniformName: string, vector2: Vector2): Effect;
  17415. /**
  17416. * Sets a float2 on a uniform variable.
  17417. * @param uniformName Name of the variable.
  17418. * @param x First float in float2.
  17419. * @param y Second float in float2.
  17420. * @returns this effect.
  17421. */
  17422. setFloat2(uniformName: string, x: number, y: number): Effect;
  17423. /**
  17424. * Sets a Vector3 on a uniform variable.
  17425. * @param uniformName Name of the variable.
  17426. * @param vector3 Value to be set.
  17427. * @returns this effect.
  17428. */
  17429. setVector3(uniformName: string, vector3: Vector3): Effect;
  17430. /**
  17431. * Sets a float3 on a uniform variable.
  17432. * @param uniformName Name of the variable.
  17433. * @param x First float in float3.
  17434. * @param y Second float in float3.
  17435. * @param z Third float in float3.
  17436. * @returns this effect.
  17437. */
  17438. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17439. /**
  17440. * Sets a Vector4 on a uniform variable.
  17441. * @param uniformName Name of the variable.
  17442. * @param vector4 Value to be set.
  17443. * @returns this effect.
  17444. */
  17445. setVector4(uniformName: string, vector4: Vector4): Effect;
  17446. /**
  17447. * Sets a float4 on a uniform variable.
  17448. * @param uniformName Name of the variable.
  17449. * @param x First float in float4.
  17450. * @param y Second float in float4.
  17451. * @param z Third float in float4.
  17452. * @param w Fourth float in float4.
  17453. * @returns this effect.
  17454. */
  17455. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17456. /**
  17457. * Sets a Color3 on a uniform variable.
  17458. * @param uniformName Name of the variable.
  17459. * @param color3 Value to be set.
  17460. * @returns this effect.
  17461. */
  17462. setColor3(uniformName: string, color3: Color3): Effect;
  17463. /**
  17464. * Sets a Color4 on a uniform variable.
  17465. * @param uniformName Name of the variable.
  17466. * @param color3 Value to be set.
  17467. * @param alpha Alpha value to be set.
  17468. * @returns this effect.
  17469. */
  17470. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17471. /**
  17472. * Sets a Color4 on a uniform variable
  17473. * @param uniformName defines the name of the variable
  17474. * @param color4 defines the value to be set
  17475. * @returns this effect.
  17476. */
  17477. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17478. /**
  17479. * This function will add a new shader to the shader store
  17480. * @param name the name of the shader
  17481. * @param pixelShader optional pixel shader content
  17482. * @param vertexShader optional vertex shader content
  17483. */
  17484. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17485. /**
  17486. * Store of each shader (The can be looked up using effect.key)
  17487. */
  17488. static ShadersStore: {
  17489. [key: string]: string;
  17490. };
  17491. /**
  17492. * Store of each included file for a shader (The can be looked up using effect.key)
  17493. */
  17494. static IncludesShadersStore: {
  17495. [key: string]: string;
  17496. };
  17497. /**
  17498. * Resets the cache of effects.
  17499. */
  17500. static ResetCache(): void;
  17501. }
  17502. }
  17503. declare module BABYLON {
  17504. /**
  17505. * This represents all the required information to add a fresnel effect on a material:
  17506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17507. */
  17508. class FresnelParameters {
  17509. private _isEnabled;
  17510. /**
  17511. * Define if the fresnel effect is enable or not.
  17512. */
  17513. isEnabled: boolean;
  17514. /**
  17515. * Define the color used on edges (grazing angle)
  17516. */
  17517. leftColor: Color3;
  17518. /**
  17519. * Define the color used on center
  17520. */
  17521. rightColor: Color3;
  17522. /**
  17523. * Define bias applied to computed fresnel term
  17524. */
  17525. bias: number;
  17526. /**
  17527. * Defined the power exponent applied to fresnel term
  17528. */
  17529. power: number;
  17530. /**
  17531. * Clones the current fresnel and its valuues
  17532. * @returns a clone fresnel configuration
  17533. */
  17534. clone(): FresnelParameters;
  17535. /**
  17536. * Serializes the current fresnel parameters to a JSON representation.
  17537. * @return the JSON serialization
  17538. */
  17539. serialize(): any;
  17540. /**
  17541. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17542. * @param parsedFresnelParameters Define the JSON representation
  17543. * @returns the parsed parameters
  17544. */
  17545. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17546. }
  17547. }
  17548. declare module BABYLON {
  17549. /**
  17550. * Interface to follow in your material defines to integrate easily the
  17551. * Image proccessing functions.
  17552. * @hidden
  17553. */
  17554. interface IImageProcessingConfigurationDefines {
  17555. IMAGEPROCESSING: boolean;
  17556. VIGNETTE: boolean;
  17557. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17558. VIGNETTEBLENDMODEOPAQUE: boolean;
  17559. TONEMAPPING: boolean;
  17560. TONEMAPPING_ACES: boolean;
  17561. CONTRAST: boolean;
  17562. EXPOSURE: boolean;
  17563. COLORCURVES: boolean;
  17564. COLORGRADING: boolean;
  17565. COLORGRADING3D: boolean;
  17566. SAMPLER3DGREENDEPTH: boolean;
  17567. SAMPLER3DBGRMAP: boolean;
  17568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17569. }
  17570. /**
  17571. * @hidden
  17572. */
  17573. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17574. IMAGEPROCESSING: boolean;
  17575. VIGNETTE: boolean;
  17576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17577. VIGNETTEBLENDMODEOPAQUE: boolean;
  17578. TONEMAPPING: boolean;
  17579. TONEMAPPING_ACES: boolean;
  17580. CONTRAST: boolean;
  17581. COLORCURVES: boolean;
  17582. COLORGRADING: boolean;
  17583. COLORGRADING3D: boolean;
  17584. SAMPLER3DGREENDEPTH: boolean;
  17585. SAMPLER3DBGRMAP: boolean;
  17586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17587. EXPOSURE: boolean;
  17588. constructor();
  17589. }
  17590. /**
  17591. * This groups together the common properties used for image processing either in direct forward pass
  17592. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17593. * or not.
  17594. */
  17595. class ImageProcessingConfiguration {
  17596. /**
  17597. * Default tone mapping applied in BabylonJS.
  17598. */
  17599. static readonly TONEMAPPING_STANDARD: number;
  17600. /**
  17601. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17602. * to other engines rendering to increase portability.
  17603. */
  17604. static readonly TONEMAPPING_ACES: number;
  17605. /**
  17606. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17607. */
  17608. colorCurves: Nullable<ColorCurves>;
  17609. private _colorCurvesEnabled;
  17610. /**
  17611. * Gets wether the color curves effect is enabled.
  17612. */
  17613. /**
  17614. * Sets wether the color curves effect is enabled.
  17615. */
  17616. colorCurvesEnabled: boolean;
  17617. private _colorGradingTexture;
  17618. /**
  17619. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17620. */
  17621. /**
  17622. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17623. */
  17624. colorGradingTexture: Nullable<BaseTexture>;
  17625. private _colorGradingEnabled;
  17626. /**
  17627. * Gets wether the color grading effect is enabled.
  17628. */
  17629. /**
  17630. * Sets wether the color grading effect is enabled.
  17631. */
  17632. colorGradingEnabled: boolean;
  17633. private _colorGradingWithGreenDepth;
  17634. /**
  17635. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17636. */
  17637. /**
  17638. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17639. */
  17640. colorGradingWithGreenDepth: boolean;
  17641. private _colorGradingBGR;
  17642. /**
  17643. * Gets wether the color grading texture contains BGR values.
  17644. */
  17645. /**
  17646. * Sets wether the color grading texture contains BGR values.
  17647. */
  17648. colorGradingBGR: boolean;
  17649. /** @hidden */
  17650. _exposure: number;
  17651. /**
  17652. * Gets the Exposure used in the effect.
  17653. */
  17654. /**
  17655. * Sets the Exposure used in the effect.
  17656. */
  17657. exposure: number;
  17658. private _toneMappingEnabled;
  17659. /**
  17660. * Gets wether the tone mapping effect is enabled.
  17661. */
  17662. /**
  17663. * Sets wether the tone mapping effect is enabled.
  17664. */
  17665. toneMappingEnabled: boolean;
  17666. private _toneMappingType;
  17667. /**
  17668. * Gets the type of tone mapping effect.
  17669. */
  17670. /**
  17671. * Sets the type of tone mapping effect used in BabylonJS.
  17672. */
  17673. toneMappingType: number;
  17674. protected _contrast: number;
  17675. /**
  17676. * Gets the contrast used in the effect.
  17677. */
  17678. /**
  17679. * Sets the contrast used in the effect.
  17680. */
  17681. contrast: number;
  17682. /**
  17683. * Vignette stretch size.
  17684. */
  17685. vignetteStretch: number;
  17686. /**
  17687. * Vignette centre X Offset.
  17688. */
  17689. vignetteCentreX: number;
  17690. /**
  17691. * Vignette centre Y Offset.
  17692. */
  17693. vignetteCentreY: number;
  17694. /**
  17695. * Vignette weight or intensity of the vignette effect.
  17696. */
  17697. vignetteWeight: number;
  17698. /**
  17699. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17700. * if vignetteEnabled is set to true.
  17701. */
  17702. vignetteColor: Color4;
  17703. /**
  17704. * Camera field of view used by the Vignette effect.
  17705. */
  17706. vignetteCameraFov: number;
  17707. private _vignetteBlendMode;
  17708. /**
  17709. * Gets the vignette blend mode allowing different kind of effect.
  17710. */
  17711. /**
  17712. * Sets the vignette blend mode allowing different kind of effect.
  17713. */
  17714. vignetteBlendMode: number;
  17715. private _vignetteEnabled;
  17716. /**
  17717. * Gets wether the vignette effect is enabled.
  17718. */
  17719. /**
  17720. * Sets wether the vignette effect is enabled.
  17721. */
  17722. vignetteEnabled: boolean;
  17723. private _applyByPostProcess;
  17724. /**
  17725. * Gets wether the image processing is applied through a post process or not.
  17726. */
  17727. /**
  17728. * Sets wether the image processing is applied through a post process or not.
  17729. */
  17730. applyByPostProcess: boolean;
  17731. private _isEnabled;
  17732. /**
  17733. * Gets wether the image processing is enabled or not.
  17734. */
  17735. /**
  17736. * Sets wether the image processing is enabled or not.
  17737. */
  17738. isEnabled: boolean;
  17739. /**
  17740. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17741. */
  17742. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17743. /**
  17744. * Method called each time the image processing information changes requires to recompile the effect.
  17745. */
  17746. protected _updateParameters(): void;
  17747. /**
  17748. * Gets the current class name.
  17749. * @return "ImageProcessingConfiguration"
  17750. */
  17751. getClassName(): string;
  17752. /**
  17753. * Prepare the list of uniforms associated with the Image Processing effects.
  17754. * @param uniforms The list of uniforms used in the effect
  17755. * @param defines the list of defines currently in use
  17756. */
  17757. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17758. /**
  17759. * Prepare the list of samplers associated with the Image Processing effects.
  17760. * @param samplersList The list of uniforms used in the effect
  17761. * @param defines the list of defines currently in use
  17762. */
  17763. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17764. /**
  17765. * Prepare the list of defines associated to the shader.
  17766. * @param defines the list of defines to complete
  17767. * @param forPostProcess Define if we are currently in post process mode or not
  17768. */
  17769. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17770. /**
  17771. * Returns true if all the image processing information are ready.
  17772. * @returns True if ready, otherwise, false
  17773. */
  17774. isReady(): boolean;
  17775. /**
  17776. * Binds the image processing to the shader.
  17777. * @param effect The effect to bind to
  17778. * @param aspectRatio Define the current aspect ratio of the effect
  17779. */
  17780. bind(effect: Effect, aspectRatio?: number): void;
  17781. /**
  17782. * Clones the current image processing instance.
  17783. * @return The cloned image processing
  17784. */
  17785. clone(): ImageProcessingConfiguration;
  17786. /**
  17787. * Serializes the current image processing instance to a json representation.
  17788. * @return a JSON representation
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parses the image processing from a json representation.
  17793. * @param source the JSON source to parse
  17794. * @return The parsed image processing
  17795. */
  17796. static Parse(source: any): ImageProcessingConfiguration;
  17797. private static _VIGNETTEMODE_MULTIPLY;
  17798. private static _VIGNETTEMODE_OPAQUE;
  17799. /**
  17800. * Used to apply the vignette as a mix with the pixel color.
  17801. */
  17802. static readonly VIGNETTEMODE_MULTIPLY: number;
  17803. /**
  17804. * Used to apply the vignette as a replacement of the pixel color.
  17805. */
  17806. static readonly VIGNETTEMODE_OPAQUE: number;
  17807. }
  17808. }
  17809. declare module BABYLON {
  17810. /**
  17811. * Manages the defines for the Material
  17812. */
  17813. class MaterialDefines {
  17814. private _keys;
  17815. private _isDirty;
  17816. /** @hidden */
  17817. _renderId: number;
  17818. /** @hidden */
  17819. _areLightsDirty: boolean;
  17820. /** @hidden */
  17821. _areAttributesDirty: boolean;
  17822. /** @hidden */
  17823. _areTexturesDirty: boolean;
  17824. /** @hidden */
  17825. _areFresnelDirty: boolean;
  17826. /** @hidden */
  17827. _areMiscDirty: boolean;
  17828. /** @hidden */
  17829. _areImageProcessingDirty: boolean;
  17830. /** @hidden */
  17831. _normals: boolean;
  17832. /** @hidden */
  17833. _uvs: boolean;
  17834. /** @hidden */
  17835. _needNormals: boolean;
  17836. /** @hidden */
  17837. _needUVs: boolean;
  17838. /**
  17839. * Specifies if the material needs to be re-calculated
  17840. */
  17841. readonly isDirty: boolean;
  17842. /**
  17843. * Marks the material to indicate that it has been re-calculated
  17844. */
  17845. markAsProcessed(): void;
  17846. /**
  17847. * Marks the material to indicate that it needs to be re-calculated
  17848. */
  17849. markAsUnprocessed(): void;
  17850. /**
  17851. * Marks the material to indicate all of its defines need to be re-calculated
  17852. */
  17853. markAllAsDirty(): void;
  17854. /**
  17855. * Marks the material to indicate that image processing needs to be re-calculated
  17856. */
  17857. markAsImageProcessingDirty(): void;
  17858. /**
  17859. * Marks the material to indicate the lights need to be re-calculated
  17860. */
  17861. markAsLightDirty(): void;
  17862. /**
  17863. * Marks the attribute state as changed
  17864. */
  17865. markAsAttributesDirty(): void;
  17866. /**
  17867. * Marks the texture state as changed
  17868. */
  17869. markAsTexturesDirty(): void;
  17870. /**
  17871. * Marks the fresnel state as changed
  17872. */
  17873. markAsFresnelDirty(): void;
  17874. /**
  17875. * Marks the misc state as changed
  17876. */
  17877. markAsMiscDirty(): void;
  17878. /**
  17879. * Rebuilds the material defines
  17880. */
  17881. rebuild(): void;
  17882. /**
  17883. * Specifies if two material defines are equal
  17884. * @param other - A material define instance to compare to
  17885. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17886. */
  17887. isEqual(other: MaterialDefines): boolean;
  17888. /**
  17889. * Clones this instance's defines to another instance
  17890. * @param other - material defines to clone values to
  17891. */
  17892. cloneTo(other: MaterialDefines): void;
  17893. /**
  17894. * Resets the material define values
  17895. */
  17896. reset(): void;
  17897. /**
  17898. * Converts the material define values to a string
  17899. * @returns - String of material define information
  17900. */
  17901. toString(): string;
  17902. }
  17903. /**
  17904. * Base class for the main features of a material in Babylon.js
  17905. */
  17906. class Material implements IAnimatable {
  17907. private static _TriangleFillMode;
  17908. private static _WireFrameFillMode;
  17909. private static _PointFillMode;
  17910. private static _PointListDrawMode;
  17911. private static _LineListDrawMode;
  17912. private static _LineLoopDrawMode;
  17913. private static _LineStripDrawMode;
  17914. private static _TriangleStripDrawMode;
  17915. private static _TriangleFanDrawMode;
  17916. /**
  17917. * Returns the triangle fill mode
  17918. */
  17919. static readonly TriangleFillMode: number;
  17920. /**
  17921. * Returns the wireframe mode
  17922. */
  17923. static readonly WireFrameFillMode: number;
  17924. /**
  17925. * Returns the point fill mode
  17926. */
  17927. static readonly PointFillMode: number;
  17928. /**
  17929. * Returns the point list draw mode
  17930. */
  17931. static readonly PointListDrawMode: number;
  17932. /**
  17933. * Returns the line list draw mode
  17934. */
  17935. static readonly LineListDrawMode: number;
  17936. /**
  17937. * Returns the line loop draw mode
  17938. */
  17939. static readonly LineLoopDrawMode: number;
  17940. /**
  17941. * Returns the line strip draw mode
  17942. */
  17943. static readonly LineStripDrawMode: number;
  17944. /**
  17945. * Returns the triangle strip draw mode
  17946. */
  17947. static readonly TriangleStripDrawMode: number;
  17948. /**
  17949. * Returns the triangle fan draw mode
  17950. */
  17951. static readonly TriangleFanDrawMode: number;
  17952. /**
  17953. * Stores the clock-wise side orientation
  17954. */
  17955. private static _ClockWiseSideOrientation;
  17956. /**
  17957. * Stores the counter clock-wise side orientation
  17958. */
  17959. private static _CounterClockWiseSideOrientation;
  17960. /**
  17961. * Returns the clock-wise side orientation
  17962. */
  17963. static readonly ClockWiseSideOrientation: number;
  17964. /**
  17965. * Returns the counter clock-wise side orientation
  17966. */
  17967. static readonly CounterClockWiseSideOrientation: number;
  17968. /**
  17969. * The dirty texture flag value
  17970. */
  17971. static readonly TextureDirtyFlag: number;
  17972. /**
  17973. * The dirty light flag value
  17974. */
  17975. static readonly LightDirtyFlag: number;
  17976. /**
  17977. * The dirty fresnel flag value
  17978. */
  17979. static readonly FresnelDirtyFlag: number;
  17980. /**
  17981. * The dirty attribute flag value
  17982. */
  17983. static readonly AttributesDirtyFlag: number;
  17984. /**
  17985. * The dirty misc flag value
  17986. */
  17987. static readonly MiscDirtyFlag: number;
  17988. /**
  17989. * The all dirty flag value
  17990. */
  17991. static readonly AllDirtyFlag: number;
  17992. /**
  17993. * The ID of the material
  17994. */
  17995. id: string;
  17996. /**
  17997. * Gets or sets the unique id of the material
  17998. */
  17999. uniqueId: number;
  18000. /**
  18001. * The name of the material
  18002. */
  18003. name: string;
  18004. /**
  18005. * Specifies if the ready state should be checked on each call
  18006. */
  18007. checkReadyOnEveryCall: boolean;
  18008. /**
  18009. * Specifies if the ready state should be checked once
  18010. */
  18011. checkReadyOnlyOnce: boolean;
  18012. /**
  18013. * The state of the material
  18014. */
  18015. state: string;
  18016. /**
  18017. * The alpha value of the material
  18018. */
  18019. protected _alpha: number;
  18020. /**
  18021. * Sets the alpha value of the material
  18022. */
  18023. /**
  18024. * Gets the alpha value of the material
  18025. */
  18026. alpha: number;
  18027. /**
  18028. * Specifies if back face culling is enabled
  18029. */
  18030. protected _backFaceCulling: boolean;
  18031. /**
  18032. * Sets the back-face culling state
  18033. */
  18034. /**
  18035. * Gets the back-face culling state
  18036. */
  18037. backFaceCulling: boolean;
  18038. /**
  18039. * Stores the value for side orientation
  18040. */
  18041. sideOrientation: number;
  18042. /**
  18043. * Callback triggered when the material is compiled
  18044. */
  18045. onCompiled: (effect: Effect) => void;
  18046. /**
  18047. * Callback triggered when an error occurs
  18048. */
  18049. onError: (effect: Effect, errors: string) => void;
  18050. /**
  18051. * Callback triggered to get the render target textures
  18052. */
  18053. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18054. /**
  18055. * Gets a boolean indicating that current material needs to register RTT
  18056. */
  18057. readonly hasRenderTargetTextures: boolean;
  18058. /**
  18059. * Specifies if the material should be serialized
  18060. */
  18061. doNotSerialize: boolean;
  18062. /**
  18063. * @hidden
  18064. */
  18065. _storeEffectOnSubMeshes: boolean;
  18066. /**
  18067. * Stores the animations for the material
  18068. */
  18069. animations: Array<Animation>;
  18070. /**
  18071. * An event triggered when the material is disposed
  18072. */
  18073. onDisposeObservable: Observable<Material>;
  18074. /**
  18075. * An observer which watches for dispose events
  18076. */
  18077. private _onDisposeObserver;
  18078. private _onUnBindObservable;
  18079. /**
  18080. * Called during a dispose event
  18081. */
  18082. onDispose: () => void;
  18083. private _onBindObservable;
  18084. /**
  18085. * An event triggered when the material is bound
  18086. */
  18087. readonly onBindObservable: Observable<AbstractMesh>;
  18088. /**
  18089. * An observer which watches for bind events
  18090. */
  18091. private _onBindObserver;
  18092. /**
  18093. * Called during a bind event
  18094. */
  18095. onBind: (Mesh: AbstractMesh) => void;
  18096. /**
  18097. * An event triggered when the material is unbound
  18098. */
  18099. readonly onUnBindObservable: Observable<Material>;
  18100. /**
  18101. * Stores the value of the alpha mode
  18102. */
  18103. private _alphaMode;
  18104. /**
  18105. * Sets the value of the alpha mode.
  18106. *
  18107. * | Value | Type | Description |
  18108. * | --- | --- | --- |
  18109. * | 0 | ALPHA_DISABLE | |
  18110. * | 1 | ALPHA_ADD | |
  18111. * | 2 | ALPHA_COMBINE | |
  18112. * | 3 | ALPHA_SUBTRACT | |
  18113. * | 4 | ALPHA_MULTIPLY | |
  18114. * | 5 | ALPHA_MAXIMIZED | |
  18115. * | 6 | ALPHA_ONEONE | |
  18116. * | 7 | ALPHA_PREMULTIPLIED | |
  18117. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18118. * | 9 | ALPHA_INTERPOLATE | |
  18119. * | 10 | ALPHA_SCREENMODE | |
  18120. *
  18121. */
  18122. /**
  18123. * Gets the value of the alpha mode
  18124. */
  18125. alphaMode: number;
  18126. /**
  18127. * Stores the state of the need depth pre-pass value
  18128. */
  18129. private _needDepthPrePass;
  18130. /**
  18131. * Sets the need depth pre-pass value
  18132. */
  18133. /**
  18134. * Gets the depth pre-pass value
  18135. */
  18136. needDepthPrePass: boolean;
  18137. /**
  18138. * Specifies if depth writing should be disabled
  18139. */
  18140. disableDepthWrite: boolean;
  18141. /**
  18142. * Specifies if depth writing should be forced
  18143. */
  18144. forceDepthWrite: boolean;
  18145. /**
  18146. * Specifies if there should be a separate pass for culling
  18147. */
  18148. separateCullingPass: boolean;
  18149. /**
  18150. * Stores the state specifing if fog should be enabled
  18151. */
  18152. private _fogEnabled;
  18153. /**
  18154. * Sets the state for enabling fog
  18155. */
  18156. /**
  18157. * Gets the value of the fog enabled state
  18158. */
  18159. fogEnabled: boolean;
  18160. /**
  18161. * Stores the size of points
  18162. */
  18163. pointSize: number;
  18164. /**
  18165. * Stores the z offset value
  18166. */
  18167. zOffset: number;
  18168. /**
  18169. * Gets a value specifying if wireframe mode is enabled
  18170. */
  18171. /**
  18172. * Sets the state of wireframe mode
  18173. */
  18174. wireframe: boolean;
  18175. /**
  18176. * Gets the value specifying if point clouds are enabled
  18177. */
  18178. /**
  18179. * Sets the state of point cloud mode
  18180. */
  18181. pointsCloud: boolean;
  18182. /**
  18183. * Gets the material fill mode
  18184. */
  18185. /**
  18186. * Sets the material fill mode
  18187. */
  18188. fillMode: number;
  18189. /**
  18190. * @hidden
  18191. * Stores the effects for the material
  18192. */
  18193. _effect: Nullable<Effect>;
  18194. /**
  18195. * @hidden
  18196. * Specifies if the material was previously ready
  18197. */
  18198. _wasPreviouslyReady: boolean;
  18199. /**
  18200. * Specifies if uniform buffers should be used
  18201. */
  18202. private _useUBO;
  18203. /**
  18204. * Stores a reference to the scene
  18205. */
  18206. private _scene;
  18207. /**
  18208. * Stores the fill mode state
  18209. */
  18210. private _fillMode;
  18211. /**
  18212. * Specifies if the depth write state should be cached
  18213. */
  18214. private _cachedDepthWriteState;
  18215. /**
  18216. * Stores the uniform buffer
  18217. */
  18218. protected _uniformBuffer: UniformBuffer;
  18219. /** @hidden */
  18220. _indexInSceneMaterialArray: number;
  18221. /** @hidden */
  18222. meshMap: Nullable<{
  18223. [id: string]: AbstractMesh | undefined;
  18224. }>;
  18225. /**
  18226. * Creates a material instance
  18227. * @param name defines the name of the material
  18228. * @param scene defines the scene to reference
  18229. * @param doNotAdd specifies if the material should be added to the scene
  18230. */
  18231. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18232. /**
  18233. * Returns a string representation of the current material
  18234. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18235. * @returns a string with material information
  18236. */
  18237. toString(fullDetails?: boolean): string;
  18238. /**
  18239. * Gets the class name of the material
  18240. * @returns a string with the class name of the material
  18241. */
  18242. getClassName(): string;
  18243. /**
  18244. * Specifies if updates for the material been locked
  18245. */
  18246. readonly isFrozen: boolean;
  18247. /**
  18248. * Locks updates for the material
  18249. */
  18250. freeze(): void;
  18251. /**
  18252. * Unlocks updates for the material
  18253. */
  18254. unfreeze(): void;
  18255. /**
  18256. * Specifies if the material is ready to be used
  18257. * @param mesh defines the mesh to check
  18258. * @param useInstances specifies if instances should be used
  18259. * @returns a boolean indicating if the material is ready to be used
  18260. */
  18261. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18262. /**
  18263. * Specifies that the submesh is ready to be used
  18264. * @param mesh defines the mesh to check
  18265. * @param subMesh defines which submesh to check
  18266. * @param useInstances specifies that instances should be used
  18267. * @returns a boolean indicating that the submesh is ready or not
  18268. */
  18269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18270. /**
  18271. * Returns the material effect
  18272. * @returns the effect associated with the material
  18273. */
  18274. getEffect(): Nullable<Effect>;
  18275. /**
  18276. * Returns the current scene
  18277. * @returns a Scene
  18278. */
  18279. getScene(): Scene;
  18280. /**
  18281. * Specifies if the material will require alpha blending
  18282. * @returns a boolean specifying if alpha blending is needed
  18283. */
  18284. needAlphaBlending(): boolean;
  18285. /**
  18286. * Specifies if the mesh will require alpha blending
  18287. * @param mesh defines the mesh to check
  18288. * @returns a boolean specifying if alpha blending is needed for the mesh
  18289. */
  18290. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18291. /**
  18292. * Specifies if this material should be rendered in alpha test mode
  18293. * @returns a boolean specifying if an alpha test is needed.
  18294. */
  18295. needAlphaTesting(): boolean;
  18296. /**
  18297. * Gets the texture used for the alpha test
  18298. * @returns the texture to use for alpha testing
  18299. */
  18300. getAlphaTestTexture(): Nullable<BaseTexture>;
  18301. /**
  18302. * Marks the material to indicate that it needs to be re-calculated
  18303. */
  18304. markDirty(): void;
  18305. /** @hidden */
  18306. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18307. /**
  18308. * Binds the material to the mesh
  18309. * @param world defines the world transformation matrix
  18310. * @param mesh defines the mesh to bind the material to
  18311. */
  18312. bind(world: Matrix, mesh?: Mesh): void;
  18313. /**
  18314. * Binds the submesh to the material
  18315. * @param world defines the world transformation matrix
  18316. * @param mesh defines the mesh containing the submesh
  18317. * @param subMesh defines the submesh to bind the material to
  18318. */
  18319. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18320. /**
  18321. * Binds the world matrix to the material
  18322. * @param world defines the world transformation matrix
  18323. */
  18324. bindOnlyWorldMatrix(world: Matrix): void;
  18325. /**
  18326. * Binds the scene's uniform buffer to the effect.
  18327. * @param effect defines the effect to bind to the scene uniform buffer
  18328. * @param sceneUbo defines the uniform buffer storing scene data
  18329. */
  18330. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18331. /**
  18332. * Binds the view matrix to the effect
  18333. * @param effect defines the effect to bind the view matrix to
  18334. */
  18335. bindView(effect: Effect): void;
  18336. /**
  18337. * Binds the view projection matrix to the effect
  18338. * @param effect defines the effect to bind the view projection matrix to
  18339. */
  18340. bindViewProjection(effect: Effect): void;
  18341. /**
  18342. * Specifies if material alpha testing should be turned on for the mesh
  18343. * @param mesh defines the mesh to check
  18344. */
  18345. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18346. /**
  18347. * Processes to execute after binding the material to a mesh
  18348. * @param mesh defines the rendered mesh
  18349. */
  18350. protected _afterBind(mesh?: Mesh): void;
  18351. /**
  18352. * Unbinds the material from the mesh
  18353. */
  18354. unbind(): void;
  18355. /**
  18356. * Gets the active textures from the material
  18357. * @returns an array of textures
  18358. */
  18359. getActiveTextures(): BaseTexture[];
  18360. /**
  18361. * Specifies if the material uses a texture
  18362. * @param texture defines the texture to check against the material
  18363. * @returns a boolean specifying if the material uses the texture
  18364. */
  18365. hasTexture(texture: BaseTexture): boolean;
  18366. /**
  18367. * Makes a duplicate of the material, and gives it a new name
  18368. * @param name defines the new name for the duplicated material
  18369. * @returns the cloned material
  18370. */
  18371. clone(name: string): Nullable<Material>;
  18372. /**
  18373. * Gets the meshes bound to the material
  18374. * @returns an array of meshes bound to the material
  18375. */
  18376. getBindedMeshes(): AbstractMesh[];
  18377. /**
  18378. * Force shader compilation
  18379. * @param mesh defines the mesh associated with this material
  18380. * @param onCompiled defines a function to execute once the material is compiled
  18381. * @param options defines the options to configure the compilation
  18382. */
  18383. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18384. clipPlane: boolean;
  18385. }>): void;
  18386. /**
  18387. * Force shader compilation
  18388. * @param mesh defines the mesh that will use this material
  18389. * @param options defines additional options for compiling the shaders
  18390. * @returns a promise that resolves when the compilation completes
  18391. */
  18392. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18393. clipPlane: boolean;
  18394. }>): Promise<void>;
  18395. private static readonly _ImageProcessingDirtyCallBack;
  18396. private static readonly _TextureDirtyCallBack;
  18397. private static readonly _FresnelDirtyCallBack;
  18398. private static readonly _MiscDirtyCallBack;
  18399. private static readonly _LightsDirtyCallBack;
  18400. private static readonly _AttributeDirtyCallBack;
  18401. private static _FresnelAndMiscDirtyCallBack;
  18402. private static _TextureAndMiscDirtyCallBack;
  18403. private static readonly _DirtyCallbackArray;
  18404. private static readonly _RunDirtyCallBacks;
  18405. /**
  18406. * Marks a define in the material to indicate that it needs to be re-computed
  18407. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18408. */
  18409. markAsDirty(flag: number): void;
  18410. /**
  18411. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18412. * @param func defines a function which checks material defines against the submeshes
  18413. */
  18414. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18415. /**
  18416. * Indicates that image processing needs to be re-calculated for all submeshes
  18417. */
  18418. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18419. /**
  18420. * Indicates that textures need to be re-calculated for all submeshes
  18421. */
  18422. protected _markAllSubMeshesAsTexturesDirty(): void;
  18423. /**
  18424. * Indicates that fresnel needs to be re-calculated for all submeshes
  18425. */
  18426. protected _markAllSubMeshesAsFresnelDirty(): void;
  18427. /**
  18428. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18429. */
  18430. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18431. /**
  18432. * Indicates that lights need to be re-calculated for all submeshes
  18433. */
  18434. protected _markAllSubMeshesAsLightsDirty(): void;
  18435. /**
  18436. * Indicates that attributes need to be re-calculated for all submeshes
  18437. */
  18438. protected _markAllSubMeshesAsAttributesDirty(): void;
  18439. /**
  18440. * Indicates that misc needs to be re-calculated for all submeshes
  18441. */
  18442. protected _markAllSubMeshesAsMiscDirty(): void;
  18443. /**
  18444. * Indicates that textures and misc need to be re-calculated for all submeshes
  18445. */
  18446. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18447. /**
  18448. * Disposes the material
  18449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18450. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18451. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18452. */
  18453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18454. /** @hidden */
  18455. private releaseVertexArrayObject;
  18456. /**
  18457. * Serializes this material
  18458. * @returns the serialized material object
  18459. */
  18460. serialize(): any;
  18461. /**
  18462. * Creates a MultiMaterial from parsed MultiMaterial data.
  18463. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18464. * @param scene defines the hosting scene
  18465. * @returns a new MultiMaterial
  18466. */
  18467. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18468. /**
  18469. * Creates a material from parsed material data
  18470. * @param parsedMaterial defines parsed material data
  18471. * @param scene defines the hosting scene
  18472. * @param rootUrl defines the root URL to use to load textures
  18473. * @returns a new material
  18474. */
  18475. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18476. }
  18477. }
  18478. declare module BABYLON {
  18479. /**
  18480. * "Static Class" containing the most commonly used helper while dealing with material for
  18481. * rendering purpose.
  18482. *
  18483. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18484. *
  18485. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18486. */
  18487. class MaterialHelper {
  18488. /**
  18489. * Bind the current view position to an effect.
  18490. * @param effect The effect to be bound
  18491. * @param scene The scene the eyes position is used from
  18492. */
  18493. static BindEyePosition(effect: Effect, scene: Scene): void;
  18494. /**
  18495. * Helps preparing the defines values about the UVs in used in the effect.
  18496. * UVs are shared as much as we can accross channels in the shaders.
  18497. * @param texture The texture we are preparing the UVs for
  18498. * @param defines The defines to update
  18499. * @param key The channel key "diffuse", "specular"... used in the shader
  18500. */
  18501. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18502. /**
  18503. * Binds a texture matrix value to its corrsponding uniform
  18504. * @param texture The texture to bind the matrix for
  18505. * @param uniformBuffer The uniform buffer receivin the data
  18506. * @param key The channel key "diffuse", "specular"... used in the shader
  18507. */
  18508. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18509. /**
  18510. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18511. * @param mesh defines the current mesh
  18512. * @param scene defines the current scene
  18513. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18514. * @param pointsCloud defines if point cloud rendering has to be turned on
  18515. * @param fogEnabled defines if fog has to be turned on
  18516. * @param alphaTest defines if alpha testing has to be turned on
  18517. * @param defines defines the current list of defines
  18518. */
  18519. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18520. /**
  18521. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18522. * @param scene defines the current scene
  18523. * @param engine defines the current engine
  18524. * @param defines specifies the list of active defines
  18525. * @param useInstances defines if instances have to be turned on
  18526. * @param useClipPlane defines if clip plane have to be turned on
  18527. */
  18528. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18529. /**
  18530. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18531. * @param mesh The mesh containing the geometry data we will draw
  18532. * @param defines The defines to update
  18533. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18534. * @param useBones Precise whether bones should be used or not (override mesh info)
  18535. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18536. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18537. * @returns false if defines are considered not dirty and have not been checked
  18538. */
  18539. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18540. /**
  18541. * Prepares the defines related to the light information passed in parameter
  18542. * @param scene The scene we are intending to draw
  18543. * @param mesh The mesh the effect is compiling for
  18544. * @param defines The defines to update
  18545. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18546. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18547. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18548. * @returns true if normals will be required for the rest of the effect
  18549. */
  18550. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18551. /**
  18552. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18553. * that won t be acctive due to defines being turned off.
  18554. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18555. * @param samplersList The samplers list
  18556. * @param defines The defines helping in the list generation
  18557. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18558. */
  18559. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18560. /**
  18561. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18562. * @param defines The defines to update while falling back
  18563. * @param fallbacks The authorized effect fallbacks
  18564. * @param maxSimultaneousLights The maximum number of lights allowed
  18565. * @param rank the current rank of the Effect
  18566. * @returns The newly affected rank
  18567. */
  18568. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18569. /**
  18570. * Prepares the list of attributes required for morph targets according to the effect defines.
  18571. * @param attribs The current list of supported attribs
  18572. * @param mesh The mesh to prepare the morph targets attributes for
  18573. * @param defines The current Defines of the effect
  18574. */
  18575. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18576. /**
  18577. * Prepares the list of attributes required for bones according to the effect defines.
  18578. * @param attribs The current list of supported attribs
  18579. * @param mesh The mesh to prepare the bones attributes for
  18580. * @param defines The current Defines of the effect
  18581. * @param fallbacks The current efffect fallback strategy
  18582. */
  18583. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18584. /**
  18585. * Prepares the list of attributes required for instances according to the effect defines.
  18586. * @param attribs The current list of supported attribs
  18587. * @param defines The current Defines of the effect
  18588. */
  18589. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18590. /**
  18591. * Binds the light shadow information to the effect for the given mesh.
  18592. * @param light The light containing the generator
  18593. * @param scene The scene the lights belongs to
  18594. * @param mesh The mesh we are binding the information to render
  18595. * @param lightIndex The light index in the effect used to render the mesh
  18596. * @param effect The effect we are binding the data to
  18597. */
  18598. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18599. /**
  18600. * Binds the light information to the effect.
  18601. * @param light The light containing the generator
  18602. * @param effect The effect we are binding the data to
  18603. * @param lightIndex The light index in the effect used to render
  18604. */
  18605. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18606. /**
  18607. * Binds the lights information from the scene to the effect for the given mesh.
  18608. * @param scene The scene the lights belongs to
  18609. * @param mesh The mesh we are binding the information to render
  18610. * @param effect The effect we are binding the data to
  18611. * @param defines The generated defines for the effect
  18612. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18613. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18614. */
  18615. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18616. private static _tempFogColor;
  18617. /**
  18618. * Binds the fog information from the scene to the effect for the given mesh.
  18619. * @param scene The scene the lights belongs to
  18620. * @param mesh The mesh we are binding the information to render
  18621. * @param effect The effect we are binding the data to
  18622. * @param linearSpace Defines if the fog effect is applied in linear space
  18623. */
  18624. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18625. /**
  18626. * Binds the bones information from the mesh to the effect.
  18627. * @param mesh The mesh we are binding the information to render
  18628. * @param effect The effect we are binding the data to
  18629. */
  18630. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18631. /**
  18632. * Binds the morph targets information from the mesh to the effect.
  18633. * @param abstractMesh The mesh we are binding the information to render
  18634. * @param effect The effect we are binding the data to
  18635. */
  18636. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18637. /**
  18638. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18639. * @param defines The generated defines used in the effect
  18640. * @param effect The effect we are binding the data to
  18641. * @param scene The scene we are willing to render with logarithmic scale for
  18642. */
  18643. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18644. /**
  18645. * Binds the clip plane information from the scene to the effect.
  18646. * @param scene The scene the clip plane information are extracted from
  18647. * @param effect The effect we are binding the data to
  18648. */
  18649. static BindClipPlane(effect: Effect, scene: Scene): void;
  18650. }
  18651. }
  18652. declare module BABYLON {
  18653. /**
  18654. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18655. * separate meshes. This can be use to improve performances.
  18656. * @see http://doc.babylonjs.com/how_to/multi_materials
  18657. */
  18658. class MultiMaterial extends Material {
  18659. private _subMaterials;
  18660. /**
  18661. * Gets or Sets the list of Materials used within the multi material.
  18662. * They need to be ordered according to the submeshes order in the associated mesh
  18663. */
  18664. subMaterials: Nullable<Material>[];
  18665. /**
  18666. * Function used to align with Node.getChildren()
  18667. * @returns the list of Materials used within the multi material
  18668. */
  18669. getChildren(): Nullable<Material>[];
  18670. /**
  18671. * Instantiates a new Multi Material
  18672. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18673. * separate meshes. This can be use to improve performances.
  18674. * @see http://doc.babylonjs.com/how_to/multi_materials
  18675. * @param name Define the name in the scene
  18676. * @param scene Define the scene the material belongs to
  18677. */
  18678. constructor(name: string, scene: Scene);
  18679. private _hookArray;
  18680. /**
  18681. * Get one of the submaterial by its index in the submaterials array
  18682. * @param index The index to look the sub material at
  18683. * @returns The Material if the index has been defined
  18684. */
  18685. getSubMaterial(index: number): Nullable<Material>;
  18686. /**
  18687. * Get the list of active textures for the whole sub materials list.
  18688. * @returns All the textures that will be used during the rendering
  18689. */
  18690. getActiveTextures(): BaseTexture[];
  18691. /**
  18692. * Gets the current class name of the material e.g. "MultiMaterial"
  18693. * Mainly use in serialization.
  18694. * @returns the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Checks if the material is ready to render the requested sub mesh
  18699. * @param mesh Define the mesh the submesh belongs to
  18700. * @param subMesh Define the sub mesh to look readyness for
  18701. * @param useInstances Define whether or not the material is used with instances
  18702. * @returns true if ready, otherwise false
  18703. */
  18704. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18705. /**
  18706. * Clones the current material and its related sub materials
  18707. * @param name Define the name of the newly cloned material
  18708. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18709. * @returns the cloned material
  18710. */
  18711. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18712. /**
  18713. * Serializes the materials into a JSON representation.
  18714. * @returns the JSON representation
  18715. */
  18716. serialize(): any;
  18717. /**
  18718. * Dispose the material and release its associated resources
  18719. * @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)
  18720. * @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)
  18721. */
  18722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18723. }
  18724. }
  18725. declare module BABYLON {
  18726. /**
  18727. * Base class of materials working in push mode in babylon JS
  18728. * @hidden
  18729. */
  18730. class PushMaterial extends Material {
  18731. protected _activeEffect: Effect;
  18732. protected _normalMatrix: Matrix;
  18733. /**
  18734. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18735. * This means that the material can keep using a previous shader while a new one is being compiled.
  18736. * This is mostly used when shader parallel compilation is supported (true by default)
  18737. */
  18738. allowShaderHotSwapping: boolean;
  18739. constructor(name: string, scene: Scene);
  18740. getEffect(): Effect;
  18741. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18742. /**
  18743. * Binds the given world matrix to the active effect
  18744. *
  18745. * @param world the matrix to bind
  18746. */
  18747. bindOnlyWorldMatrix(world: Matrix): void;
  18748. /**
  18749. * Binds the given normal matrix to the active effect
  18750. *
  18751. * @param normalMatrix the matrix to bind
  18752. */
  18753. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18754. bind(world: Matrix, mesh?: Mesh): void;
  18755. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18756. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18757. }
  18758. }
  18759. declare module BABYLON {
  18760. /**
  18761. * Defines the options associated with the creation of a shader material.
  18762. */
  18763. interface IShaderMaterialOptions {
  18764. /**
  18765. * Does the material work in alpha blend mode
  18766. */
  18767. needAlphaBlending: boolean;
  18768. /**
  18769. * Does the material work in alpha test mode
  18770. */
  18771. needAlphaTesting: boolean;
  18772. /**
  18773. * The list of attribute names used in the shader
  18774. */
  18775. attributes: string[];
  18776. /**
  18777. * The list of unifrom names used in the shader
  18778. */
  18779. uniforms: string[];
  18780. /**
  18781. * The list of UBO names used in the shader
  18782. */
  18783. uniformBuffers: string[];
  18784. /**
  18785. * The list of sampler names used in the shader
  18786. */
  18787. samplers: string[];
  18788. /**
  18789. * The list of defines used in the shader
  18790. */
  18791. defines: string[];
  18792. }
  18793. /**
  18794. * 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.
  18795. *
  18796. * This returned material effects how the mesh will look based on the code in the shaders.
  18797. *
  18798. * @see http://doc.babylonjs.com/how_to/shader_material
  18799. */
  18800. class ShaderMaterial extends Material {
  18801. private _shaderPath;
  18802. private _options;
  18803. private _textures;
  18804. private _textureArrays;
  18805. private _floats;
  18806. private _ints;
  18807. private _floatsArrays;
  18808. private _colors3;
  18809. private _colors3Arrays;
  18810. private _colors4;
  18811. private _vectors2;
  18812. private _vectors3;
  18813. private _vectors4;
  18814. private _matrices;
  18815. private _matrices3x3;
  18816. private _matrices2x2;
  18817. private _vectors2Arrays;
  18818. private _vectors3Arrays;
  18819. private _cachedWorldViewMatrix;
  18820. private _renderId;
  18821. /**
  18822. * Instantiate a new shader material.
  18823. * 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.
  18824. * This returned material effects how the mesh will look based on the code in the shaders.
  18825. * @see http://doc.babylonjs.com/how_to/shader_material
  18826. * @param name Define the name of the material in the scene
  18827. * @param scene Define the scene the material belongs to
  18828. * @param shaderPath Defines the route to the shader code in one of three ways:
  18829. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18830. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18831. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18832. * @param options Define the options used to create the shader
  18833. */
  18834. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18835. /**
  18836. * Gets the current class name of the material e.g. "ShaderMaterial"
  18837. * Mainly use in serialization.
  18838. * @returns the class name
  18839. */
  18840. getClassName(): string;
  18841. /**
  18842. * Specifies if the material will require alpha blending
  18843. * @returns a boolean specifying if alpha blending is needed
  18844. */
  18845. needAlphaBlending(): boolean;
  18846. /**
  18847. * Specifies if this material should be rendered in alpha test mode
  18848. * @returns a boolean specifying if an alpha test is needed.
  18849. */
  18850. needAlphaTesting(): boolean;
  18851. private _checkUniform;
  18852. /**
  18853. * Set a texture in the shader.
  18854. * @param name Define the name of the uniform samplers as defined in the shader
  18855. * @param texture Define the texture to bind to this sampler
  18856. * @return the material itself allowing "fluent" like uniform updates
  18857. */
  18858. setTexture(name: string, texture: Texture): ShaderMaterial;
  18859. /**
  18860. * Set a texture array in the shader.
  18861. * @param name Define the name of the uniform sampler array as defined in the shader
  18862. * @param textures Define the list of textures to bind to this sampler
  18863. * @return the material itself allowing "fluent" like uniform updates
  18864. */
  18865. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18866. /**
  18867. * Set a float in the shader.
  18868. * @param name Define the name of the uniform as defined in the shader
  18869. * @param value Define the value to give to the uniform
  18870. * @return the material itself allowing "fluent" like uniform updates
  18871. */
  18872. setFloat(name: string, value: number): ShaderMaterial;
  18873. /**
  18874. * Set a int in the shader.
  18875. * @param name Define the name of the uniform as defined in the shader
  18876. * @param value Define the value to give to the uniform
  18877. * @return the material itself allowing "fluent" like uniform updates
  18878. */
  18879. setInt(name: string, value: number): ShaderMaterial;
  18880. /**
  18881. * Set an array of floats in the shader.
  18882. * @param name Define the name of the uniform as defined in the shader
  18883. * @param value Define the value to give to the uniform
  18884. * @return the material itself allowing "fluent" like uniform updates
  18885. */
  18886. setFloats(name: string, value: number[]): ShaderMaterial;
  18887. /**
  18888. * Set a vec3 in the shader from a Color3.
  18889. * @param name Define the name of the uniform as defined in the shader
  18890. * @param value Define the value to give to the uniform
  18891. * @return the material itself allowing "fluent" like uniform updates
  18892. */
  18893. setColor3(name: string, value: Color3): ShaderMaterial;
  18894. /**
  18895. * Set a vec3 array in the shader from a Color3 array.
  18896. * @param name Define the name of the uniform as defined in the shader
  18897. * @param value Define the value to give to the uniform
  18898. * @return the material itself allowing "fluent" like uniform updates
  18899. */
  18900. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18901. /**
  18902. * Set a vec4 in the shader from a Color4.
  18903. * @param name Define the name of the uniform as defined in the shader
  18904. * @param value Define the value to give to the uniform
  18905. * @return the material itself allowing "fluent" like uniform updates
  18906. */
  18907. setColor4(name: string, value: Color4): ShaderMaterial;
  18908. /**
  18909. * Set a vec2 in the shader from a Vector2.
  18910. * @param name Define the name of the uniform as defined in the shader
  18911. * @param value Define the value to give to the uniform
  18912. * @return the material itself allowing "fluent" like uniform updates
  18913. */
  18914. setVector2(name: string, value: Vector2): ShaderMaterial;
  18915. /**
  18916. * Set a vec3 in the shader from a Vector3.
  18917. * @param name Define the name of the uniform as defined in the shader
  18918. * @param value Define the value to give to the uniform
  18919. * @return the material itself allowing "fluent" like uniform updates
  18920. */
  18921. setVector3(name: string, value: Vector3): ShaderMaterial;
  18922. /**
  18923. * Set a vec4 in the shader from a Vector4.
  18924. * @param name Define the name of the uniform as defined in the shader
  18925. * @param value Define the value to give to the uniform
  18926. * @return the material itself allowing "fluent" like uniform updates
  18927. */
  18928. setVector4(name: string, value: Vector4): ShaderMaterial;
  18929. /**
  18930. * Set a mat4 in the shader from a Matrix.
  18931. * @param name Define the name of the uniform as defined in the shader
  18932. * @param value Define the value to give to the uniform
  18933. * @return the material itself allowing "fluent" like uniform updates
  18934. */
  18935. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18936. /**
  18937. * Set a mat3 in the shader from a Float32Array.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the material itself allowing "fluent" like uniform updates
  18941. */
  18942. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18943. /**
  18944. * Set a mat2 in the shader from a Float32Array.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the material itself allowing "fluent" like uniform updates
  18948. */
  18949. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18950. /**
  18951. * Set a vec2 array in the shader from a number array.
  18952. * @param name Define the name of the uniform as defined in the shader
  18953. * @param value Define the value to give to the uniform
  18954. * @return the material itself allowing "fluent" like uniform updates
  18955. */
  18956. setArray2(name: string, value: number[]): ShaderMaterial;
  18957. /**
  18958. * Set a vec3 array in the shader from a number array.
  18959. * @param name Define the name of the uniform as defined in the shader
  18960. * @param value Define the value to give to the uniform
  18961. * @return the material itself allowing "fluent" like uniform updates
  18962. */
  18963. setArray3(name: string, value: number[]): ShaderMaterial;
  18964. private _checkCache;
  18965. /**
  18966. * Checks if the material is ready to render the requested mesh
  18967. * @param mesh Define the mesh to render
  18968. * @param useInstances Define whether or not the material is used with instances
  18969. * @returns true if ready, otherwise false
  18970. */
  18971. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18972. /**
  18973. * Binds the world matrix to the material
  18974. * @param world defines the world transformation matrix
  18975. */
  18976. bindOnlyWorldMatrix(world: Matrix): void;
  18977. /**
  18978. * Binds the material to the mesh
  18979. * @param world defines the world transformation matrix
  18980. * @param mesh defines the mesh to bind the material to
  18981. */
  18982. bind(world: Matrix, mesh?: Mesh): void;
  18983. /**
  18984. * Gets the active textures from the material
  18985. * @returns an array of textures
  18986. */
  18987. getActiveTextures(): BaseTexture[];
  18988. /**
  18989. * Specifies if the material uses a texture
  18990. * @param texture defines the texture to check against the material
  18991. * @returns a boolean specifying if the material uses the texture
  18992. */
  18993. hasTexture(texture: BaseTexture): boolean;
  18994. /**
  18995. * Makes a duplicate of the material, and gives it a new name
  18996. * @param name defines the new name for the duplicated material
  18997. * @returns the cloned material
  18998. */
  18999. clone(name: string): ShaderMaterial;
  19000. /**
  19001. * Disposes the material
  19002. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19003. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19004. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19005. */
  19006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19007. /**
  19008. * Serializes this material in a JSON representation
  19009. * @returns the serialized material object
  19010. */
  19011. serialize(): any;
  19012. /**
  19013. * Creates a shader material from parsed shader material data
  19014. * @param source defines the JSON represnetation of the material
  19015. * @param scene defines the hosting scene
  19016. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19017. * @returns a new material
  19018. */
  19019. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19020. }
  19021. }
  19022. declare module BABYLON {
  19023. /** @hidden */
  19024. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19025. MAINUV1: boolean;
  19026. MAINUV2: boolean;
  19027. DIFFUSE: boolean;
  19028. DIFFUSEDIRECTUV: number;
  19029. AMBIENT: boolean;
  19030. AMBIENTDIRECTUV: number;
  19031. OPACITY: boolean;
  19032. OPACITYDIRECTUV: number;
  19033. OPACITYRGB: boolean;
  19034. REFLECTION: boolean;
  19035. EMISSIVE: boolean;
  19036. EMISSIVEDIRECTUV: number;
  19037. SPECULAR: boolean;
  19038. SPECULARDIRECTUV: number;
  19039. BUMP: boolean;
  19040. BUMPDIRECTUV: number;
  19041. PARALLAX: boolean;
  19042. PARALLAXOCCLUSION: boolean;
  19043. SPECULAROVERALPHA: boolean;
  19044. CLIPPLANE: boolean;
  19045. CLIPPLANE2: boolean;
  19046. CLIPPLANE3: boolean;
  19047. CLIPPLANE4: boolean;
  19048. ALPHATEST: boolean;
  19049. DEPTHPREPASS: boolean;
  19050. ALPHAFROMDIFFUSE: boolean;
  19051. POINTSIZE: boolean;
  19052. FOG: boolean;
  19053. SPECULARTERM: boolean;
  19054. DIFFUSEFRESNEL: boolean;
  19055. OPACITYFRESNEL: boolean;
  19056. REFLECTIONFRESNEL: boolean;
  19057. REFRACTIONFRESNEL: boolean;
  19058. EMISSIVEFRESNEL: boolean;
  19059. FRESNEL: boolean;
  19060. NORMAL: boolean;
  19061. UV1: boolean;
  19062. UV2: boolean;
  19063. VERTEXCOLOR: boolean;
  19064. VERTEXALPHA: boolean;
  19065. NUM_BONE_INFLUENCERS: number;
  19066. BonesPerMesh: number;
  19067. BONETEXTURE: boolean;
  19068. INSTANCES: boolean;
  19069. GLOSSINESS: boolean;
  19070. ROUGHNESS: boolean;
  19071. EMISSIVEASILLUMINATION: boolean;
  19072. LINKEMISSIVEWITHDIFFUSE: boolean;
  19073. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19074. LIGHTMAP: boolean;
  19075. LIGHTMAPDIRECTUV: number;
  19076. OBJECTSPACE_NORMALMAP: boolean;
  19077. USELIGHTMAPASSHADOWMAP: boolean;
  19078. REFLECTIONMAP_3D: boolean;
  19079. REFLECTIONMAP_SPHERICAL: boolean;
  19080. REFLECTIONMAP_PLANAR: boolean;
  19081. REFLECTIONMAP_CUBIC: boolean;
  19082. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19083. REFLECTIONMAP_PROJECTION: boolean;
  19084. REFLECTIONMAP_SKYBOX: boolean;
  19085. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19086. REFLECTIONMAP_EXPLICIT: boolean;
  19087. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19088. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19089. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19090. INVERTCUBICMAP: boolean;
  19091. LOGARITHMICDEPTH: boolean;
  19092. REFRACTION: boolean;
  19093. REFRACTIONMAP_3D: boolean;
  19094. REFLECTIONOVERALPHA: boolean;
  19095. TWOSIDEDLIGHTING: boolean;
  19096. SHADOWFLOAT: boolean;
  19097. MORPHTARGETS: boolean;
  19098. MORPHTARGETS_NORMAL: boolean;
  19099. MORPHTARGETS_TANGENT: boolean;
  19100. NUM_MORPH_INFLUENCERS: number;
  19101. NONUNIFORMSCALING: boolean;
  19102. PREMULTIPLYALPHA: boolean;
  19103. IMAGEPROCESSING: boolean;
  19104. VIGNETTE: boolean;
  19105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19106. VIGNETTEBLENDMODEOPAQUE: boolean;
  19107. TONEMAPPING: boolean;
  19108. TONEMAPPING_ACES: boolean;
  19109. CONTRAST: boolean;
  19110. COLORCURVES: boolean;
  19111. COLORGRADING: boolean;
  19112. COLORGRADING3D: boolean;
  19113. SAMPLER3DGREENDEPTH: boolean;
  19114. SAMPLER3DBGRMAP: boolean;
  19115. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19116. /**
  19117. * If the reflection texture on this material is in linear color space
  19118. * @hidden
  19119. */
  19120. IS_REFLECTION_LINEAR: boolean;
  19121. /**
  19122. * If the refraction texture on this material is in linear color space
  19123. * @hidden
  19124. */
  19125. IS_REFRACTION_LINEAR: boolean;
  19126. EXPOSURE: boolean;
  19127. constructor();
  19128. setReflectionMode(modeToEnable: string): void;
  19129. }
  19130. /**
  19131. * This is the default material used in Babylon. It is the best trade off between quality
  19132. * and performances.
  19133. * @see http://doc.babylonjs.com/babylon101/materials
  19134. */
  19135. class StandardMaterial extends PushMaterial {
  19136. private _diffuseTexture;
  19137. /**
  19138. * The basic texture of the material as viewed under a light.
  19139. */
  19140. diffuseTexture: Nullable<BaseTexture>;
  19141. private _ambientTexture;
  19142. /**
  19143. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19144. */
  19145. ambientTexture: Nullable<BaseTexture>;
  19146. private _opacityTexture;
  19147. /**
  19148. * Define the transparency of the material from a texture.
  19149. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19150. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19151. */
  19152. opacityTexture: Nullable<BaseTexture>;
  19153. private _reflectionTexture;
  19154. /**
  19155. * Define the texture used to display the reflection.
  19156. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19157. */
  19158. reflectionTexture: Nullable<BaseTexture>;
  19159. private _emissiveTexture;
  19160. /**
  19161. * Define texture of the material as if self lit.
  19162. * This will be mixed in the final result even in the absence of light.
  19163. */
  19164. emissiveTexture: Nullable<BaseTexture>;
  19165. private _specularTexture;
  19166. /**
  19167. * Define how the color and intensity of the highlight given by the light in the material.
  19168. */
  19169. specularTexture: Nullable<BaseTexture>;
  19170. private _bumpTexture;
  19171. /**
  19172. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19173. * 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.
  19174. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19175. */
  19176. bumpTexture: Nullable<BaseTexture>;
  19177. private _lightmapTexture;
  19178. /**
  19179. * Complex lighting can be computationally expensive to compute at runtime.
  19180. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19181. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19182. */
  19183. lightmapTexture: Nullable<BaseTexture>;
  19184. private _refractionTexture;
  19185. /**
  19186. * Define the texture used to display the refraction.
  19187. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19188. */
  19189. refractionTexture: Nullable<BaseTexture>;
  19190. /**
  19191. * The color of the material lit by the environmental background lighting.
  19192. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19193. */
  19194. ambientColor: Color3;
  19195. /**
  19196. * The basic color of the material as viewed under a light.
  19197. */
  19198. diffuseColor: Color3;
  19199. /**
  19200. * Define how the color and intensity of the highlight given by the light in the material.
  19201. */
  19202. specularColor: Color3;
  19203. /**
  19204. * Define the color of the material as if self lit.
  19205. * This will be mixed in the final result even in the absence of light.
  19206. */
  19207. emissiveColor: Color3;
  19208. /**
  19209. * Defines how sharp are the highlights in the material.
  19210. * The bigger the value the sharper giving a more glossy feeling to the result.
  19211. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19212. */
  19213. specularPower: number;
  19214. private _useAlphaFromDiffuseTexture;
  19215. /**
  19216. * Does the transparency come from the diffuse texture alpha channel.
  19217. */
  19218. useAlphaFromDiffuseTexture: boolean;
  19219. private _useEmissiveAsIllumination;
  19220. /**
  19221. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19222. */
  19223. useEmissiveAsIllumination: boolean;
  19224. private _linkEmissiveWithDiffuse;
  19225. /**
  19226. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19227. * the emissive level when the final color is close to one.
  19228. */
  19229. linkEmissiveWithDiffuse: boolean;
  19230. private _useSpecularOverAlpha;
  19231. /**
  19232. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19233. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19234. */
  19235. useSpecularOverAlpha: boolean;
  19236. private _useReflectionOverAlpha;
  19237. /**
  19238. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19239. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19240. */
  19241. useReflectionOverAlpha: boolean;
  19242. private _disableLighting;
  19243. /**
  19244. * Does lights from the scene impacts this material.
  19245. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19246. */
  19247. disableLighting: boolean;
  19248. private _useObjectSpaceNormalMap;
  19249. /**
  19250. * Allows using an object space normal map (instead of tangent space).
  19251. */
  19252. useObjectSpaceNormalMap: boolean;
  19253. private _useParallax;
  19254. /**
  19255. * Is parallax enabled or not.
  19256. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19257. */
  19258. useParallax: boolean;
  19259. private _useParallaxOcclusion;
  19260. /**
  19261. * Is parallax occlusion enabled or not.
  19262. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19263. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19264. */
  19265. useParallaxOcclusion: boolean;
  19266. /**
  19267. * 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.
  19268. */
  19269. parallaxScaleBias: number;
  19270. private _roughness;
  19271. /**
  19272. * Helps to define how blurry the reflections should appears in the material.
  19273. */
  19274. roughness: number;
  19275. /**
  19276. * In case of refraction, define the value of the indice of refraction.
  19277. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19278. */
  19279. indexOfRefraction: number;
  19280. /**
  19281. * Invert the refraction texture alongside the y axis.
  19282. * It can be usefull with procedural textures or probe for instance.
  19283. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19284. */
  19285. invertRefractionY: boolean;
  19286. /**
  19287. * Defines the alpha limits in alpha test mode.
  19288. */
  19289. alphaCutOff: number;
  19290. private _useLightmapAsShadowmap;
  19291. /**
  19292. * In case of light mapping, define whether the map contains light or shadow informations.
  19293. */
  19294. useLightmapAsShadowmap: boolean;
  19295. private _diffuseFresnelParameters;
  19296. /**
  19297. * Define the diffuse fresnel parameters of the material.
  19298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19299. */
  19300. diffuseFresnelParameters: FresnelParameters;
  19301. private _opacityFresnelParameters;
  19302. /**
  19303. * Define the opacity fresnel parameters of the material.
  19304. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19305. */
  19306. opacityFresnelParameters: FresnelParameters;
  19307. private _reflectionFresnelParameters;
  19308. /**
  19309. * Define the reflection fresnel parameters of the material.
  19310. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19311. */
  19312. reflectionFresnelParameters: FresnelParameters;
  19313. private _refractionFresnelParameters;
  19314. /**
  19315. * Define the refraction fresnel parameters of the material.
  19316. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19317. */
  19318. refractionFresnelParameters: FresnelParameters;
  19319. private _emissiveFresnelParameters;
  19320. /**
  19321. * Define the emissive fresnel parameters of the material.
  19322. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19323. */
  19324. emissiveFresnelParameters: FresnelParameters;
  19325. private _useReflectionFresnelFromSpecular;
  19326. /**
  19327. * If true automatically deducts the fresnels values from the material specularity.
  19328. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19329. */
  19330. useReflectionFresnelFromSpecular: boolean;
  19331. private _useGlossinessFromSpecularMapAlpha;
  19332. /**
  19333. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19334. */
  19335. useGlossinessFromSpecularMapAlpha: boolean;
  19336. private _maxSimultaneousLights;
  19337. /**
  19338. * Defines the maximum number of lights that can be used in the material
  19339. */
  19340. maxSimultaneousLights: number;
  19341. private _invertNormalMapX;
  19342. /**
  19343. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19344. */
  19345. invertNormalMapX: boolean;
  19346. private _invertNormalMapY;
  19347. /**
  19348. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19349. */
  19350. invertNormalMapY: boolean;
  19351. private _twoSidedLighting;
  19352. /**
  19353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19354. */
  19355. twoSidedLighting: boolean;
  19356. /**
  19357. * Default configuration related to image processing available in the standard Material.
  19358. */
  19359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19360. /**
  19361. * Gets the image processing configuration used either in this material.
  19362. */
  19363. /**
  19364. * Sets the Default image processing configuration used either in the this material.
  19365. *
  19366. * If sets to null, the scene one is in use.
  19367. */
  19368. imageProcessingConfiguration: ImageProcessingConfiguration;
  19369. /**
  19370. * Keep track of the image processing observer to allow dispose and replace.
  19371. */
  19372. private _imageProcessingObserver;
  19373. /**
  19374. * Attaches a new image processing configuration to the Standard Material.
  19375. * @param configuration
  19376. */
  19377. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19378. /**
  19379. * Gets wether the color curves effect is enabled.
  19380. */
  19381. /**
  19382. * Sets wether the color curves effect is enabled.
  19383. */
  19384. cameraColorCurvesEnabled: boolean;
  19385. /**
  19386. * Gets wether the color grading effect is enabled.
  19387. */
  19388. /**
  19389. * Gets wether the color grading effect is enabled.
  19390. */
  19391. cameraColorGradingEnabled: boolean;
  19392. /**
  19393. * Gets wether tonemapping is enabled or not.
  19394. */
  19395. /**
  19396. * Sets wether tonemapping is enabled or not
  19397. */
  19398. cameraToneMappingEnabled: boolean;
  19399. /**
  19400. * The camera exposure used on this material.
  19401. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19402. * This corresponds to a photographic exposure.
  19403. */
  19404. /**
  19405. * The camera exposure used on this material.
  19406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19407. * This corresponds to a photographic exposure.
  19408. */
  19409. cameraExposure: number;
  19410. /**
  19411. * Gets The camera contrast used on this material.
  19412. */
  19413. /**
  19414. * Sets The camera contrast used on this material.
  19415. */
  19416. cameraContrast: number;
  19417. /**
  19418. * Gets the Color Grading 2D Lookup Texture.
  19419. */
  19420. /**
  19421. * Sets the Color Grading 2D Lookup Texture.
  19422. */
  19423. cameraColorGradingTexture: Nullable<BaseTexture>;
  19424. /**
  19425. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19426. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19427. * 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;
  19428. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19429. */
  19430. /**
  19431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19433. * 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;
  19434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19435. */
  19436. cameraColorCurves: Nullable<ColorCurves>;
  19437. /**
  19438. * Custom callback helping to override the default shader used in the material.
  19439. */
  19440. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19441. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19442. protected _worldViewProjectionMatrix: Matrix;
  19443. protected _globalAmbientColor: Color3;
  19444. protected _useLogarithmicDepth: boolean;
  19445. /**
  19446. * Instantiates a new standard material.
  19447. * This is the default material used in Babylon. It is the best trade off between quality
  19448. * and performances.
  19449. * @see http://doc.babylonjs.com/babylon101/materials
  19450. * @param name Define the name of the material in the scene
  19451. * @param scene Define the scene the material belong to
  19452. */
  19453. constructor(name: string, scene: Scene);
  19454. /**
  19455. * Gets a boolean indicating that current material needs to register RTT
  19456. */
  19457. readonly hasRenderTargetTextures: boolean;
  19458. /**
  19459. * Gets the current class name of the material e.g. "StandardMaterial"
  19460. * Mainly use in serialization.
  19461. * @returns the class name
  19462. */
  19463. getClassName(): string;
  19464. /**
  19465. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19466. * You can try switching to logarithmic depth.
  19467. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19468. */
  19469. useLogarithmicDepth: boolean;
  19470. /**
  19471. * Specifies if the material will require alpha blending
  19472. * @returns a boolean specifying if alpha blending is needed
  19473. */
  19474. needAlphaBlending(): boolean;
  19475. /**
  19476. * Specifies if this material should be rendered in alpha test mode
  19477. * @returns a boolean specifying if an alpha test is needed.
  19478. */
  19479. needAlphaTesting(): boolean;
  19480. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19481. /**
  19482. * Get the texture used for alpha test purpose.
  19483. * @returns the diffuse texture in case of the standard material.
  19484. */
  19485. getAlphaTestTexture(): Nullable<BaseTexture>;
  19486. /**
  19487. * Get if the submesh is ready to be used and all its information available.
  19488. * Child classes can use it to update shaders
  19489. * @param mesh defines the mesh to check
  19490. * @param subMesh defines which submesh to check
  19491. * @param useInstances specifies that instances should be used
  19492. * @returns a boolean indicating that the submesh is ready or not
  19493. */
  19494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19495. /**
  19496. * Builds the material UBO layouts.
  19497. * Used internally during the effect preparation.
  19498. */
  19499. buildUniformLayout(): void;
  19500. /**
  19501. * Unbinds the material from the mesh
  19502. */
  19503. unbind(): void;
  19504. /**
  19505. * Binds the submesh to this material by preparing the effect and shader to draw
  19506. * @param world defines the world transformation matrix
  19507. * @param mesh defines the mesh containing the submesh
  19508. * @param subMesh defines the submesh to bind the material to
  19509. */
  19510. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19511. /**
  19512. * Get the list of animatables in the material.
  19513. * @returns the list of animatables object used in the material
  19514. */
  19515. getAnimatables(): IAnimatable[];
  19516. /**
  19517. * Gets the active textures from the material
  19518. * @returns an array of textures
  19519. */
  19520. getActiveTextures(): BaseTexture[];
  19521. /**
  19522. * Specifies if the material uses a texture
  19523. * @param texture defines the texture to check against the material
  19524. * @returns a boolean specifying if the material uses the texture
  19525. */
  19526. hasTexture(texture: BaseTexture): boolean;
  19527. /**
  19528. * Disposes the material
  19529. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19530. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19531. */
  19532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19533. /**
  19534. * Makes a duplicate of the material, and gives it a new name
  19535. * @param name defines the new name for the duplicated material
  19536. * @returns the cloned material
  19537. */
  19538. clone(name: string): StandardMaterial;
  19539. /**
  19540. * Serializes this material in a JSON representation
  19541. * @returns the serialized material object
  19542. */
  19543. serialize(): any;
  19544. /**
  19545. * Creates a standard material from parsed material data
  19546. * @param source defines the JSON represnetation of the material
  19547. * @param scene defines the hosting scene
  19548. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19549. * @returns a new material
  19550. */
  19551. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19552. private static _DiffuseTextureEnabled;
  19553. /**
  19554. * Are diffuse textures enabled in the application.
  19555. */
  19556. static DiffuseTextureEnabled: boolean;
  19557. private static _AmbientTextureEnabled;
  19558. /**
  19559. * Are ambient textures enabled in the application.
  19560. */
  19561. static AmbientTextureEnabled: boolean;
  19562. private static _OpacityTextureEnabled;
  19563. /**
  19564. * Are opacity textures enabled in the application.
  19565. */
  19566. static OpacityTextureEnabled: boolean;
  19567. private static _ReflectionTextureEnabled;
  19568. /**
  19569. * Are reflection textures enabled in the application.
  19570. */
  19571. static ReflectionTextureEnabled: boolean;
  19572. private static _EmissiveTextureEnabled;
  19573. /**
  19574. * Are emissive textures enabled in the application.
  19575. */
  19576. static EmissiveTextureEnabled: boolean;
  19577. private static _SpecularTextureEnabled;
  19578. /**
  19579. * Are specular textures enabled in the application.
  19580. */
  19581. static SpecularTextureEnabled: boolean;
  19582. private static _BumpTextureEnabled;
  19583. /**
  19584. * Are bump textures enabled in the application.
  19585. */
  19586. static BumpTextureEnabled: boolean;
  19587. private static _LightmapTextureEnabled;
  19588. /**
  19589. * Are lightmap textures enabled in the application.
  19590. */
  19591. static LightmapTextureEnabled: boolean;
  19592. private static _RefractionTextureEnabled;
  19593. /**
  19594. * Are refraction textures enabled in the application.
  19595. */
  19596. static RefractionTextureEnabled: boolean;
  19597. private static _ColorGradingTextureEnabled;
  19598. /**
  19599. * Are color grading textures enabled in the application.
  19600. */
  19601. static ColorGradingTextureEnabled: boolean;
  19602. private static _FresnelEnabled;
  19603. /**
  19604. * Are fresnels enabled in the application.
  19605. */
  19606. static FresnelEnabled: boolean;
  19607. }
  19608. }
  19609. declare module BABYLON {
  19610. /**
  19611. * Uniform buffer objects.
  19612. *
  19613. * Handles blocks of uniform on the GPU.
  19614. *
  19615. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19616. *
  19617. * For more information, please refer to :
  19618. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19619. */
  19620. class UniformBuffer {
  19621. private _engine;
  19622. private _buffer;
  19623. private _data;
  19624. private _bufferData;
  19625. private _dynamic?;
  19626. private _uniformLocations;
  19627. private _uniformSizes;
  19628. private _uniformLocationPointer;
  19629. private _needSync;
  19630. private _noUBO;
  19631. private _currentEffect;
  19632. private static _MAX_UNIFORM_SIZE;
  19633. private static _tempBuffer;
  19634. /**
  19635. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19636. * This is dynamic to allow compat with webgl 1 and 2.
  19637. * You will need to pass the name of the uniform as well as the value.
  19638. */
  19639. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19640. /**
  19641. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19642. * This is dynamic to allow compat with webgl 1 and 2.
  19643. * You will need to pass the name of the uniform as well as the value.
  19644. */
  19645. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19646. /**
  19647. * Lambda to Update a single float in a uniform buffer.
  19648. * This is dynamic to allow compat with webgl 1 and 2.
  19649. * You will need to pass the name of the uniform as well as the value.
  19650. */
  19651. updateFloat: (name: string, x: number) => void;
  19652. /**
  19653. * Lambda to Update a vec2 of float in a uniform buffer.
  19654. * This is dynamic to allow compat with webgl 1 and 2.
  19655. * You will need to pass the name of the uniform as well as the value.
  19656. */
  19657. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19658. /**
  19659. * Lambda to Update a vec3 of float in a uniform buffer.
  19660. * This is dynamic to allow compat with webgl 1 and 2.
  19661. * You will need to pass the name of the uniform as well as the value.
  19662. */
  19663. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19664. /**
  19665. * Lambda to Update a vec4 of float in a uniform buffer.
  19666. * This is dynamic to allow compat with webgl 1 and 2.
  19667. * You will need to pass the name of the uniform as well as the value.
  19668. */
  19669. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19670. /**
  19671. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19672. * This is dynamic to allow compat with webgl 1 and 2.
  19673. * You will need to pass the name of the uniform as well as the value.
  19674. */
  19675. updateMatrix: (name: string, mat: Matrix) => void;
  19676. /**
  19677. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19678. * This is dynamic to allow compat with webgl 1 and 2.
  19679. * You will need to pass the name of the uniform as well as the value.
  19680. */
  19681. updateVector3: (name: string, vector: Vector3) => void;
  19682. /**
  19683. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19684. * This is dynamic to allow compat with webgl 1 and 2.
  19685. * You will need to pass the name of the uniform as well as the value.
  19686. */
  19687. updateVector4: (name: string, vector: Vector4) => void;
  19688. /**
  19689. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19690. * This is dynamic to allow compat with webgl 1 and 2.
  19691. * You will need to pass the name of the uniform as well as the value.
  19692. */
  19693. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19694. /**
  19695. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19696. * This is dynamic to allow compat with webgl 1 and 2.
  19697. * You will need to pass the name of the uniform as well as the value.
  19698. */
  19699. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19700. /**
  19701. * Instantiates a new Uniform buffer objects.
  19702. *
  19703. * Handles blocks of uniform on the GPU.
  19704. *
  19705. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19706. *
  19707. * For more information, please refer to :
  19708. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19709. * @param engine Define the engine the buffer is associated with
  19710. * @param data Define the data contained in the buffer
  19711. * @param dynamic Define if the buffer is updatable
  19712. */
  19713. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19714. /**
  19715. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19716. * or just falling back on setUniformXXX calls.
  19717. */
  19718. readonly useUbo: boolean;
  19719. /**
  19720. * Indicates if the WebGL underlying uniform buffer is in sync
  19721. * with the javascript cache data.
  19722. */
  19723. readonly isSync: boolean;
  19724. /**
  19725. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19726. * Also, a dynamic UniformBuffer will disable cache verification and always
  19727. * update the underlying WebGL uniform buffer to the GPU.
  19728. * @returns if Dynamic, otherwise false
  19729. */
  19730. isDynamic(): boolean;
  19731. /**
  19732. * The data cache on JS side.
  19733. * @returns the underlying data as a float array
  19734. */
  19735. getData(): Float32Array;
  19736. /**
  19737. * The underlying WebGL Uniform buffer.
  19738. * @returns the webgl buffer
  19739. */
  19740. getBuffer(): Nullable<WebGLBuffer>;
  19741. /**
  19742. * std140 layout specifies how to align data within an UBO structure.
  19743. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19744. * for specs.
  19745. */
  19746. private _fillAlignment;
  19747. /**
  19748. * Adds an uniform in the buffer.
  19749. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19750. * for the layout to be correct !
  19751. * @param name Name of the uniform, as used in the uniform block in the shader.
  19752. * @param size Data size, or data directly.
  19753. */
  19754. addUniform(name: string, size: number | number[]): void;
  19755. /**
  19756. * Adds a Matrix 4x4 to the uniform buffer.
  19757. * @param name Name of the uniform, as used in the uniform block in the shader.
  19758. * @param mat A 4x4 matrix.
  19759. */
  19760. addMatrix(name: string, mat: Matrix): void;
  19761. /**
  19762. * Adds a vec2 to the uniform buffer.
  19763. * @param name Name of the uniform, as used in the uniform block in the shader.
  19764. * @param x Define the x component value of the vec2
  19765. * @param y Define the y component value of the vec2
  19766. */
  19767. addFloat2(name: string, x: number, y: number): void;
  19768. /**
  19769. * Adds a vec3 to the uniform buffer.
  19770. * @param name Name of the uniform, as used in the uniform block in the shader.
  19771. * @param x Define the x component value of the vec3
  19772. * @param y Define the y component value of the vec3
  19773. * @param z Define the z component value of the vec3
  19774. */
  19775. addFloat3(name: string, x: number, y: number, z: number): void;
  19776. /**
  19777. * Adds a vec3 to the uniform buffer.
  19778. * @param name Name of the uniform, as used in the uniform block in the shader.
  19779. * @param color Define the vec3 from a Color
  19780. */
  19781. addColor3(name: string, color: Color3): void;
  19782. /**
  19783. * Adds a vec4 to the uniform buffer.
  19784. * @param name Name of the uniform, as used in the uniform block in the shader.
  19785. * @param color Define the rgb components from a Color
  19786. * @param alpha Define the a component of the vec4
  19787. */
  19788. addColor4(name: string, color: Color3, alpha: number): void;
  19789. /**
  19790. * Adds a vec3 to the uniform buffer.
  19791. * @param name Name of the uniform, as used in the uniform block in the shader.
  19792. * @param vector Define the vec3 components from a Vector
  19793. */
  19794. addVector3(name: string, vector: Vector3): void;
  19795. /**
  19796. * Adds a Matrix 3x3 to the uniform buffer.
  19797. * @param name Name of the uniform, as used in the uniform block in the shader.
  19798. */
  19799. addMatrix3x3(name: string): void;
  19800. /**
  19801. * Adds a Matrix 2x2 to the uniform buffer.
  19802. * @param name Name of the uniform, as used in the uniform block in the shader.
  19803. */
  19804. addMatrix2x2(name: string): void;
  19805. /**
  19806. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19807. */
  19808. create(): void;
  19809. /** @hidden */
  19810. _rebuild(): void;
  19811. /**
  19812. * Updates the WebGL Uniform Buffer on the GPU.
  19813. * If the `dynamic` flag is set to true, no cache comparison is done.
  19814. * Otherwise, the buffer will be updated only if the cache differs.
  19815. */
  19816. update(): void;
  19817. /**
  19818. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19819. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19820. * @param data Define the flattened data
  19821. * @param size Define the size of the data.
  19822. */
  19823. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19824. private _updateMatrix3x3ForUniform;
  19825. private _updateMatrix3x3ForEffect;
  19826. private _updateMatrix2x2ForEffect;
  19827. private _updateMatrix2x2ForUniform;
  19828. private _updateFloatForEffect;
  19829. private _updateFloatForUniform;
  19830. private _updateFloat2ForEffect;
  19831. private _updateFloat2ForUniform;
  19832. private _updateFloat3ForEffect;
  19833. private _updateFloat3ForUniform;
  19834. private _updateFloat4ForEffect;
  19835. private _updateFloat4ForUniform;
  19836. private _updateMatrixForEffect;
  19837. private _updateMatrixForUniform;
  19838. private _updateVector3ForEffect;
  19839. private _updateVector3ForUniform;
  19840. private _updateVector4ForEffect;
  19841. private _updateVector4ForUniform;
  19842. private _updateColor3ForEffect;
  19843. private _updateColor3ForUniform;
  19844. private _updateColor4ForEffect;
  19845. private _updateColor4ForUniform;
  19846. /**
  19847. * Sets a sampler uniform on the effect.
  19848. * @param name Define the name of the sampler.
  19849. * @param texture Define the texture to set in the sampler
  19850. */
  19851. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19852. /**
  19853. * Directly updates the value of the uniform in the cache AND on the GPU.
  19854. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19855. * @param data Define the flattened data
  19856. */
  19857. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19858. /**
  19859. * Binds this uniform buffer to an effect.
  19860. * @param effect Define the effect to bind the buffer to
  19861. * @param name Name of the uniform block in the shader.
  19862. */
  19863. bindToEffect(effect: Effect, name: string): void;
  19864. /**
  19865. * Disposes the uniform buffer.
  19866. */
  19867. dispose(): void;
  19868. }
  19869. }
  19870. declare module BABYLON {
  19871. /**
  19872. * Scalar computation library
  19873. */
  19874. class Scalar {
  19875. /**
  19876. * Two pi constants convenient for computation.
  19877. */
  19878. static TwoPi: number;
  19879. /**
  19880. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19881. * @param a number
  19882. * @param b number
  19883. * @param epsilon (default = 1.401298E-45)
  19884. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19885. */
  19886. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19887. /**
  19888. * Returns a string : the upper case translation of the number i to hexadecimal.
  19889. * @param i number
  19890. * @returns the upper case translation of the number i to hexadecimal.
  19891. */
  19892. static ToHex(i: number): string;
  19893. /**
  19894. * Returns -1 if value is negative and +1 is value is positive.
  19895. * @param value the value
  19896. * @returns the value itself if it's equal to zero.
  19897. */
  19898. static Sign(value: number): number;
  19899. /**
  19900. * Returns the value itself if it's between min and max.
  19901. * Returns min if the value is lower than min.
  19902. * Returns max if the value is greater than max.
  19903. * @param value the value to clmap
  19904. * @param min the min value to clamp to (default: 0)
  19905. * @param max the max value to clamp to (default: 1)
  19906. * @returns the clamped value
  19907. */
  19908. static Clamp(value: number, min?: number, max?: number): number;
  19909. /**
  19910. * the log2 of value.
  19911. * @param value the value to compute log2 of
  19912. * @returns the log2 of value.
  19913. */
  19914. static Log2(value: number): number;
  19915. /**
  19916. * Loops the value, so that it is never larger than length and never smaller than 0.
  19917. *
  19918. * This is similar to the modulo operator but it works with floating point numbers.
  19919. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19920. * With t = 5 and length = 2.5, the result would be 0.0.
  19921. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19922. * @param value the value
  19923. * @param length the length
  19924. * @returns the looped value
  19925. */
  19926. static Repeat(value: number, length: number): number;
  19927. /**
  19928. * Normalize the value between 0.0 and 1.0 using min and max values
  19929. * @param value value to normalize
  19930. * @param min max to normalize between
  19931. * @param max min to normalize between
  19932. * @returns the normalized value
  19933. */
  19934. static Normalize(value: number, min: number, max: number): number;
  19935. /**
  19936. * Denormalize the value from 0.0 and 1.0 using min and max values
  19937. * @param normalized value to denormalize
  19938. * @param min max to denormalize between
  19939. * @param max min to denormalize between
  19940. * @returns the denormalized value
  19941. */
  19942. static Denormalize(normalized: number, min: number, max: number): number;
  19943. /**
  19944. * Calculates the shortest difference between two given angles given in degrees.
  19945. * @param current current angle in degrees
  19946. * @param target target angle in degrees
  19947. * @returns the delta
  19948. */
  19949. static DeltaAngle(current: number, target: number): number;
  19950. /**
  19951. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19952. * @param tx value
  19953. * @param length length
  19954. * @returns The returned value will move back and forth between 0 and length
  19955. */
  19956. static PingPong(tx: number, length: number): number;
  19957. /**
  19958. * Interpolates between min and max with smoothing at the limits.
  19959. *
  19960. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19961. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19962. * @param from from
  19963. * @param to to
  19964. * @param tx value
  19965. * @returns the smooth stepped value
  19966. */
  19967. static SmoothStep(from: number, to: number, tx: number): number;
  19968. /**
  19969. * Moves a value current towards target.
  19970. *
  19971. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19972. * Negative values of maxDelta pushes the value away from target.
  19973. * @param current current value
  19974. * @param target target value
  19975. * @param maxDelta max distance to move
  19976. * @returns resulting value
  19977. */
  19978. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19979. /**
  19980. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19981. *
  19982. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19983. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19984. * @param current current value
  19985. * @param target target value
  19986. * @param maxDelta max distance to move
  19987. * @returns resulting angle
  19988. */
  19989. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19990. /**
  19991. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19992. * @param start start value
  19993. * @param end target value
  19994. * @param amount amount to lerp between
  19995. * @returns the lerped value
  19996. */
  19997. static Lerp(start: number, end: number, amount: number): number;
  19998. /**
  19999. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20000. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20001. * @param start start value
  20002. * @param end target value
  20003. * @param amount amount to lerp between
  20004. * @returns the lerped value
  20005. */
  20006. static LerpAngle(start: number, end: number, amount: number): number;
  20007. /**
  20008. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20009. * @param a start value
  20010. * @param b target value
  20011. * @param value value between a and b
  20012. * @returns the inverseLerp value
  20013. */
  20014. static InverseLerp(a: number, b: number, value: number): number;
  20015. /**
  20016. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20017. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20018. * @param value1 spline value
  20019. * @param tangent1 spline value
  20020. * @param value2 spline value
  20021. * @param tangent2 spline value
  20022. * @param amount input value
  20023. * @returns hermite result
  20024. */
  20025. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20026. /**
  20027. * Returns a random float number between and min and max values
  20028. * @param min min value of random
  20029. * @param max max value of random
  20030. * @returns random value
  20031. */
  20032. static RandomRange(min: number, max: number): number;
  20033. /**
  20034. * This function returns percentage of a number in a given range.
  20035. *
  20036. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20037. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20038. * @param number to convert to percentage
  20039. * @param min min range
  20040. * @param max max range
  20041. * @returns the percentage
  20042. */
  20043. static RangeToPercent(number: number, min: number, max: number): number;
  20044. /**
  20045. * This function returns number that corresponds to the percentage in a given range.
  20046. *
  20047. * PercentToRange(0.34,0,100) will return 34.
  20048. * @param percent to convert to number
  20049. * @param min min range
  20050. * @param max max range
  20051. * @returns the number
  20052. */
  20053. static PercentToRange(percent: number, min: number, max: number): number;
  20054. /**
  20055. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20056. * @param angle The angle to normalize in radian.
  20057. * @return The converted angle.
  20058. */
  20059. static NormalizeRadians(angle: number): number;
  20060. }
  20061. }
  20062. declare module BABYLON {
  20063. /**
  20064. * Constant used to convert a value to gamma space
  20065. * @ignorenaming
  20066. */
  20067. const ToGammaSpace: number;
  20068. /**
  20069. * Constant used to convert a value to linear space
  20070. * @ignorenaming
  20071. */
  20072. const ToLinearSpace = 2.2;
  20073. /**
  20074. * Constant used to define the minimal number value in Babylon.js
  20075. * @ignorenaming
  20076. */
  20077. const Epsilon = 0.001;
  20078. /**
  20079. * Class used to hold a RBG color
  20080. */
  20081. class Color3 {
  20082. /**
  20083. * Defines the red component (between 0 and 1, default is 0)
  20084. */
  20085. r: number;
  20086. /**
  20087. * Defines the green component (between 0 and 1, default is 0)
  20088. */
  20089. g: number;
  20090. /**
  20091. * Defines the blue component (between 0 and 1, default is 0)
  20092. */
  20093. b: number;
  20094. /**
  20095. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20096. * @param r defines the red component (between 0 and 1, default is 0)
  20097. * @param g defines the green component (between 0 and 1, default is 0)
  20098. * @param b defines the blue component (between 0 and 1, default is 0)
  20099. */
  20100. constructor(
  20101. /**
  20102. * Defines the red component (between 0 and 1, default is 0)
  20103. */
  20104. r?: number,
  20105. /**
  20106. * Defines the green component (between 0 and 1, default is 0)
  20107. */
  20108. g?: number,
  20109. /**
  20110. * Defines the blue component (between 0 and 1, default is 0)
  20111. */
  20112. b?: number);
  20113. /**
  20114. * Creates a string with the Color3 current values
  20115. * @returns the string representation of the Color3 object
  20116. */
  20117. toString(): string;
  20118. /**
  20119. * Returns the string "Color3"
  20120. * @returns "Color3"
  20121. */
  20122. getClassName(): string;
  20123. /**
  20124. * Compute the Color3 hash code
  20125. * @returns an unique number that can be used to hash Color3 objects
  20126. */
  20127. getHashCode(): number;
  20128. /**
  20129. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20130. * @param array defines the array where to store the r,g,b components
  20131. * @param index defines an optional index in the target array to define where to start storing values
  20132. * @returns the current Color3 object
  20133. */
  20134. toArray(array: FloatArray, index?: number): Color3;
  20135. /**
  20136. * Returns a new Color4 object from the current Color3 and the given alpha
  20137. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20138. * @returns a new Color4 object
  20139. */
  20140. toColor4(alpha?: number): Color4;
  20141. /**
  20142. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20143. * @returns the new array
  20144. */
  20145. asArray(): number[];
  20146. /**
  20147. * Returns the luminance value
  20148. * @returns a float value
  20149. */
  20150. toLuminance(): number;
  20151. /**
  20152. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20153. * @param otherColor defines the second operand
  20154. * @returns the new Color3 object
  20155. */
  20156. multiply(otherColor: Color3): Color3;
  20157. /**
  20158. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20159. * @param otherColor defines the second operand
  20160. * @param result defines the Color3 object where to store the result
  20161. * @returns the current Color3
  20162. */
  20163. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  20164. /**
  20165. * Determines equality between Color3 objects
  20166. * @param otherColor defines the second operand
  20167. * @returns true if the rgb values are equal to the given ones
  20168. */
  20169. equals(otherColor: Color3): boolean;
  20170. /**
  20171. * Determines equality between the current Color3 object and a set of r,b,g values
  20172. * @param r defines the red component to check
  20173. * @param g defines the green component to check
  20174. * @param b defines the blue component to check
  20175. * @returns true if the rgb values are equal to the given ones
  20176. */
  20177. equalsFloats(r: number, g: number, b: number): boolean;
  20178. /**
  20179. * Multiplies in place each rgb value by scale
  20180. * @param scale defines the scaling factor
  20181. * @returns the updated Color3
  20182. */
  20183. scale(scale: number): Color3;
  20184. /**
  20185. * Multiplies the rgb values by scale and stores the result into "result"
  20186. * @param scale defines the scaling factor
  20187. * @param result defines the Color3 object where to store the result
  20188. * @returns the unmodified current Color3
  20189. */
  20190. scaleToRef(scale: number, result: Color3): Color3;
  20191. /**
  20192. * Scale the current Color3 values by a factor and add the result to a given Color3
  20193. * @param scale defines the scale factor
  20194. * @param result defines color to store the result into
  20195. * @returns the unmodified current Color3
  20196. */
  20197. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20198. /**
  20199. * Clamps the rgb values by the min and max values and stores the result into "result"
  20200. * @param min defines minimum clamping value (default is 0)
  20201. * @param max defines maximum clamping value (default is 1)
  20202. * @param result defines color to store the result into
  20203. * @returns the original Color3
  20204. */
  20205. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20206. /**
  20207. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20208. * @param otherColor defines the second operand
  20209. * @returns the new Color3
  20210. */
  20211. add(otherColor: Color3): Color3;
  20212. /**
  20213. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20214. * @param otherColor defines the second operand
  20215. * @param result defines Color3 object to store the result into
  20216. * @returns the unmodified current Color3
  20217. */
  20218. addToRef(otherColor: Color3, result: Color3): Color3;
  20219. /**
  20220. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20221. * @param otherColor defines the second operand
  20222. * @returns the new Color3
  20223. */
  20224. subtract(otherColor: Color3): Color3;
  20225. /**
  20226. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20227. * @param otherColor defines the second operand
  20228. * @param result defines Color3 object to store the result into
  20229. * @returns the unmodified current Color3
  20230. */
  20231. subtractToRef(otherColor: Color3, result: Color3): Color3;
  20232. /**
  20233. * Copy the current object
  20234. * @returns a new Color3 copied the current one
  20235. */
  20236. clone(): Color3;
  20237. /**
  20238. * Copies the rgb values from the source in the current Color3
  20239. * @param source defines the source Color3 object
  20240. * @returns the updated Color3 object
  20241. */
  20242. copyFrom(source: Color3): Color3;
  20243. /**
  20244. * Updates the Color3 rgb values from the given floats
  20245. * @param r defines the red component to read from
  20246. * @param g defines the green component to read from
  20247. * @param b defines the blue component to read from
  20248. * @returns the current Color3 object
  20249. */
  20250. copyFromFloats(r: number, g: number, b: number): Color3;
  20251. /**
  20252. * Updates the Color3 rgb values from the given floats
  20253. * @param r defines the red component to read from
  20254. * @param g defines the green component to read from
  20255. * @param b defines the blue component to read from
  20256. * @returns the current Color3 object
  20257. */
  20258. set(r: number, g: number, b: number): Color3;
  20259. /**
  20260. * Compute the Color3 hexadecimal code as a string
  20261. * @returns a string containing the hexadecimal representation of the Color3 object
  20262. */
  20263. toHexString(): string;
  20264. /**
  20265. * Computes a new Color3 converted from the current one to linear space
  20266. * @returns a new Color3 object
  20267. */
  20268. toLinearSpace(): Color3;
  20269. /**
  20270. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20271. * @param convertedColor defines the Color3 object where to store the linear space version
  20272. * @returns the unmodified Color3
  20273. */
  20274. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20275. /**
  20276. * Computes a new Color3 converted from the current one to gamma space
  20277. * @returns a new Color3 object
  20278. */
  20279. toGammaSpace(): Color3;
  20280. /**
  20281. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20282. * @param convertedColor defines the Color3 object where to store the gamma space version
  20283. * @returns the unmodified Color3
  20284. */
  20285. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20286. /**
  20287. * Creates a new Color3 from the string containing valid hexadecimal values
  20288. * @param hex defines a string containing valid hexadecimal values
  20289. * @returns a new Color3 object
  20290. */
  20291. static FromHexString(hex: string): Color3;
  20292. /**
  20293. * Creates a new Vector3 from the starting index of the given array
  20294. * @param array defines the source array
  20295. * @param offset defines an offset in the source array
  20296. * @returns a new Color3 object
  20297. */
  20298. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  20299. /**
  20300. * Creates a new Color3 from integer values (< 256)
  20301. * @param r defines the red component to read from (value between 0 and 255)
  20302. * @param g defines the green component to read from (value between 0 and 255)
  20303. * @param b defines the blue component to read from (value between 0 and 255)
  20304. * @returns a new Color3 object
  20305. */
  20306. static FromInts(r: number, g: number, b: number): Color3;
  20307. /**
  20308. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20309. * @param start defines the start Color3 value
  20310. * @param end defines the end Color3 value
  20311. * @param amount defines the gradient value between start and end
  20312. * @returns a new Color3 object
  20313. */
  20314. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  20315. /**
  20316. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20317. * @param left defines the start value
  20318. * @param right defines the end value
  20319. * @param amount defines the gradient factor
  20320. * @param result defines the Color3 object where to store the result
  20321. */
  20322. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  20323. /**
  20324. * Returns a Color3 value containing a red color
  20325. * @returns a new Color3 object
  20326. */
  20327. static Red(): Color3;
  20328. /**
  20329. * Returns a Color3 value containing a green color
  20330. * @returns a new Color3 object
  20331. */
  20332. static Green(): Color3;
  20333. /**
  20334. * Returns a Color3 value containing a blue color
  20335. * @returns a new Color3 object
  20336. */
  20337. static Blue(): Color3;
  20338. /**
  20339. * Returns a Color3 value containing a black color
  20340. * @returns a new Color3 object
  20341. */
  20342. static Black(): Color3;
  20343. /**
  20344. * Returns a Color3 value containing a white color
  20345. * @returns a new Color3 object
  20346. */
  20347. static White(): Color3;
  20348. /**
  20349. * Returns a Color3 value containing a purple color
  20350. * @returns a new Color3 object
  20351. */
  20352. static Purple(): Color3;
  20353. /**
  20354. * Returns a Color3 value containing a magenta color
  20355. * @returns a new Color3 object
  20356. */
  20357. static Magenta(): Color3;
  20358. /**
  20359. * Returns a Color3 value containing a yellow color
  20360. * @returns a new Color3 object
  20361. */
  20362. static Yellow(): Color3;
  20363. /**
  20364. * Returns a Color3 value containing a gray color
  20365. * @returns a new Color3 object
  20366. */
  20367. static Gray(): Color3;
  20368. /**
  20369. * Returns a Color3 value containing a teal color
  20370. * @returns a new Color3 object
  20371. */
  20372. static Teal(): Color3;
  20373. /**
  20374. * Returns a Color3 value containing a random color
  20375. * @returns a new Color3 object
  20376. */
  20377. static Random(): Color3;
  20378. }
  20379. /**
  20380. * Class used to hold a RBGA color
  20381. */
  20382. class Color4 {
  20383. /**
  20384. * Defines the red component (between 0 and 1, default is 0)
  20385. */
  20386. r: number;
  20387. /**
  20388. * Defines the green component (between 0 and 1, default is 0)
  20389. */
  20390. g: number;
  20391. /**
  20392. * Defines the blue component (between 0 and 1, default is 0)
  20393. */
  20394. b: number;
  20395. /**
  20396. * Defines the alpha component (between 0 and 1, default is 1)
  20397. */
  20398. a: number;
  20399. /**
  20400. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20401. * @param r defines the red component (between 0 and 1, default is 0)
  20402. * @param g defines the green component (between 0 and 1, default is 0)
  20403. * @param b defines the blue component (between 0 and 1, default is 0)
  20404. * @param a defines the alpha component (between 0 and 1, default is 1)
  20405. */
  20406. constructor(
  20407. /**
  20408. * Defines the red component (between 0 and 1, default is 0)
  20409. */
  20410. r?: number,
  20411. /**
  20412. * Defines the green component (between 0 and 1, default is 0)
  20413. */
  20414. g?: number,
  20415. /**
  20416. * Defines the blue component (between 0 and 1, default is 0)
  20417. */
  20418. b?: number,
  20419. /**
  20420. * Defines the alpha component (between 0 and 1, default is 1)
  20421. */
  20422. a?: number);
  20423. /**
  20424. * Adds in place the given Color4 values to the current Color4 object
  20425. * @param right defines the second operand
  20426. * @returns the current updated Color4 object
  20427. */
  20428. addInPlace(right: Color4): Color4;
  20429. /**
  20430. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20431. * @returns the new array
  20432. */
  20433. asArray(): number[];
  20434. /**
  20435. * Stores from the starting index in the given array the Color4 successive values
  20436. * @param array defines the array where to store the r,g,b components
  20437. * @param index defines an optional index in the target array to define where to start storing values
  20438. * @returns the current Color4 object
  20439. */
  20440. toArray(array: number[], index?: number): Color4;
  20441. /**
  20442. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20443. * @param right defines the second operand
  20444. * @returns a new Color4 object
  20445. */
  20446. add(right: Color4): Color4;
  20447. /**
  20448. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20449. * @param right defines the second operand
  20450. * @returns a new Color4 object
  20451. */
  20452. subtract(right: Color4): Color4;
  20453. /**
  20454. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20455. * @param right defines the second operand
  20456. * @param result defines the Color4 object where to store the result
  20457. * @returns the current Color4 object
  20458. */
  20459. subtractToRef(right: Color4, result: Color4): Color4;
  20460. /**
  20461. * Creates a new Color4 with the current Color4 values multiplied by scale
  20462. * @param scale defines the scaling factor to apply
  20463. * @returns a new Color4 object
  20464. */
  20465. scale(scale: number): Color4;
  20466. /**
  20467. * Multiplies the current Color4 values by scale and stores the result in "result"
  20468. * @param scale defines the scaling factor to apply
  20469. * @param result defines the Color4 object where to store the result
  20470. * @returns the current unmodified Color4
  20471. */
  20472. scaleToRef(scale: number, result: Color4): Color4;
  20473. /**
  20474. * Scale the current Color4 values by a factor and add the result to a given Color4
  20475. * @param scale defines the scale factor
  20476. * @param result defines the Color4 object where to store the result
  20477. * @returns the unmodified current Color4
  20478. */
  20479. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20480. /**
  20481. * Clamps the rgb values by the min and max values and stores the result into "result"
  20482. * @param min defines minimum clamping value (default is 0)
  20483. * @param max defines maximum clamping value (default is 1)
  20484. * @param result defines color to store the result into.
  20485. * @returns the cuurent Color4
  20486. */
  20487. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20488. /**
  20489. * Multipy an Color4 value by another and return a new Color4 object
  20490. * @param color defines the Color4 value to multiply by
  20491. * @returns a new Color4 object
  20492. */
  20493. multiply(color: Color4): Color4;
  20494. /**
  20495. * Multipy a Color4 value by another and push the result in a reference value
  20496. * @param color defines the Color4 value to multiply by
  20497. * @param result defines the Color4 to fill the result in
  20498. * @returns the result Color4
  20499. */
  20500. multiplyToRef(color: Color4, result: Color4): Color4;
  20501. /**
  20502. * Creates a string with the Color4 current values
  20503. * @returns the string representation of the Color4 object
  20504. */
  20505. toString(): string;
  20506. /**
  20507. * Returns the string "Color4"
  20508. * @returns "Color4"
  20509. */
  20510. getClassName(): string;
  20511. /**
  20512. * Compute the Color4 hash code
  20513. * @returns an unique number that can be used to hash Color4 objects
  20514. */
  20515. getHashCode(): number;
  20516. /**
  20517. * Creates a new Color4 copied from the current one
  20518. * @returns a new Color4 object
  20519. */
  20520. clone(): Color4;
  20521. /**
  20522. * Copies the given Color4 values into the current one
  20523. * @param source defines the source Color4 object
  20524. * @returns the current updated Color4 object
  20525. */
  20526. copyFrom(source: Color4): Color4;
  20527. /**
  20528. * Copies the given float values into the current one
  20529. * @param r defines the red component to read from
  20530. * @param g defines the green component to read from
  20531. * @param b defines the blue component to read from
  20532. * @param a defines the alpha component to read from
  20533. * @returns the current updated Color4 object
  20534. */
  20535. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20536. /**
  20537. * Copies the given float values into the current one
  20538. * @param r defines the red component to read from
  20539. * @param g defines the green component to read from
  20540. * @param b defines the blue component to read from
  20541. * @param a defines the alpha component to read from
  20542. * @returns the current updated Color4 object
  20543. */
  20544. set(r: number, g: number, b: number, a: number): Color4;
  20545. /**
  20546. * Compute the Color4 hexadecimal code as a string
  20547. * @returns a string containing the hexadecimal representation of the Color4 object
  20548. */
  20549. toHexString(): string;
  20550. /**
  20551. * Computes a new Color4 converted from the current one to linear space
  20552. * @returns a new Color4 object
  20553. */
  20554. toLinearSpace(): Color4;
  20555. /**
  20556. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20557. * @param convertedColor defines the Color4 object where to store the linear space version
  20558. * @returns the unmodified Color4
  20559. */
  20560. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20561. /**
  20562. * Computes a new Color4 converted from the current one to gamma space
  20563. * @returns a new Color4 object
  20564. */
  20565. toGammaSpace(): Color4;
  20566. /**
  20567. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20568. * @param convertedColor defines the Color4 object where to store the gamma space version
  20569. * @returns the unmodified Color4
  20570. */
  20571. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20572. /**
  20573. * Creates a new Color4 from the string containing valid hexadecimal values
  20574. * @param hex defines a string containing valid hexadecimal values
  20575. * @returns a new Color4 object
  20576. */
  20577. static FromHexString(hex: string): Color4;
  20578. /**
  20579. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20580. * @param left defines the start value
  20581. * @param right defines the end value
  20582. * @param amount defines the gradient factor
  20583. * @returns a new Color4 object
  20584. */
  20585. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20586. /**
  20587. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20588. * @param left defines the start value
  20589. * @param right defines the end value
  20590. * @param amount defines the gradient factor
  20591. * @param result defines the Color4 object where to store data
  20592. */
  20593. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20594. /**
  20595. * Creates a new Color4 from a Color3 and an alpha value
  20596. * @param color3 defines the source Color3 to read from
  20597. * @param alpha defines the alpha component (1.0 by default)
  20598. * @returns a new Color4 object
  20599. */
  20600. static FromColor3(color3: Color3, alpha?: number): Color4;
  20601. /**
  20602. * Creates a new Color4 from the starting index element of the given array
  20603. * @param array defines the source array to read from
  20604. * @param offset defines the offset in the source array
  20605. * @returns a new Color4 object
  20606. */
  20607. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20608. /**
  20609. * Creates a new Color3 from integer values (< 256)
  20610. * @param r defines the red component to read from (value between 0 and 255)
  20611. * @param g defines the green component to read from (value between 0 and 255)
  20612. * @param b defines the blue component to read from (value between 0 and 255)
  20613. * @param a defines the alpha component to read from (value between 0 and 255)
  20614. * @returns a new Color3 object
  20615. */
  20616. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20617. /**
  20618. * Check the content of a given array and convert it to an array containing RGBA data
  20619. * If the original array was already containing count * 4 values then it is returned directly
  20620. * @param colors defines the array to check
  20621. * @param count defines the number of RGBA data to expect
  20622. * @returns an array containing count * 4 values (RGBA)
  20623. */
  20624. static CheckColors4(colors: number[], count: number): number[];
  20625. }
  20626. /**
  20627. * Class representing a vector containing 2 coordinates
  20628. */
  20629. class Vector2 {
  20630. /** defines the first coordinate */
  20631. x: number;
  20632. /** defines the second coordinate */
  20633. y: number;
  20634. /**
  20635. * Creates a new Vector2 from the given x and y coordinates
  20636. * @param x defines the first coordinate
  20637. * @param y defines the second coordinate
  20638. */
  20639. constructor(
  20640. /** defines the first coordinate */
  20641. x?: number,
  20642. /** defines the second coordinate */
  20643. y?: number);
  20644. /**
  20645. * Gets a string with the Vector2 coordinates
  20646. * @returns a string with the Vector2 coordinates
  20647. */
  20648. toString(): string;
  20649. /**
  20650. * Gets class name
  20651. * @returns the string "Vector2"
  20652. */
  20653. getClassName(): string;
  20654. /**
  20655. * Gets current vector hash code
  20656. * @returns the Vector2 hash code as a number
  20657. */
  20658. getHashCode(): number;
  20659. /**
  20660. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20661. * @param array defines the source array
  20662. * @param index defines the offset in source array
  20663. * @returns the current Vector2
  20664. */
  20665. toArray(array: FloatArray, index?: number): Vector2;
  20666. /**
  20667. * Copy the current vector to an array
  20668. * @returns a new array with 2 elements: the Vector2 coordinates.
  20669. */
  20670. asArray(): number[];
  20671. /**
  20672. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20673. * @param source defines the source Vector2
  20674. * @returns the current updated Vector2
  20675. */
  20676. copyFrom(source: Vector2): Vector2;
  20677. /**
  20678. * Sets the Vector2 coordinates with the given floats
  20679. * @param x defines the first coordinate
  20680. * @param y defines the second coordinate
  20681. * @returns the current updated Vector2
  20682. */
  20683. copyFromFloats(x: number, y: number): Vector2;
  20684. /**
  20685. * Sets the Vector2 coordinates with the given floats
  20686. * @param x defines the first coordinate
  20687. * @param y defines the second coordinate
  20688. * @returns the current updated Vector2
  20689. */
  20690. set(x: number, y: number): Vector2;
  20691. /**
  20692. * Add another vector with the current one
  20693. * @param otherVector defines the other vector
  20694. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20695. */
  20696. add(otherVector: Vector2): Vector2;
  20697. /**
  20698. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20699. * @param otherVector defines the other vector
  20700. * @param result defines the target vector
  20701. * @returns the unmodified current Vector2
  20702. */
  20703. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20704. /**
  20705. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20706. * @param otherVector defines the other vector
  20707. * @returns the current updated Vector2
  20708. */
  20709. addInPlace(otherVector: Vector2): Vector2;
  20710. /**
  20711. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20712. * @param otherVector defines the other vector
  20713. * @returns a new Vector2
  20714. */
  20715. addVector3(otherVector: Vector3): Vector2;
  20716. /**
  20717. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20718. * @param otherVector defines the other vector
  20719. * @returns a new Vector2
  20720. */
  20721. subtract(otherVector: Vector2): Vector2;
  20722. /**
  20723. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20724. * @param otherVector defines the other vector
  20725. * @param result defines the target vector
  20726. * @returns the unmodified current Vector2
  20727. */
  20728. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20729. /**
  20730. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20731. * @param otherVector defines the other vector
  20732. * @returns the current updated Vector2
  20733. */
  20734. subtractInPlace(otherVector: Vector2): Vector2;
  20735. /**
  20736. * Multiplies in place the current Vector2 coordinates by the given ones
  20737. * @param otherVector defines the other vector
  20738. * @returns the current updated Vector2
  20739. */
  20740. multiplyInPlace(otherVector: Vector2): Vector2;
  20741. /**
  20742. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20743. * @param otherVector defines the other vector
  20744. * @returns a new Vector2
  20745. */
  20746. multiply(otherVector: Vector2): Vector2;
  20747. /**
  20748. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20749. * @param otherVector defines the other vector
  20750. * @param result defines the target vector
  20751. * @returns the unmodified current Vector2
  20752. */
  20753. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20754. /**
  20755. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20756. * @param x defines the first coordinate
  20757. * @param y defines the second coordinate
  20758. * @returns a new Vector2
  20759. */
  20760. multiplyByFloats(x: number, y: number): Vector2;
  20761. /**
  20762. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20763. * @param otherVector defines the other vector
  20764. * @returns a new Vector2
  20765. */
  20766. divide(otherVector: Vector2): Vector2;
  20767. /**
  20768. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20769. * @param otherVector defines the other vector
  20770. * @param result defines the target vector
  20771. * @returns the unmodified current Vector2
  20772. */
  20773. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20774. /**
  20775. * Divides the current Vector2 coordinates by the given ones
  20776. * @param otherVector defines the other vector
  20777. * @returns the current updated Vector2
  20778. */
  20779. divideInPlace(otherVector: Vector2): Vector2;
  20780. /**
  20781. * Gets a new Vector2 with current Vector2 negated coordinates
  20782. * @returns a new Vector2
  20783. */
  20784. negate(): Vector2;
  20785. /**
  20786. * Multiply the Vector2 coordinates by scale
  20787. * @param scale defines the scaling factor
  20788. * @returns the current updated Vector2
  20789. */
  20790. scaleInPlace(scale: number): Vector2;
  20791. /**
  20792. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20793. * @param scale defines the scaling factor
  20794. * @returns a new Vector2
  20795. */
  20796. scale(scale: number): Vector2;
  20797. /**
  20798. * Scale the current Vector2 values by a factor to a given Vector2
  20799. * @param scale defines the scale factor
  20800. * @param result defines the Vector2 object where to store the result
  20801. * @returns the unmodified current Vector2
  20802. */
  20803. scaleToRef(scale: number, result: Vector2): Vector2;
  20804. /**
  20805. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20806. * @param scale defines the scale factor
  20807. * @param result defines the Vector2 object where to store the result
  20808. * @returns the unmodified current Vector2
  20809. */
  20810. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20811. /**
  20812. * Gets a boolean if two vectors are equals
  20813. * @param otherVector defines the other vector
  20814. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20815. */
  20816. equals(otherVector: Vector2): boolean;
  20817. /**
  20818. * Gets a boolean if two vectors are equals (using an epsilon value)
  20819. * @param otherVector defines the other vector
  20820. * @param epsilon defines the minimal distance to consider equality
  20821. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20822. */
  20823. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20824. /**
  20825. * Gets a new Vector2 from current Vector2 floored values
  20826. * @returns a new Vector2
  20827. */
  20828. floor(): Vector2;
  20829. /**
  20830. * Gets a new Vector2 from current Vector2 floored values
  20831. * @returns a new Vector2
  20832. */
  20833. fract(): Vector2;
  20834. /**
  20835. * Gets the length of the vector
  20836. * @returns the vector length (float)
  20837. */
  20838. length(): number;
  20839. /**
  20840. * Gets the vector squared length
  20841. * @returns the vector squared length (float)
  20842. */
  20843. lengthSquared(): number;
  20844. /**
  20845. * Normalize the vector
  20846. * @returns the current updated Vector2
  20847. */
  20848. normalize(): Vector2;
  20849. /**
  20850. * Gets a new Vector2 copied from the Vector2
  20851. * @returns a new Vector2
  20852. */
  20853. clone(): Vector2;
  20854. /**
  20855. * Gets a new Vector2(0, 0)
  20856. * @returns a new Vector2
  20857. */
  20858. static Zero(): Vector2;
  20859. /**
  20860. * Gets a new Vector2(1, 1)
  20861. * @returns a new Vector2
  20862. */
  20863. static One(): Vector2;
  20864. /**
  20865. * Gets a new Vector2 set from the given index element of the given array
  20866. * @param array defines the data source
  20867. * @param offset defines the offset in the data source
  20868. * @returns a new Vector2
  20869. */
  20870. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20871. /**
  20872. * Sets "result" from the given index element of the given array
  20873. * @param array defines the data source
  20874. * @param offset defines the offset in the data source
  20875. * @param result defines the target vector
  20876. */
  20877. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20878. /**
  20879. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20880. * @param value1 defines 1st point of control
  20881. * @param value2 defines 2nd point of control
  20882. * @param value3 defines 3rd point of control
  20883. * @param value4 defines 4th point of control
  20884. * @param amount defines the interpolation factor
  20885. * @returns a new Vector2
  20886. */
  20887. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20888. /**
  20889. * 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".
  20890. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20891. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20892. * @param value defines the value to clamp
  20893. * @param min defines the lower limit
  20894. * @param max defines the upper limit
  20895. * @returns a new Vector2
  20896. */
  20897. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20898. /**
  20899. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20900. * @param value1 defines the 1st control point
  20901. * @param tangent1 defines the outgoing tangent
  20902. * @param value2 defines the 2nd control point
  20903. * @param tangent2 defines the incoming tangent
  20904. * @param amount defines the interpolation factor
  20905. * @returns a new Vector2
  20906. */
  20907. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20908. /**
  20909. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20910. * @param start defines the start vector
  20911. * @param end defines the end vector
  20912. * @param amount defines the interpolation factor
  20913. * @returns a new Vector2
  20914. */
  20915. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20916. /**
  20917. * Gets the dot product of the vector "left" and the vector "right"
  20918. * @param left defines first vector
  20919. * @param right defines second vector
  20920. * @returns the dot product (float)
  20921. */
  20922. static Dot(left: Vector2, right: Vector2): number;
  20923. /**
  20924. * Returns a new Vector2 equal to the normalized given vector
  20925. * @param vector defines the vector to normalize
  20926. * @returns a new Vector2
  20927. */
  20928. static Normalize(vector: Vector2): Vector2;
  20929. /**
  20930. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20931. * @param left defines 1st vector
  20932. * @param right defines 2nd vector
  20933. * @returns a new Vector2
  20934. */
  20935. static Minimize(left: Vector2, right: Vector2): Vector2;
  20936. /**
  20937. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20938. * @param left defines 1st vector
  20939. * @param right defines 2nd vector
  20940. * @returns a new Vector2
  20941. */
  20942. static Maximize(left: Vector2, right: Vector2): Vector2;
  20943. /**
  20944. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20945. * @param vector defines the vector to transform
  20946. * @param transformation defines the matrix to apply
  20947. * @returns a new Vector2
  20948. */
  20949. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20950. /**
  20951. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20952. * @param vector defines the vector to transform
  20953. * @param transformation defines the matrix to apply
  20954. * @param result defines the target vector
  20955. */
  20956. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20957. /**
  20958. * Determines if a given vector is included in a triangle
  20959. * @param p defines the vector to test
  20960. * @param p0 defines 1st triangle point
  20961. * @param p1 defines 2nd triangle point
  20962. * @param p2 defines 3rd triangle point
  20963. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20964. */
  20965. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20966. /**
  20967. * Gets the distance between the vectors "value1" and "value2"
  20968. * @param value1 defines first vector
  20969. * @param value2 defines second vector
  20970. * @returns the distance between vectors
  20971. */
  20972. static Distance(value1: Vector2, value2: Vector2): number;
  20973. /**
  20974. * Returns the squared distance between the vectors "value1" and "value2"
  20975. * @param value1 defines first vector
  20976. * @param value2 defines second vector
  20977. * @returns the squared distance between vectors
  20978. */
  20979. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20980. /**
  20981. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20982. * @param value1 defines first vector
  20983. * @param value2 defines second vector
  20984. * @returns a new Vector2
  20985. */
  20986. static Center(value1: Vector2, value2: Vector2): Vector2;
  20987. /**
  20988. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20989. * @param p defines the middle point
  20990. * @param segA defines one point of the segment
  20991. * @param segB defines the other point of the segment
  20992. * @returns the shortest distance
  20993. */
  20994. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20995. }
  20996. /**
  20997. * Classed used to store (x,y,z) vector representation
  20998. * A Vector3 is the main object used in 3D geometry
  20999. * It can represent etiher the coordinates of a point the space, either a direction
  21000. * Reminder: Babylon.js uses a left handed forward facing system
  21001. */
  21002. class Vector3 {
  21003. /**
  21004. * Defines the first coordinates (on X axis)
  21005. */
  21006. x: number;
  21007. /**
  21008. * Defines the second coordinates (on Y axis)
  21009. */
  21010. y: number;
  21011. /**
  21012. * Defines the third coordinates (on Z axis)
  21013. */
  21014. z: number;
  21015. /**
  21016. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21017. * @param x defines the first coordinates (on X axis)
  21018. * @param y defines the second coordinates (on Y axis)
  21019. * @param z defines the third coordinates (on Z axis)
  21020. */
  21021. constructor(
  21022. /**
  21023. * Defines the first coordinates (on X axis)
  21024. */
  21025. x?: number,
  21026. /**
  21027. * Defines the second coordinates (on Y axis)
  21028. */
  21029. y?: number,
  21030. /**
  21031. * Defines the third coordinates (on Z axis)
  21032. */
  21033. z?: number);
  21034. /**
  21035. * Creates a string representation of the Vector3
  21036. * @returns a string with the Vector3 coordinates.
  21037. */
  21038. toString(): string;
  21039. /**
  21040. * Gets the class name
  21041. * @returns the string "Vector3"
  21042. */
  21043. getClassName(): string;
  21044. /**
  21045. * Creates the Vector3 hash code
  21046. * @returns a number which tends to be unique between Vector3 instances
  21047. */
  21048. getHashCode(): number;
  21049. /**
  21050. * Creates an array containing three elements : the coordinates of the Vector3
  21051. * @returns a new array of numbers
  21052. */
  21053. asArray(): number[];
  21054. /**
  21055. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21056. * @param array defines the destination array
  21057. * @param index defines the offset in the destination array
  21058. * @returns the current Vector3
  21059. */
  21060. toArray(array: FloatArray, index?: number): Vector3;
  21061. /**
  21062. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21063. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21064. */
  21065. toQuaternion(): Quaternion;
  21066. /**
  21067. * Adds the given vector to the current Vector3
  21068. * @param otherVector defines the second operand
  21069. * @returns the current updated Vector3
  21070. */
  21071. addInPlace(otherVector: Vector3): Vector3;
  21072. /**
  21073. * Adds the given coordinates to the current Vector3
  21074. * @param x defines the x coordinate of the operand
  21075. * @param y defines the y coordinate of the operand
  21076. * @param z defines the z coordinate of the operand
  21077. * @returns the current updated Vector3
  21078. */
  21079. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21080. /**
  21081. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21082. * @param otherVector defines the second operand
  21083. * @returns the resulting Vector3
  21084. */
  21085. add(otherVector: Vector3): Vector3;
  21086. /**
  21087. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21088. * @param otherVector defines the second operand
  21089. * @param result defines the Vector3 object where to store the result
  21090. * @returns the current Vector3
  21091. */
  21092. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  21093. /**
  21094. * Subtract the given vector from the current Vector3
  21095. * @param otherVector defines the second operand
  21096. * @returns the current updated Vector3
  21097. */
  21098. subtractInPlace(otherVector: Vector3): Vector3;
  21099. /**
  21100. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21101. * @param otherVector defines the second operand
  21102. * @returns the resulting Vector3
  21103. */
  21104. subtract(otherVector: Vector3): Vector3;
  21105. /**
  21106. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21107. * @param otherVector defines the second operand
  21108. * @param result defines the Vector3 object where to store the result
  21109. * @returns the current Vector3
  21110. */
  21111. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  21112. /**
  21113. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21114. * @param x defines the x coordinate of the operand
  21115. * @param y defines the y coordinate of the operand
  21116. * @param z defines the z coordinate of the operand
  21117. * @returns the resulting Vector3
  21118. */
  21119. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21120. /**
  21121. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21122. * @param x defines the x coordinate of the operand
  21123. * @param y defines the y coordinate of the operand
  21124. * @param z defines the z coordinate of the operand
  21125. * @param result defines the Vector3 object where to store the result
  21126. * @returns the current Vector3
  21127. */
  21128. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21129. /**
  21130. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21131. * @returns a new Vector3
  21132. */
  21133. negate(): Vector3;
  21134. /**
  21135. * Multiplies the Vector3 coordinates by the float "scale"
  21136. * @param scale defines the multiplier factor
  21137. * @returns the current updated Vector3
  21138. */
  21139. scaleInPlace(scale: number): Vector3;
  21140. /**
  21141. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21142. * @param scale defines the multiplier factor
  21143. * @returns a new Vector3
  21144. */
  21145. scale(scale: number): Vector3;
  21146. /**
  21147. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21148. * @param scale defines the multiplier factor
  21149. * @param result defines the Vector3 object where to store the result
  21150. * @returns the current Vector3
  21151. */
  21152. scaleToRef(scale: number, result: Vector3): Vector3;
  21153. /**
  21154. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21155. * @param scale defines the scale factor
  21156. * @param result defines the Vector3 object where to store the result
  21157. * @returns the unmodified current Vector3
  21158. */
  21159. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21160. /**
  21161. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21162. * @param otherVector defines the second operand
  21163. * @returns true if both vectors are equals
  21164. */
  21165. equals(otherVector: Vector3): boolean;
  21166. /**
  21167. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21168. * @param otherVector defines the second operand
  21169. * @param epsilon defines the minimal distance to define values as equals
  21170. * @returns true if both vectors are distant less than epsilon
  21171. */
  21172. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  21173. /**
  21174. * Returns true if the current Vector3 coordinates equals the given floats
  21175. * @param x defines the x coordinate of the operand
  21176. * @param y defines the y coordinate of the operand
  21177. * @param z defines the z coordinate of the operand
  21178. * @returns true if both vectors are equals
  21179. */
  21180. equalsToFloats(x: number, y: number, z: number): boolean;
  21181. /**
  21182. * Multiplies the current Vector3 coordinates by the given ones
  21183. * @param otherVector defines the second operand
  21184. * @returns the current updated Vector3
  21185. */
  21186. multiplyInPlace(otherVector: Vector3): Vector3;
  21187. /**
  21188. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21189. * @param otherVector defines the second operand
  21190. * @returns the new Vector3
  21191. */
  21192. multiply(otherVector: Vector3): Vector3;
  21193. /**
  21194. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21195. * @param otherVector defines the second operand
  21196. * @param result defines the Vector3 object where to store the result
  21197. * @returns the current Vector3
  21198. */
  21199. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  21200. /**
  21201. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21202. * @param x defines the x coordinate of the operand
  21203. * @param y defines the y coordinate of the operand
  21204. * @param z defines the z coordinate of the operand
  21205. * @returns the new Vector3
  21206. */
  21207. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21208. /**
  21209. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21210. * @param otherVector defines the second operand
  21211. * @returns the new Vector3
  21212. */
  21213. divide(otherVector: Vector3): Vector3;
  21214. /**
  21215. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21216. * @param otherVector defines the second operand
  21217. * @param result defines the Vector3 object where to store the result
  21218. * @returns the current Vector3
  21219. */
  21220. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  21221. /**
  21222. * Divides the current Vector3 coordinates by the given ones.
  21223. * @param otherVector defines the second operand
  21224. * @returns the current updated Vector3
  21225. */
  21226. divideInPlace(otherVector: Vector3): Vector3;
  21227. /**
  21228. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21229. * @param other defines the second operand
  21230. * @returns the current updated Vector3
  21231. */
  21232. minimizeInPlace(other: Vector3): Vector3;
  21233. /**
  21234. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21235. * @param other defines the second operand
  21236. * @returns the current updated Vector3
  21237. */
  21238. maximizeInPlace(other: Vector3): Vector3;
  21239. /**
  21240. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21241. * @param x defines the x coordinate of the operand
  21242. * @param y defines the y coordinate of the operand
  21243. * @param z defines the z coordinate of the operand
  21244. * @returns the current updated Vector3
  21245. */
  21246. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21247. /**
  21248. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21249. * @param x defines the x coordinate of the operand
  21250. * @param y defines the y coordinate of the operand
  21251. * @param z defines the z coordinate of the operand
  21252. * @returns the current updated Vector3
  21253. */
  21254. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21255. /**
  21256. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21257. */
  21258. readonly isNonUniform: boolean;
  21259. /**
  21260. * Gets a new Vector3 from current Vector3 floored values
  21261. * @returns a new Vector3
  21262. */
  21263. floor(): Vector3;
  21264. /**
  21265. * Gets a new Vector3 from current Vector3 floored values
  21266. * @returns a new Vector3
  21267. */
  21268. fract(): Vector3;
  21269. /**
  21270. * Gets the length of the Vector3
  21271. * @returns the length of the Vecto3
  21272. */
  21273. length(): number;
  21274. /**
  21275. * Gets the squared length of the Vector3
  21276. * @returns squared length of the Vector3
  21277. */
  21278. lengthSquared(): number;
  21279. /**
  21280. * Normalize the current Vector3.
  21281. * Please note that this is an in place operation.
  21282. * @returns the current updated Vector3
  21283. */
  21284. normalize(): Vector3;
  21285. /**
  21286. * Reorders the x y z properties of the vector in place
  21287. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21288. * @returns the current updated vector
  21289. */
  21290. reorderInPlace(order: string): this;
  21291. /**
  21292. * Rotates the vector around 0,0,0 by a quaternion
  21293. * @param quaternion the rotation quaternion
  21294. * @param result vector to store the result
  21295. * @returns the resulting vector
  21296. */
  21297. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21298. /**
  21299. * Rotates a vector around a given point
  21300. * @param quaternion the rotation quaternion
  21301. * @param point the point to rotate around
  21302. * @param result vector to store the result
  21303. * @returns the resulting vector
  21304. */
  21305. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21306. /**
  21307. * Normalize the current Vector3 with the given input length.
  21308. * Please note that this is an in place operation.
  21309. * @param len the length of the vector
  21310. * @returns the current updated Vector3
  21311. */
  21312. normalizeFromLength(len: number): Vector3;
  21313. /**
  21314. * Normalize the current Vector3 to a new vector
  21315. * @returns the new Vector3
  21316. */
  21317. normalizeToNew(): Vector3;
  21318. /**
  21319. * Normalize the current Vector3 to the reference
  21320. * @param reference define the Vector3 to update
  21321. * @returns the updated Vector3
  21322. */
  21323. normalizeToRef(reference: Vector3): Vector3;
  21324. /**
  21325. * Creates a new Vector3 copied from the current Vector3
  21326. * @returns the new Vector3
  21327. */
  21328. clone(): Vector3;
  21329. /**
  21330. * Copies the given vector coordinates to the current Vector3 ones
  21331. * @param source defines the source Vector3
  21332. * @returns the current updated Vector3
  21333. */
  21334. copyFrom(source: Vector3): Vector3;
  21335. /**
  21336. * Copies the given floats to the current Vector3 coordinates
  21337. * @param x defines the x coordinate of the operand
  21338. * @param y defines the y coordinate of the operand
  21339. * @param z defines the z coordinate of the operand
  21340. * @returns the current updated Vector3
  21341. */
  21342. copyFromFloats(x: number, y: number, z: number): Vector3;
  21343. /**
  21344. * Copies the given floats to the current Vector3 coordinates
  21345. * @param x defines the x coordinate of the operand
  21346. * @param y defines the y coordinate of the operand
  21347. * @param z defines the z coordinate of the operand
  21348. * @returns the current updated Vector3
  21349. */
  21350. set(x: number, y: number, z: number): Vector3;
  21351. /**
  21352. * Copies the given float to the current Vector3 coordinates
  21353. * @param v defines the x, y and z coordinates of the operand
  21354. * @returns the current updated Vector3
  21355. */
  21356. setAll(v: number): Vector3;
  21357. /**
  21358. * Get the clip factor between two vectors
  21359. * @param vector0 defines the first operand
  21360. * @param vector1 defines the second operand
  21361. * @param axis defines the axis to use
  21362. * @param size defines the size along the axis
  21363. * @returns the clip factor
  21364. */
  21365. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  21366. /**
  21367. * Get angle between two vectors
  21368. * @param vector0 angle between vector0 and vector1
  21369. * @param vector1 angle between vector0 and vector1
  21370. * @param normal direction of the normal
  21371. * @return the angle between vector0 and vector1
  21372. */
  21373. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  21374. /**
  21375. * Returns a new Vector3 set from the index "offset" of the given array
  21376. * @param array defines the source array
  21377. * @param offset defines the offset in the source array
  21378. * @returns the new Vector3
  21379. */
  21380. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  21381. /**
  21382. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21383. * This function is deprecated. Use FromArray instead
  21384. * @param array defines the source array
  21385. * @param offset defines the offset in the source array
  21386. * @returns the new Vector3
  21387. */
  21388. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  21389. /**
  21390. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21391. * @param array defines the source array
  21392. * @param offset defines the offset in the source array
  21393. * @param result defines the Vector3 where to store the result
  21394. */
  21395. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  21396. /**
  21397. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21398. * This function is deprecated. Use FromArrayToRef instead.
  21399. * @param array defines the source array
  21400. * @param offset defines the offset in the source array
  21401. * @param result defines the Vector3 where to store the result
  21402. */
  21403. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  21404. /**
  21405. * Sets the given vector "result" with the given floats.
  21406. * @param x defines the x coordinate of the source
  21407. * @param y defines the y coordinate of the source
  21408. * @param z defines the z coordinate of the source
  21409. * @param result defines the Vector3 where to store the result
  21410. */
  21411. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21412. /**
  21413. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21414. * @returns a new empty Vector3
  21415. */
  21416. static Zero(): Vector3;
  21417. /**
  21418. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21419. * @returns a new unit Vector3
  21420. */
  21421. static One(): Vector3;
  21422. /**
  21423. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21424. * @returns a new up Vector3
  21425. */
  21426. static Up(): Vector3;
  21427. /**
  21428. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21429. * @returns a new down Vector3
  21430. */
  21431. static Down(): Vector3;
  21432. /**
  21433. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21434. * @returns a new forward Vector3
  21435. */
  21436. static Forward(): Vector3;
  21437. /**
  21438. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21439. * @returns a new forward Vector3
  21440. */
  21441. static Backward(): Vector3;
  21442. /**
  21443. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21444. * @returns a new right Vector3
  21445. */
  21446. static Right(): Vector3;
  21447. /**
  21448. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21449. * @returns a new left Vector3
  21450. */
  21451. static Left(): Vector3;
  21452. /**
  21453. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21454. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21455. * @param vector defines the Vector3 to transform
  21456. * @param transformation defines the transformation matrix
  21457. * @returns the transformed Vector3
  21458. */
  21459. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21460. /**
  21461. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21462. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21463. * @param vector defines the Vector3 to transform
  21464. * @param transformation defines the transformation matrix
  21465. * @param result defines the Vector3 where to store the result
  21466. */
  21467. static TransformCoordinatesToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  21468. /**
  21469. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21470. * This method computes tranformed coordinates only, not transformed direction vectors
  21471. * @param x define the x coordinate of the source vector
  21472. * @param y define the y coordinate of the source vector
  21473. * @param z define the z coordinate of the source vector
  21474. * @param transformation defines the transformation matrix
  21475. * @param result defines the Vector3 where to store the result
  21476. */
  21477. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  21478. /**
  21479. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21480. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21481. * @param vector defines the Vector3 to transform
  21482. * @param transformation defines the transformation matrix
  21483. * @returns the new Vector3
  21484. */
  21485. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21486. /**
  21487. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21488. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21489. * @param vector defines the Vector3 to transform
  21490. * @param transformation defines the transformation matrix
  21491. * @param result defines the Vector3 where to store the result
  21492. */
  21493. static TransformNormalToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  21494. /**
  21495. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21496. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21497. * @param x define the x coordinate of the source vector
  21498. * @param y define the y coordinate of the source vector
  21499. * @param z define the z coordinate of the source vector
  21500. * @param transformation defines the transformation matrix
  21501. * @param result defines the Vector3 where to store the result
  21502. */
  21503. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  21504. /**
  21505. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21506. * @param value1 defines the first control point
  21507. * @param value2 defines the second control point
  21508. * @param value3 defines the third control point
  21509. * @param value4 defines the fourth control point
  21510. * @param amount defines the amount on the spline to use
  21511. * @returns the new Vector3
  21512. */
  21513. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21514. /**
  21515. * 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"
  21516. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21517. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21518. * @param value defines the current value
  21519. * @param min defines the lower range value
  21520. * @param max defines the upper range value
  21521. * @returns the new Vector3
  21522. */
  21523. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21524. /**
  21525. * 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"
  21526. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21527. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21528. * @param value defines the current value
  21529. * @param min defines the lower range value
  21530. * @param max defines the upper range value
  21531. * @param result defines the Vector3 where to store the result
  21532. */
  21533. static ClampToRef(value: Vector3, min: Vector3, max: Vector3, result: Vector3): void;
  21534. /**
  21535. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21536. * @param value1 defines the first control point
  21537. * @param tangent1 defines the first tangent vector
  21538. * @param value2 defines the second control point
  21539. * @param tangent2 defines the second tangent vector
  21540. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21541. * @returns the new Vector3
  21542. */
  21543. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21544. /**
  21545. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21546. * @param start defines the start value
  21547. * @param end defines the end value
  21548. * @param amount max defines amount between both (between 0 and 1)
  21549. * @returns the new Vector3
  21550. */
  21551. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21552. /**
  21553. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21554. * @param start defines the start value
  21555. * @param end defines the end value
  21556. * @param amount max defines amount between both (between 0 and 1)
  21557. * @param result defines the Vector3 where to store the result
  21558. */
  21559. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21560. /**
  21561. * Returns the dot product (float) between the vectors "left" and "right"
  21562. * @param left defines the left operand
  21563. * @param right defines the right operand
  21564. * @returns the dot product
  21565. */
  21566. static Dot(left: Vector3, right: Vector3): number;
  21567. /**
  21568. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21569. * The cross product is then orthogonal to both "left" and "right"
  21570. * @param left defines the left operand
  21571. * @param right defines the right operand
  21572. * @returns the cross product
  21573. */
  21574. static Cross(left: Vector3, right: Vector3): Vector3;
  21575. /**
  21576. * Sets the given vector "result" with the cross product of "left" and "right"
  21577. * The cross product is then orthogonal to both "left" and "right"
  21578. * @param left defines the left operand
  21579. * @param right defines the right operand
  21580. * @param result defines the Vector3 where to store the result
  21581. */
  21582. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21583. /**
  21584. * Returns a new Vector3 as the normalization of the given vector
  21585. * @param vector defines the Vector3 to normalize
  21586. * @returns the new Vector3
  21587. */
  21588. static Normalize(vector: Vector3): Vector3;
  21589. /**
  21590. * Sets the given vector "result" with the normalization of the given first vector
  21591. * @param vector defines the Vector3 to normalize
  21592. * @param result defines the Vector3 where to store the result
  21593. */
  21594. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21595. /**
  21596. * Project a Vector3 onto screen space
  21597. * @param vector defines the Vector3 to project
  21598. * @param world defines the world matrix to use
  21599. * @param transform defines the transform (view x projection) matrix to use
  21600. * @param viewport defines the screen viewport to use
  21601. * @returns the new Vector3
  21602. */
  21603. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21604. /** @hidden */
  21605. private static UnprojectFromInvertedMatrixToRef;
  21606. /**
  21607. * Unproject from screen space to object space
  21608. * @param source defines the screen space Vector3 to use
  21609. * @param viewportWidth defines the current width of the viewport
  21610. * @param viewportHeight defines the current height of the viewport
  21611. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21612. * @param transform defines the transform (view x projection) matrix to use
  21613. * @returns the new Vector3
  21614. */
  21615. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21616. /**
  21617. * Unproject from screen space to object space
  21618. * @param source defines the screen space Vector3 to use
  21619. * @param viewportWidth defines the current width of the viewport
  21620. * @param viewportHeight defines the current height of the viewport
  21621. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21622. * @param view defines the view matrix to use
  21623. * @param projection defines the projection matrix to use
  21624. * @returns the new Vector3
  21625. */
  21626. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21627. /**
  21628. * Unproject from screen space to object space
  21629. * @param source defines the screen space Vector3 to use
  21630. * @param viewportWidth defines the current width of the viewport
  21631. * @param viewportHeight defines the current height of the viewport
  21632. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21633. * @param view defines the view matrix to use
  21634. * @param projection defines the projection matrix to use
  21635. * @param result defines the Vector3 where to store the result
  21636. */
  21637. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21638. /**
  21639. * Unproject from screen space to object space
  21640. * @param sourceX defines the screen space x coordinate to use
  21641. * @param sourceY defines the screen space y coordinate to use
  21642. * @param sourceZ defines the screen space z coordinate to use
  21643. * @param viewportWidth defines the current width of the viewport
  21644. * @param viewportHeight defines the current height of the viewport
  21645. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21646. * @param view defines the view matrix to use
  21647. * @param projection defines the projection matrix to use
  21648. * @param result defines the Vector3 where to store the result
  21649. */
  21650. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21651. /**
  21652. * Unproject a ray from screen space to object space
  21653. * @param sourceX defines the screen space x coordinate to use
  21654. * @param sourceY defines the screen space y coordinate to use
  21655. * @param viewportWidth defines the current width of the viewport
  21656. * @param viewportHeight defines the current height of the viewport
  21657. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21658. * @param view defines the view matrix to use
  21659. * @param projection defines the projection matrix to use
  21660. * @param ray defines the Ray where to store the result
  21661. */
  21662. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: Readonly<Matrix>, view: Readonly<Matrix>, projection: Readonly<Matrix>, ray: Ray): void;
  21663. /**
  21664. * Gets the minimal coordinate values between two Vector3
  21665. * @param left defines the first operand
  21666. * @param right defines the second operand
  21667. * @returns the new Vector3
  21668. */
  21669. static Minimize(left: Vector3, right: Vector3): Vector3;
  21670. /**
  21671. * Gets the maximal coordinate values between two Vector3
  21672. * @param left defines the first operand
  21673. * @param right defines the second operand
  21674. * @returns the new Vector3
  21675. */
  21676. static Maximize(left: Vector3, right: Vector3): Vector3;
  21677. /**
  21678. * Returns the distance between the vectors "value1" and "value2"
  21679. * @param value1 defines the first operand
  21680. * @param value2 defines the second operand
  21681. * @returns the distance
  21682. */
  21683. static Distance(value1: Vector3, value2: Vector3): number;
  21684. /**
  21685. * Returns the squared distance between the vectors "value1" and "value2"
  21686. * @param value1 defines the first operand
  21687. * @param value2 defines the second operand
  21688. * @returns the squared distance
  21689. */
  21690. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21691. /**
  21692. * Returns a new Vector3 located at the center between "value1" and "value2"
  21693. * @param value1 defines the first operand
  21694. * @param value2 defines the second operand
  21695. * @returns the new Vector3
  21696. */
  21697. static Center(value1: Vector3, value2: Vector3): Vector3;
  21698. /**
  21699. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21700. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21701. * to something in order to rotate it from its local system to the given target system
  21702. * Note: axis1, axis2 and axis3 are normalized during this operation
  21703. * @param axis1 defines the first axis
  21704. * @param axis2 defines the second axis
  21705. * @param axis3 defines the third axis
  21706. * @returns a new Vector3
  21707. */
  21708. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21709. /**
  21710. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21711. * @param axis1 defines the first axis
  21712. * @param axis2 defines the second axis
  21713. * @param axis3 defines the third axis
  21714. * @param ref defines the Vector3 where to store the result
  21715. */
  21716. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21717. }
  21718. /**
  21719. * Vector4 class created for EulerAngle class conversion to Quaternion
  21720. */
  21721. class Vector4 {
  21722. /** x value of the vector */
  21723. x: number;
  21724. /** y value of the vector */
  21725. y: number;
  21726. /** z value of the vector */
  21727. z: number;
  21728. /** w value of the vector */
  21729. w: number;
  21730. /**
  21731. * Creates a Vector4 object from the given floats.
  21732. * @param x x value of the vector
  21733. * @param y y value of the vector
  21734. * @param z z value of the vector
  21735. * @param w w value of the vector
  21736. */
  21737. constructor(
  21738. /** x value of the vector */
  21739. x: number,
  21740. /** y value of the vector */
  21741. y: number,
  21742. /** z value of the vector */
  21743. z: number,
  21744. /** w value of the vector */
  21745. w: number);
  21746. /**
  21747. * Returns the string with the Vector4 coordinates.
  21748. * @returns a string containing all the vector values
  21749. */
  21750. toString(): string;
  21751. /**
  21752. * Returns the string "Vector4".
  21753. * @returns "Vector4"
  21754. */
  21755. getClassName(): string;
  21756. /**
  21757. * Returns the Vector4 hash code.
  21758. * @returns a unique hash code
  21759. */
  21760. getHashCode(): number;
  21761. /**
  21762. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21763. * @returns the resulting array
  21764. */
  21765. asArray(): number[];
  21766. /**
  21767. * Populates the given array from the given index with the Vector4 coordinates.
  21768. * @param array array to populate
  21769. * @param index index of the array to start at (default: 0)
  21770. * @returns the Vector4.
  21771. */
  21772. toArray(array: FloatArray, index?: number): Vector4;
  21773. /**
  21774. * Adds the given vector to the current Vector4.
  21775. * @param otherVector the vector to add
  21776. * @returns the updated Vector4.
  21777. */
  21778. addInPlace(otherVector: Vector4): Vector4;
  21779. /**
  21780. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21781. * @param otherVector the vector to add
  21782. * @returns the resulting vector
  21783. */
  21784. add(otherVector: Vector4): Vector4;
  21785. /**
  21786. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21787. * @param otherVector the vector to add
  21788. * @param result the vector to store the result
  21789. * @returns the current Vector4.
  21790. */
  21791. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21792. /**
  21793. * Subtract in place the given vector from the current Vector4.
  21794. * @param otherVector the vector to subtract
  21795. * @returns the updated Vector4.
  21796. */
  21797. subtractInPlace(otherVector: Vector4): Vector4;
  21798. /**
  21799. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21800. * @param otherVector the vector to add
  21801. * @returns the new vector with the result
  21802. */
  21803. subtract(otherVector: Vector4): Vector4;
  21804. /**
  21805. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21806. * @param otherVector the vector to subtract
  21807. * @param result the vector to store the result
  21808. * @returns the current Vector4.
  21809. */
  21810. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21811. /**
  21812. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21813. */
  21814. /**
  21815. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21816. * @param x value to subtract
  21817. * @param y value to subtract
  21818. * @param z value to subtract
  21819. * @param w value to subtract
  21820. * @returns new vector containing the result
  21821. */
  21822. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21823. /**
  21824. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21825. * @param x value to subtract
  21826. * @param y value to subtract
  21827. * @param z value to subtract
  21828. * @param w value to subtract
  21829. * @param result the vector to store the result in
  21830. * @returns the current Vector4.
  21831. */
  21832. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21833. /**
  21834. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21835. * @returns a new vector with the negated values
  21836. */
  21837. negate(): Vector4;
  21838. /**
  21839. * Multiplies the current Vector4 coordinates by scale (float).
  21840. * @param scale the number to scale with
  21841. * @returns the updated Vector4.
  21842. */
  21843. scaleInPlace(scale: number): Vector4;
  21844. /**
  21845. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21846. * @param scale the number to scale with
  21847. * @returns a new vector with the result
  21848. */
  21849. scale(scale: number): Vector4;
  21850. /**
  21851. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21852. * @param scale the number to scale with
  21853. * @param result a vector to store the result in
  21854. * @returns the current Vector4.
  21855. */
  21856. scaleToRef(scale: number, result: Vector4): Vector4;
  21857. /**
  21858. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21859. * @param scale defines the scale factor
  21860. * @param result defines the Vector4 object where to store the result
  21861. * @returns the unmodified current Vector4
  21862. */
  21863. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21864. /**
  21865. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21866. * @param otherVector the vector to compare against
  21867. * @returns true if they are equal
  21868. */
  21869. equals(otherVector: Vector4): boolean;
  21870. /**
  21871. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21872. * @param otherVector vector to compare against
  21873. * @param epsilon (Default: very small number)
  21874. * @returns true if they are equal
  21875. */
  21876. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21877. /**
  21878. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21879. * @param x x value to compare against
  21880. * @param y y value to compare against
  21881. * @param z z value to compare against
  21882. * @param w w value to compare against
  21883. * @returns true if equal
  21884. */
  21885. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21886. /**
  21887. * Multiplies in place the current Vector4 by the given one.
  21888. * @param otherVector vector to multiple with
  21889. * @returns the updated Vector4.
  21890. */
  21891. multiplyInPlace(otherVector: Vector4): Vector4;
  21892. /**
  21893. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21894. * @param otherVector vector to multiple with
  21895. * @returns resulting new vector
  21896. */
  21897. multiply(otherVector: Vector4): Vector4;
  21898. /**
  21899. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21900. * @param otherVector vector to multiple with
  21901. * @param result vector to store the result
  21902. * @returns the current Vector4.
  21903. */
  21904. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21905. /**
  21906. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21907. * @param x x value multiply with
  21908. * @param y y value multiply with
  21909. * @param z z value multiply with
  21910. * @param w w value multiply with
  21911. * @returns resulting new vector
  21912. */
  21913. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21914. /**
  21915. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21916. * @param otherVector vector to devide with
  21917. * @returns resulting new vector
  21918. */
  21919. divide(otherVector: Vector4): Vector4;
  21920. /**
  21921. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21922. * @param otherVector vector to devide with
  21923. * @param result vector to store the result
  21924. * @returns the current Vector4.
  21925. */
  21926. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21927. /**
  21928. * Divides the current Vector3 coordinates by the given ones.
  21929. * @param otherVector vector to devide with
  21930. * @returns the updated Vector3.
  21931. */
  21932. divideInPlace(otherVector: Vector4): Vector4;
  21933. /**
  21934. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21935. * @param other defines the second operand
  21936. * @returns the current updated Vector4
  21937. */
  21938. minimizeInPlace(other: Vector4): Vector4;
  21939. /**
  21940. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21941. * @param other defines the second operand
  21942. * @returns the current updated Vector4
  21943. */
  21944. maximizeInPlace(other: Vector4): Vector4;
  21945. /**
  21946. * Gets a new Vector4 from current Vector4 floored values
  21947. * @returns a new Vector4
  21948. */
  21949. floor(): Vector4;
  21950. /**
  21951. * Gets a new Vector4 from current Vector3 floored values
  21952. * @returns a new Vector4
  21953. */
  21954. fract(): Vector4;
  21955. /**
  21956. * Returns the Vector4 length (float).
  21957. * @returns the length
  21958. */
  21959. length(): number;
  21960. /**
  21961. * Returns the Vector4 squared length (float).
  21962. * @returns the length squared
  21963. */
  21964. lengthSquared(): number;
  21965. /**
  21966. * Normalizes in place the Vector4.
  21967. * @returns the updated Vector4.
  21968. */
  21969. normalize(): Vector4;
  21970. /**
  21971. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21972. * @returns this converted to a new vector3
  21973. */
  21974. toVector3(): Vector3;
  21975. /**
  21976. * Returns a new Vector4 copied from the current one.
  21977. * @returns the new cloned vector
  21978. */
  21979. clone(): Vector4;
  21980. /**
  21981. * Updates the current Vector4 with the given one coordinates.
  21982. * @param source the source vector to copy from
  21983. * @returns the updated Vector4.
  21984. */
  21985. copyFrom(source: Vector4): Vector4;
  21986. /**
  21987. * Updates the current Vector4 coordinates with the given floats.
  21988. * @param x float to copy from
  21989. * @param y float to copy from
  21990. * @param z float to copy from
  21991. * @param w float to copy from
  21992. * @returns the updated Vector4.
  21993. */
  21994. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21995. /**
  21996. * Updates the current Vector4 coordinates with the given floats.
  21997. * @param x float to set from
  21998. * @param y float to set from
  21999. * @param z float to set from
  22000. * @param w float to set from
  22001. * @returns the updated Vector4.
  22002. */
  22003. set(x: number, y: number, z: number, w: number): Vector4;
  22004. /**
  22005. * Copies the given float to the current Vector3 coordinates
  22006. * @param v defines the x, y, z and w coordinates of the operand
  22007. * @returns the current updated Vector3
  22008. */
  22009. setAll(v: number): Vector4;
  22010. /**
  22011. * Returns a new Vector4 set from the starting index of the given array.
  22012. * @param array the array to pull values from
  22013. * @param offset the offset into the array to start at
  22014. * @returns the new vector
  22015. */
  22016. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  22017. /**
  22018. * Updates the given vector "result" from the starting index of the given array.
  22019. * @param array the array to pull values from
  22020. * @param offset the offset into the array to start at
  22021. * @param result the vector to store the result in
  22022. */
  22023. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  22024. /**
  22025. * Updates the given vector "result" from the starting index of the given Float32Array.
  22026. * @param array the array to pull values from
  22027. * @param offset the offset into the array to start at
  22028. * @param result the vector to store the result in
  22029. */
  22030. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  22031. /**
  22032. * Updates the given vector "result" coordinates from the given floats.
  22033. * @param x float to set from
  22034. * @param y float to set from
  22035. * @param z float to set from
  22036. * @param w float to set from
  22037. * @param result the vector to the floats in
  22038. */
  22039. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22040. /**
  22041. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22042. * @returns the new vector
  22043. */
  22044. static Zero(): Vector4;
  22045. /**
  22046. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22047. * @returns the new vector
  22048. */
  22049. static One(): Vector4;
  22050. /**
  22051. * Returns a new normalized Vector4 from the given one.
  22052. * @param vector the vector to normalize
  22053. * @returns the vector
  22054. */
  22055. static Normalize(vector: Vector4): Vector4;
  22056. /**
  22057. * Updates the given vector "result" from the normalization of the given one.
  22058. * @param vector the vector to normalize
  22059. * @param result the vector to store the result in
  22060. */
  22061. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  22062. /**
  22063. * Returns a vector with the minimum values from the left and right vectors
  22064. * @param left left vector to minimize
  22065. * @param right right vector to minimize
  22066. * @returns a new vector with the minimum of the left and right vector values
  22067. */
  22068. static Minimize(left: Vector4, right: Vector4): Vector4;
  22069. /**
  22070. * Returns a vector with the maximum values from the left and right vectors
  22071. * @param left left vector to maximize
  22072. * @param right right vector to maximize
  22073. * @returns a new vector with the maximum of the left and right vector values
  22074. */
  22075. static Maximize(left: Vector4, right: Vector4): Vector4;
  22076. /**
  22077. * Returns the distance (float) between the vectors "value1" and "value2".
  22078. * @param value1 value to calulate the distance between
  22079. * @param value2 value to calulate the distance between
  22080. * @return the distance between the two vectors
  22081. */
  22082. static Distance(value1: Vector4, value2: Vector4): number;
  22083. /**
  22084. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22085. * @param value1 value to calulate the distance between
  22086. * @param value2 value to calulate the distance between
  22087. * @return the distance between the two vectors squared
  22088. */
  22089. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  22090. /**
  22091. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22092. * @param value1 value to calulate the center between
  22093. * @param value2 value to calulate the center between
  22094. * @return the center between the two vectors
  22095. */
  22096. static Center(value1: Vector4, value2: Vector4): Vector4;
  22097. /**
  22098. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22099. * This methods computes transformed normalized direction vectors only.
  22100. * @param vector the vector to transform
  22101. * @param transformation the transformation matrix to apply
  22102. * @returns the new vector
  22103. */
  22104. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  22105. /**
  22106. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22107. * This methods computes transformed normalized direction vectors only.
  22108. * @param vector the vector to transform
  22109. * @param transformation the transformation matrix to apply
  22110. * @param result the vector to store the result in
  22111. */
  22112. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  22113. /**
  22114. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22115. * This methods computes transformed normalized direction vectors only.
  22116. * @param x value to transform
  22117. * @param y value to transform
  22118. * @param z value to transform
  22119. * @param w value to transform
  22120. * @param transformation the transformation matrix to apply
  22121. * @param result the vector to store the results in
  22122. */
  22123. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  22124. }
  22125. /**
  22126. * Interface for the size containing width and height
  22127. */
  22128. interface ISize {
  22129. /**
  22130. * Width
  22131. */
  22132. width: number;
  22133. /**
  22134. * Heighht
  22135. */
  22136. height: number;
  22137. }
  22138. /**
  22139. * Size containing widht and height
  22140. */
  22141. class Size implements ISize {
  22142. /**
  22143. * Width
  22144. */
  22145. width: number;
  22146. /**
  22147. * Height
  22148. */
  22149. height: number;
  22150. /**
  22151. * Creates a Size object from the given width and height (floats).
  22152. * @param width width of the new size
  22153. * @param height height of the new size
  22154. */
  22155. constructor(width: number, height: number);
  22156. /**
  22157. * Returns a string with the Size width and height
  22158. * @returns a string with the Size width and height
  22159. */
  22160. toString(): string;
  22161. /**
  22162. * "Size"
  22163. * @returns the string "Size"
  22164. */
  22165. getClassName(): string;
  22166. /**
  22167. * Returns the Size hash code.
  22168. * @returns a hash code for a unique width and height
  22169. */
  22170. getHashCode(): number;
  22171. /**
  22172. * Updates the current size from the given one.
  22173. * @param src the given size
  22174. */
  22175. copyFrom(src: Size): void;
  22176. /**
  22177. * Updates in place the current Size from the given floats.
  22178. * @param width width of the new size
  22179. * @param height height of the new size
  22180. * @returns the updated Size.
  22181. */
  22182. copyFromFloats(width: number, height: number): Size;
  22183. /**
  22184. * Updates in place the current Size from the given floats.
  22185. * @param width width to set
  22186. * @param height height to set
  22187. * @returns the updated Size.
  22188. */
  22189. set(width: number, height: number): Size;
  22190. /**
  22191. * Multiplies the width and height by numbers
  22192. * @param w factor to multiple the width by
  22193. * @param h factor to multiple the height by
  22194. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22195. */
  22196. multiplyByFloats(w: number, h: number): Size;
  22197. /**
  22198. * Clones the size
  22199. * @returns a new Size copied from the given one.
  22200. */
  22201. clone(): Size;
  22202. /**
  22203. * True if the current Size and the given one width and height are strictly equal.
  22204. * @param other the other size to compare against
  22205. * @returns True if the current Size and the given one width and height are strictly equal.
  22206. */
  22207. equals(other: Size): boolean;
  22208. /**
  22209. * The surface of the Size : width * height (float).
  22210. */
  22211. readonly surface: number;
  22212. /**
  22213. * Create a new size of zero
  22214. * @returns a new Size set to (0.0, 0.0)
  22215. */
  22216. static Zero(): Size;
  22217. /**
  22218. * Sums the width and height of two sizes
  22219. * @param otherSize size to add to this size
  22220. * @returns a new Size set as the addition result of the current Size and the given one.
  22221. */
  22222. add(otherSize: Size): Size;
  22223. /**
  22224. * Subtracts the width and height of two
  22225. * @param otherSize size to subtract to this size
  22226. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22227. */
  22228. subtract(otherSize: Size): Size;
  22229. /**
  22230. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22231. * @param start starting size to lerp between
  22232. * @param end end size to lerp between
  22233. * @param amount amount to lerp between the start and end values
  22234. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22235. */
  22236. static Lerp(start: Size, end: Size, amount: number): Size;
  22237. }
  22238. /**
  22239. * Class used to store quaternion data
  22240. * @see https://en.wikipedia.org/wiki/Quaternion
  22241. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22242. */
  22243. class Quaternion {
  22244. /** defines the first component (0 by default) */
  22245. x: number;
  22246. /** defines the second component (0 by default) */
  22247. y: number;
  22248. /** defines the third component (0 by default) */
  22249. z: number;
  22250. /** defines the fourth component (1.0 by default) */
  22251. w: number;
  22252. /**
  22253. * Creates a new Quaternion from the given floats
  22254. * @param x defines the first component (0 by default)
  22255. * @param y defines the second component (0 by default)
  22256. * @param z defines the third component (0 by default)
  22257. * @param w defines the fourth component (1.0 by default)
  22258. */
  22259. constructor(
  22260. /** defines the first component (0 by default) */
  22261. x?: number,
  22262. /** defines the second component (0 by default) */
  22263. y?: number,
  22264. /** defines the third component (0 by default) */
  22265. z?: number,
  22266. /** defines the fourth component (1.0 by default) */
  22267. w?: number);
  22268. /**
  22269. * Gets a string representation for the current quaternion
  22270. * @returns a string with the Quaternion coordinates
  22271. */
  22272. toString(): string;
  22273. /**
  22274. * Gets the class name of the quaternion
  22275. * @returns the string "Quaternion"
  22276. */
  22277. getClassName(): string;
  22278. /**
  22279. * Gets a hash code for this quaternion
  22280. * @returns the quaternion hash code
  22281. */
  22282. getHashCode(): number;
  22283. /**
  22284. * Copy the quaternion to an array
  22285. * @returns a new array populated with 4 elements from the quaternion coordinates
  22286. */
  22287. asArray(): number[];
  22288. /**
  22289. * Check if two quaternions are equals
  22290. * @param otherQuaternion defines the second operand
  22291. * @return true if the current quaternion and the given one coordinates are strictly equals
  22292. */
  22293. equals(otherQuaternion: Quaternion): boolean;
  22294. /**
  22295. * Clone the current quaternion
  22296. * @returns a new quaternion copied from the current one
  22297. */
  22298. clone(): Quaternion;
  22299. /**
  22300. * Copy a quaternion to the current one
  22301. * @param other defines the other quaternion
  22302. * @returns the updated current quaternion
  22303. */
  22304. copyFrom(other: Quaternion): Quaternion;
  22305. /**
  22306. * Updates the current quaternion with the given float coordinates
  22307. * @param x defines the x coordinate
  22308. * @param y defines the y coordinate
  22309. * @param z defines the z coordinate
  22310. * @param w defines the w coordinate
  22311. * @returns the updated current quaternion
  22312. */
  22313. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22314. /**
  22315. * Updates the current quaternion from the given float coordinates
  22316. * @param x defines the x coordinate
  22317. * @param y defines the y coordinate
  22318. * @param z defines the z coordinate
  22319. * @param w defines the w coordinate
  22320. * @returns the updated current quaternion
  22321. */
  22322. set(x: number, y: number, z: number, w: number): Quaternion;
  22323. /**
  22324. * Adds two quaternions
  22325. * @param other defines the second operand
  22326. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22327. */
  22328. add(other: Quaternion): Quaternion;
  22329. /**
  22330. * Add a quaternion to the current one
  22331. * @param other defines the quaternion to add
  22332. * @returns the current quaternion
  22333. */
  22334. addInPlace(other: Quaternion): Quaternion;
  22335. /**
  22336. * Subtract two quaternions
  22337. * @param other defines the second operand
  22338. * @returns a new quaternion as the subtraction result of the given one from the current one
  22339. */
  22340. subtract(other: Quaternion): Quaternion;
  22341. /**
  22342. * Multiplies the current quaternion by a scale factor
  22343. * @param value defines the scale factor
  22344. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22345. */
  22346. scale(value: number): Quaternion;
  22347. /**
  22348. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22349. * @param scale defines the scale factor
  22350. * @param result defines the Quaternion object where to store the result
  22351. * @returns the unmodified current quaternion
  22352. */
  22353. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22354. /**
  22355. * Multiplies in place the current quaternion by a scale factor
  22356. * @param value defines the scale factor
  22357. * @returns the current modified quaternion
  22358. */
  22359. scaleInPlace(value: number): Quaternion;
  22360. /**
  22361. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22362. * @param scale defines the scale factor
  22363. * @param result defines the Quaternion object where to store the result
  22364. * @returns the unmodified current quaternion
  22365. */
  22366. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22367. /**
  22368. * Multiplies two quaternions
  22369. * @param q1 defines the second operand
  22370. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22371. */
  22372. multiply(q1: Quaternion): Quaternion;
  22373. /**
  22374. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22375. * @param q1 defines the second operand
  22376. * @param result defines the target quaternion
  22377. * @returns the current quaternion
  22378. */
  22379. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  22380. /**
  22381. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22382. * @param q1 defines the second operand
  22383. * @returns the currentupdated quaternion
  22384. */
  22385. multiplyInPlace(q1: Quaternion): Quaternion;
  22386. /**
  22387. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22388. * @param ref defines the target quaternion
  22389. * @returns the current quaternion
  22390. */
  22391. conjugateToRef(ref: Quaternion): Quaternion;
  22392. /**
  22393. * Conjugates in place (1-q) the current quaternion
  22394. * @returns the current updated quaternion
  22395. */
  22396. conjugateInPlace(): Quaternion;
  22397. /**
  22398. * Conjugates in place (1-q) the current quaternion
  22399. * @returns a new quaternion
  22400. */
  22401. conjugate(): Quaternion;
  22402. /**
  22403. * Gets length of current quaternion
  22404. * @returns the quaternion length (float)
  22405. */
  22406. length(): number;
  22407. /**
  22408. * Normalize in place the current quaternion
  22409. * @returns the current updated quaternion
  22410. */
  22411. normalize(): Quaternion;
  22412. /**
  22413. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22414. * @param order is a reserved parameter and is ignore for now
  22415. * @returns a new Vector3 containing the Euler angles
  22416. */
  22417. toEulerAngles(order?: string): Vector3;
  22418. /**
  22419. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22420. * @param result defines the vector which will be filled with the Euler angles
  22421. * @param order is a reserved parameter and is ignore for now
  22422. * @returns the current unchanged quaternion
  22423. */
  22424. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22425. /**
  22426. * Updates the given rotation matrix with the current quaternion values
  22427. * @param result defines the target matrix
  22428. * @returns the current unchanged quaternion
  22429. */
  22430. toRotationMatrix(result: Matrix): Quaternion;
  22431. /**
  22432. * Updates the current quaternion from the given rotation matrix values
  22433. * @param matrix defines the source matrix
  22434. * @returns the current updated quaternion
  22435. */
  22436. fromRotationMatrix(matrix: Matrix): Quaternion;
  22437. /**
  22438. * Creates a new quaternion from a rotation matrix
  22439. * @param matrix defines the source matrix
  22440. * @returns a new quaternion created from the given rotation matrix values
  22441. */
  22442. static FromRotationMatrix(matrix: Matrix): Quaternion;
  22443. /**
  22444. * Updates the given quaternion with the given rotation matrix values
  22445. * @param matrix defines the source matrix
  22446. * @param result defines the target quaternion
  22447. */
  22448. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  22449. /**
  22450. * Returns the dot product (float) between the quaternions "left" and "right"
  22451. * @param left defines the left operand
  22452. * @param right defines the right operand
  22453. * @returns the dot product
  22454. */
  22455. static Dot(left: Quaternion, right: Quaternion): number;
  22456. /**
  22457. * Checks if the two quaternions are close to each other
  22458. * @param quat0 defines the first quaternion to check
  22459. * @param quat1 defines the second quaternion to check
  22460. * @returns true if the two quaternions are close to each other
  22461. */
  22462. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  22463. /**
  22464. * Creates an empty quaternion
  22465. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22466. */
  22467. static Zero(): Quaternion;
  22468. /**
  22469. * Inverse a given quaternion
  22470. * @param q defines the source quaternion
  22471. * @returns a new quaternion as the inverted current quaternion
  22472. */
  22473. static Inverse(q: Quaternion): Quaternion;
  22474. /**
  22475. * Inverse a given quaternion
  22476. * @param q defines the source quaternion
  22477. * @param result the quaternion the result will be stored in
  22478. * @returns the result quaternion
  22479. */
  22480. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22481. /**
  22482. * Creates an identity quaternion
  22483. * @returns the identity quaternion
  22484. */
  22485. static Identity(): Quaternion;
  22486. /**
  22487. * Gets a boolean indicating if the given quaternion is identity
  22488. * @param quaternion defines the quaternion to check
  22489. * @returns true if the quaternion is identity
  22490. */
  22491. static IsIdentity(quaternion: Quaternion): boolean;
  22492. /**
  22493. * Creates a quaternion from a rotation around an axis
  22494. * @param axis defines the axis to use
  22495. * @param angle defines the angle to use
  22496. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22497. */
  22498. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22499. /**
  22500. * Creates a rotation around an axis and stores it into the given quaternion
  22501. * @param axis defines the axis to use
  22502. * @param angle defines the angle to use
  22503. * @param result defines the target quaternion
  22504. * @returns the target quaternion
  22505. */
  22506. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22507. /**
  22508. * Creates a new quaternion from data stored into an array
  22509. * @param array defines the data source
  22510. * @param offset defines the offset in the source array where the data starts
  22511. * @returns a new quaternion
  22512. */
  22513. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22514. /**
  22515. * Create a quaternion from Euler rotation angles
  22516. * @param x Pitch
  22517. * @param y Yaw
  22518. * @param z Roll
  22519. * @returns the new Quaternion
  22520. */
  22521. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22522. /**
  22523. * Updates a quaternion from Euler rotation angles
  22524. * @param x Pitch
  22525. * @param y Yaw
  22526. * @param z Roll
  22527. * @param result the quaternion to store the result
  22528. * @returns the updated quaternion
  22529. */
  22530. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22531. /**
  22532. * Create a quaternion from Euler rotation vector
  22533. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22534. * @returns the new Quaternion
  22535. */
  22536. static FromEulerVector(vec: Vector3): Quaternion;
  22537. /**
  22538. * Updates a quaternion from Euler rotation vector
  22539. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22540. * @param result the quaternion to store the result
  22541. * @returns the updated quaternion
  22542. */
  22543. static FromEulerVectorToRef(vec: Vector3, result: Quaternion): Quaternion;
  22544. /**
  22545. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22546. * @param yaw defines the rotation around Y axis
  22547. * @param pitch defines the rotation around X axis
  22548. * @param roll defines the rotation around Z axis
  22549. * @returns the new quaternion
  22550. */
  22551. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22552. /**
  22553. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22554. * @param yaw defines the rotation around Y axis
  22555. * @param pitch defines the rotation around X axis
  22556. * @param roll defines the rotation around Z axis
  22557. * @param result defines the target quaternion
  22558. */
  22559. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22560. /**
  22561. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22562. * @param alpha defines the rotation around first axis
  22563. * @param beta defines the rotation around second axis
  22564. * @param gamma defines the rotation around third axis
  22565. * @returns the new quaternion
  22566. */
  22567. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22568. /**
  22569. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22570. * @param alpha defines the rotation around first axis
  22571. * @param beta defines the rotation around second axis
  22572. * @param gamma defines the rotation around third axis
  22573. * @param result defines the target quaternion
  22574. */
  22575. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22576. /**
  22577. * 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)
  22578. * @param axis1 defines the first axis
  22579. * @param axis2 defines the second axis
  22580. * @param axis3 defines the third axis
  22581. * @returns the new quaternion
  22582. */
  22583. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22584. /**
  22585. * 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
  22586. * @param axis1 defines the first axis
  22587. * @param axis2 defines the second axis
  22588. * @param axis3 defines the third axis
  22589. * @param ref defines the target quaternion
  22590. */
  22591. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22592. /**
  22593. * Interpolates between two quaternions
  22594. * @param left defines first quaternion
  22595. * @param right defines second quaternion
  22596. * @param amount defines the gradient to use
  22597. * @returns the new interpolated quaternion
  22598. */
  22599. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22600. /**
  22601. * Interpolates between two quaternions and stores it into a target quaternion
  22602. * @param left defines first quaternion
  22603. * @param right defines second quaternion
  22604. * @param amount defines the gradient to use
  22605. * @param result defines the target quaternion
  22606. */
  22607. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22608. /**
  22609. * Interpolate between two quaternions using Hermite interpolation
  22610. * @param value1 defines first quaternion
  22611. * @param tangent1 defines the incoming tangent
  22612. * @param value2 defines second quaternion
  22613. * @param tangent2 defines the outgoing tangent
  22614. * @param amount defines the target quaternion
  22615. * @returns the new interpolated quaternion
  22616. */
  22617. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22618. }
  22619. /**
  22620. * Class used to store matrix data (4x4)
  22621. */
  22622. class Matrix {
  22623. private static _updateFlagSeed;
  22624. private static _identityReadOnly;
  22625. private _isIdentity;
  22626. private _isIdentityDirty;
  22627. private _isIdentity3x2;
  22628. private _isIdentity3x2Dirty;
  22629. /**
  22630. * Gets the update flag of the matrix which is an unique number for the matrix.
  22631. * It will be incremented every time the matrix data change.
  22632. * You can use it to speed the comparison between two versions of the same matrix.
  22633. */
  22634. updateFlag: number;
  22635. private readonly _m;
  22636. /**
  22637. * Gets the internal data of the matrix
  22638. */
  22639. readonly m: Readonly<Float32Array>;
  22640. /** @hidden */
  22641. _markAsUpdated(): void;
  22642. /** @hidden */
  22643. private _updateIdentityStatus;
  22644. /**
  22645. * Creates an empty matrix (filled with zeros)
  22646. */
  22647. constructor();
  22648. /**
  22649. * Check if the current matrix is identity
  22650. * @returns true is the matrix is the identity matrix
  22651. */
  22652. isIdentity(): boolean;
  22653. /**
  22654. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22655. * @returns true is the matrix is the identity matrix
  22656. */
  22657. isIdentityAs3x2(): boolean;
  22658. /**
  22659. * Gets the determinant of the matrix
  22660. * @returns the matrix determinant
  22661. */
  22662. determinant(): number;
  22663. /**
  22664. * Returns the matrix as a Float32Array
  22665. * @returns the matrix underlying array
  22666. */
  22667. toArray(): Readonly<Float32Array>;
  22668. /**
  22669. * Returns the matrix as a Float32Array
  22670. * @returns the matrix underlying array.
  22671. */
  22672. asArray(): Readonly<Float32Array>;
  22673. /**
  22674. * Inverts the current matrix in place
  22675. * @returns the current inverted matrix
  22676. */
  22677. invert(): Matrix;
  22678. /**
  22679. * Sets all the matrix elements to zero
  22680. * @returns the current matrix
  22681. */
  22682. reset(): Matrix;
  22683. /**
  22684. * Adds the current matrix with a second one
  22685. * @param other defines the matrix to add
  22686. * @returns a new matrix as the addition of the current matrix and the given one
  22687. */
  22688. add(other: Matrix): Matrix;
  22689. /**
  22690. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22691. * @param other defines the matrix to add
  22692. * @param result defines the target matrix
  22693. * @returns the current matrix
  22694. */
  22695. addToRef(other: Matrix, result: Matrix): Matrix;
  22696. /**
  22697. * Adds in place the given matrix to the current matrix
  22698. * @param other defines the second operand
  22699. * @returns the current updated matrix
  22700. */
  22701. addToSelf(other: Matrix): Matrix;
  22702. /**
  22703. * Sets the given matrix to the current inverted Matrix
  22704. * @param other defines the target matrix
  22705. * @returns the unmodified current matrix
  22706. */
  22707. invertToRef(other: Matrix): Matrix;
  22708. /**
  22709. * add a value at the specified position in the current Matrix
  22710. * @param index the index of the value within the matrix. between 0 and 15.
  22711. * @param value the value to be added
  22712. * @returns the current updated matrix
  22713. */
  22714. addAtIndex(index: number, value: number): Matrix;
  22715. /**
  22716. * mutiply the specified position in the current Matrix by a value
  22717. * @param index the index of the value within the matrix. between 0 and 15.
  22718. * @param value the value to be added
  22719. * @returns the current updated matrix
  22720. */
  22721. multiplyAtIndex(index: number, value: number): Matrix;
  22722. /**
  22723. * Inserts the translation vector (using 3 floats) in the current matrix
  22724. * @param x defines the 1st component of the translation
  22725. * @param y defines the 2nd component of the translation
  22726. * @param z defines the 3rd component of the translation
  22727. * @returns the current updated matrix
  22728. */
  22729. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22730. /**
  22731. * Inserts the translation vector in the current matrix
  22732. * @param vector3 defines the translation to insert
  22733. * @returns the current updated matrix
  22734. */
  22735. setTranslation(vector3: Vector3): Matrix;
  22736. /**
  22737. * Gets the translation value of the current matrix
  22738. * @returns a new Vector3 as the extracted translation from the matrix
  22739. */
  22740. getTranslation(): Vector3;
  22741. /**
  22742. * Fill a Vector3 with the extracted translation from the matrix
  22743. * @param result defines the Vector3 where to store the translation
  22744. * @returns the current matrix
  22745. */
  22746. getTranslationToRef(result: Vector3): Matrix;
  22747. /**
  22748. * Remove rotation and scaling part from the matrix
  22749. * @returns the updated matrix
  22750. */
  22751. removeRotationAndScaling(): Matrix;
  22752. /**
  22753. * Multiply two matrices
  22754. * @param other defines the second operand
  22755. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22756. */
  22757. multiply(other: Readonly<Matrix>): Matrix;
  22758. /**
  22759. * Copy the current matrix from the given one
  22760. * @param other defines the source matrix
  22761. * @returns the current updated matrix
  22762. */
  22763. copyFrom(other: Readonly<Matrix>): Matrix;
  22764. /**
  22765. * Populates the given array from the starting index with the current matrix values
  22766. * @param array defines the target array
  22767. * @param offset defines the offset in the target array where to start storing values
  22768. * @returns the current matrix
  22769. */
  22770. copyToArray(array: Float32Array, offset?: number): Matrix;
  22771. /**
  22772. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22773. * @param other defines the second operand
  22774. * @param result defines the matrix where to store the multiplication
  22775. * @returns the current matrix
  22776. */
  22777. multiplyToRef(other: Readonly<Matrix>, result: Matrix): Matrix;
  22778. /**
  22779. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22780. * @param other defines the second operand
  22781. * @param result defines the array where to store the multiplication
  22782. * @param offset defines the offset in the target array where to start storing values
  22783. * @returns the current matrix
  22784. */
  22785. multiplyToArray(other: Readonly<Matrix>, result: Float32Array, offset: number): Matrix;
  22786. /**
  22787. * Check equality between this matrix and a second one
  22788. * @param value defines the second matrix to compare
  22789. * @returns true is the current matrix and the given one values are strictly equal
  22790. */
  22791. equals(value: Matrix): boolean;
  22792. /**
  22793. * Clone the current matrix
  22794. * @returns a new matrix from the current matrix
  22795. */
  22796. clone(): Matrix;
  22797. /**
  22798. * Returns the name of the current matrix class
  22799. * @returns the string "Matrix"
  22800. */
  22801. getClassName(): string;
  22802. /**
  22803. * Gets the hash code of the current matrix
  22804. * @returns the hash code
  22805. */
  22806. getHashCode(): number;
  22807. /**
  22808. * Decomposes the current Matrix into a translation, rotation and scaling components
  22809. * @param scale defines the scale vector3 given as a reference to update
  22810. * @param rotation defines the rotation quaternion given as a reference to update
  22811. * @param translation defines the translation vector3 given as a reference to update
  22812. * @returns true if operation was successful
  22813. */
  22814. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22815. /**
  22816. * Gets specific row of the matrix
  22817. * @param index defines the number of the row to get
  22818. * @returns the index-th row of the current matrix as a new Vector4
  22819. */
  22820. getRow(index: number): Nullable<Vector4>;
  22821. /**
  22822. * Sets the index-th row of the current matrix to the vector4 values
  22823. * @param index defines the number of the row to set
  22824. * @param row defines the target vector4
  22825. * @returns the updated current matrix
  22826. */
  22827. setRow(index: number, row: Vector4): Matrix;
  22828. /**
  22829. * Compute the transpose of the matrix
  22830. * @returns the new transposed matrix
  22831. */
  22832. transpose(): Matrix;
  22833. /**
  22834. * Compute the transpose of the matrix and store it in a given matrix
  22835. * @param result defines the target matrix
  22836. * @returns the current matrix
  22837. */
  22838. transposeToRef(result: Matrix): Matrix;
  22839. /**
  22840. * Sets the index-th row of the current matrix with the given 4 x float values
  22841. * @param index defines the row index
  22842. * @param x defines the x component to set
  22843. * @param y defines the y component to set
  22844. * @param z defines the z component to set
  22845. * @param w defines the w component to set
  22846. * @returns the updated current matrix
  22847. */
  22848. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22849. /**
  22850. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22851. * @param scale defines the scale factor
  22852. * @returns a new matrix
  22853. */
  22854. scale(scale: number): Matrix;
  22855. /**
  22856. * Scale the current matrix values by a factor to a given result matrix
  22857. * @param scale defines the scale factor
  22858. * @param result defines the matrix to store the result
  22859. * @returns the current matrix
  22860. */
  22861. scaleToRef(scale: number, result: Matrix): Matrix;
  22862. /**
  22863. * Scale the current matrix values by a factor and add the result to a given matrix
  22864. * @param scale defines the scale factor
  22865. * @param result defines the Matrix to store the result
  22866. * @returns the current matrix
  22867. */
  22868. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22869. /**
  22870. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22871. * @param ref matrix to store the result
  22872. */
  22873. toNormalMatrix(ref: Matrix): void;
  22874. /**
  22875. * Gets only rotation part of the current matrix
  22876. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22877. */
  22878. getRotationMatrix(): Matrix;
  22879. /**
  22880. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22881. * @param result defines the target matrix to store data to
  22882. * @returns the current matrix
  22883. */
  22884. getRotationMatrixToRef(result: Matrix): Matrix;
  22885. /**
  22886. * Toggles model matrix from being right handed to left handed in place and vice versa
  22887. */
  22888. toggleModelMatrixHandInPlace(): void;
  22889. /**
  22890. * Toggles projection matrix from being right handed to left handed in place and vice versa
  22891. */
  22892. toggleProjectionMatrixHandInPlace(): void;
  22893. /**
  22894. * Creates a matrix from an array
  22895. * @param array defines the source array
  22896. * @param offset defines an offset in the source array
  22897. * @returns a new Matrix set from the starting index of the given array
  22898. */
  22899. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22900. /**
  22901. * Copy the content of an array into a given matrix
  22902. * @param array defines the source array
  22903. * @param offset defines an offset in the source array
  22904. * @param result defines the target matrix
  22905. */
  22906. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22907. /**
  22908. * Stores an array into a matrix after having multiplied each component by a given factor
  22909. * @param array defines the source array
  22910. * @param offset defines the offset in the source array
  22911. * @param scale defines the scaling factor
  22912. * @param result defines the target matrix
  22913. */
  22914. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22915. /**
  22916. * Gets an identity matrix that must not be updated
  22917. */
  22918. static readonly IdentityReadOnly: Readonly<Matrix>;
  22919. /**
  22920. * Stores a list of values (16) inside a given matrix
  22921. * @param initialM11 defines 1st value of 1st row
  22922. * @param initialM12 defines 2nd value of 1st row
  22923. * @param initialM13 defines 3rd value of 1st row
  22924. * @param initialM14 defines 4th value of 1st row
  22925. * @param initialM21 defines 1st value of 2nd row
  22926. * @param initialM22 defines 2nd value of 2nd row
  22927. * @param initialM23 defines 3rd value of 2nd row
  22928. * @param initialM24 defines 4th value of 2nd row
  22929. * @param initialM31 defines 1st value of 3rd row
  22930. * @param initialM32 defines 2nd value of 3rd row
  22931. * @param initialM33 defines 3rd value of 3rd row
  22932. * @param initialM34 defines 4th value of 3rd row
  22933. * @param initialM41 defines 1st value of 4th row
  22934. * @param initialM42 defines 2nd value of 4th row
  22935. * @param initialM43 defines 3rd value of 4th row
  22936. * @param initialM44 defines 4th value of 4th row
  22937. * @param result defines the target matrix
  22938. */
  22939. 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;
  22940. /**
  22941. * Creates new matrix from a list of values (16)
  22942. * @param initialM11 defines 1st value of 1st row
  22943. * @param initialM12 defines 2nd value of 1st row
  22944. * @param initialM13 defines 3rd value of 1st row
  22945. * @param initialM14 defines 4th value of 1st row
  22946. * @param initialM21 defines 1st value of 2nd row
  22947. * @param initialM22 defines 2nd value of 2nd row
  22948. * @param initialM23 defines 3rd value of 2nd row
  22949. * @param initialM24 defines 4th value of 2nd row
  22950. * @param initialM31 defines 1st value of 3rd row
  22951. * @param initialM32 defines 2nd value of 3rd row
  22952. * @param initialM33 defines 3rd value of 3rd row
  22953. * @param initialM34 defines 4th value of 3rd row
  22954. * @param initialM41 defines 1st value of 4th row
  22955. * @param initialM42 defines 2nd value of 4th row
  22956. * @param initialM43 defines 3rd value of 4th row
  22957. * @param initialM44 defines 4th value of 4th row
  22958. * @returns the new matrix
  22959. */
  22960. 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;
  22961. /**
  22962. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22963. * @param scale defines the scale vector3
  22964. * @param rotation defines the rotation quaternion
  22965. * @param translation defines the translation vector3
  22966. * @returns a new matrix
  22967. */
  22968. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22969. /**
  22970. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22971. * @param scale defines the scale vector3
  22972. * @param rotation defines the rotation quaternion
  22973. * @param translation defines the translation vector3
  22974. * @param result defines the target matrix
  22975. */
  22976. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22977. /**
  22978. * Creates a new identity matrix
  22979. * @returns a new identity matrix
  22980. */
  22981. static Identity(): Matrix;
  22982. /**
  22983. * Creates a new identity matrix and stores the result in a given matrix
  22984. * @param result defines the target matrix
  22985. */
  22986. static IdentityToRef(result: Matrix): void;
  22987. /**
  22988. * Creates a new zero matrix
  22989. * @returns a new zero matrix
  22990. */
  22991. static Zero(): Matrix;
  22992. /**
  22993. * Creates a new rotation matrix for "angle" radians around the X axis
  22994. * @param angle defines the angle (in radians) to use
  22995. * @return the new matrix
  22996. */
  22997. static RotationX(angle: number): Matrix;
  22998. /**
  22999. * Creates a new matrix as the invert of a given matrix
  23000. * @param source defines the source matrix
  23001. * @returns the new matrix
  23002. */
  23003. static Invert(source: Matrix): Matrix;
  23004. /**
  23005. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23006. * @param angle defines the angle (in radians) to use
  23007. * @param result defines the target matrix
  23008. */
  23009. static RotationXToRef(angle: number, result: Matrix): void;
  23010. /**
  23011. * Creates a new rotation matrix for "angle" radians around the Y axis
  23012. * @param angle defines the angle (in radians) to use
  23013. * @return the new matrix
  23014. */
  23015. static RotationY(angle: number): Matrix;
  23016. /**
  23017. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23018. * @param angle defines the angle (in radians) to use
  23019. * @param result defines the target matrix
  23020. */
  23021. static RotationYToRef(angle: number, result: Matrix): void;
  23022. /**
  23023. * Creates a new rotation matrix for "angle" radians around the Z axis
  23024. * @param angle defines the angle (in radians) to use
  23025. * @return the new matrix
  23026. */
  23027. static RotationZ(angle: number): Matrix;
  23028. /**
  23029. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23030. * @param angle defines the angle (in radians) to use
  23031. * @param result defines the target matrix
  23032. */
  23033. static RotationZToRef(angle: number, result: Matrix): void;
  23034. /**
  23035. * Creates a new rotation matrix for "angle" radians around the given axis
  23036. * @param axis defines the axis to use
  23037. * @param angle defines the angle (in radians) to use
  23038. * @return the new matrix
  23039. */
  23040. static RotationAxis(axis: Vector3, angle: number): Matrix;
  23041. /**
  23042. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23043. * @param axis defines the axis to use
  23044. * @param angle defines the angle (in radians) to use
  23045. * @param result defines the target matrix
  23046. */
  23047. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  23048. /**
  23049. * Creates a rotation matrix
  23050. * @param yaw defines the yaw angle in radians (Y axis)
  23051. * @param pitch defines the pitch angle in radians (X axis)
  23052. * @param roll defines the roll angle in radians (X axis)
  23053. * @returns the new rotation matrix
  23054. */
  23055. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23056. /**
  23057. * Creates a rotation matrix and stores it in a given matrix
  23058. * @param yaw defines the yaw angle in radians (Y axis)
  23059. * @param pitch defines the pitch angle in radians (X axis)
  23060. * @param roll defines the roll angle in radians (X axis)
  23061. * @param result defines the target matrix
  23062. */
  23063. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23064. /**
  23065. * Creates a scaling matrix
  23066. * @param x defines the scale factor on X axis
  23067. * @param y defines the scale factor on Y axis
  23068. * @param z defines the scale factor on Z axis
  23069. * @returns the new matrix
  23070. */
  23071. static Scaling(x: number, y: number, z: number): Matrix;
  23072. /**
  23073. * Creates a scaling matrix and stores it in a given matrix
  23074. * @param x defines the scale factor on X axis
  23075. * @param y defines the scale factor on Y axis
  23076. * @param z defines the scale factor on Z axis
  23077. * @param result defines the target matrix
  23078. */
  23079. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23080. /**
  23081. * Creates a translation matrix
  23082. * @param x defines the translation on X axis
  23083. * @param y defines the translation on Y axis
  23084. * @param z defines the translationon Z axis
  23085. * @returns the new matrix
  23086. */
  23087. static Translation(x: number, y: number, z: number): Matrix;
  23088. /**
  23089. * Creates a translation matrix and stores it in a given matrix
  23090. * @param x defines the translation on X axis
  23091. * @param y defines the translation on Y axis
  23092. * @param z defines the translationon Z axis
  23093. * @param result defines the target matrix
  23094. */
  23095. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23096. /**
  23097. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23098. * @param startValue defines the start value
  23099. * @param endValue defines the end value
  23100. * @param gradient defines the gradient factor
  23101. * @returns the new matrix
  23102. */
  23103. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  23104. /**
  23105. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23106. * @param startValue defines the start value
  23107. * @param endValue defines the end value
  23108. * @param gradient defines the gradient factor
  23109. * @param result defines the Matrix object where to store data
  23110. */
  23111. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  23112. /**
  23113. * Builds a new matrix whose values are computed by:
  23114. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23115. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23116. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23117. * @param startValue defines the first matrix
  23118. * @param endValue defines the second matrix
  23119. * @param gradient defines the gradient between the two matrices
  23120. * @returns the new matrix
  23121. */
  23122. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  23123. /**
  23124. * Update a matrix to values which are computed by:
  23125. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23126. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23127. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23128. * @param startValue defines the first matrix
  23129. * @param endValue defines the second matrix
  23130. * @param gradient defines the gradient between the two matrices
  23131. * @param result defines the target matrix
  23132. */
  23133. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  23134. /**
  23135. * 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"
  23136. * This function works in left handed mode
  23137. * @param eye defines the final position of the entity
  23138. * @param target defines where the entity should look at
  23139. * @param up defines the up vector for the entity
  23140. * @returns the new matrix
  23141. */
  23142. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  23143. /**
  23144. * 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".
  23145. * This function works in left handed mode
  23146. * @param eye defines the final position of the entity
  23147. * @param target defines where the entity should look at
  23148. * @param up defines the up vector for the entity
  23149. * @param result defines the target matrix
  23150. */
  23151. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  23152. /**
  23153. * 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"
  23154. * This function works in right handed mode
  23155. * @param eye defines the final position of the entity
  23156. * @param target defines where the entity should look at
  23157. * @param up defines the up vector for the entity
  23158. * @returns the new matrix
  23159. */
  23160. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  23161. /**
  23162. * 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".
  23163. * This function works in right handed mode
  23164. * @param eye defines the final position of the entity
  23165. * @param target defines where the entity should look at
  23166. * @param up defines the up vector for the entity
  23167. * @param result defines the target matrix
  23168. */
  23169. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  23170. /**
  23171. * Create a left-handed orthographic projection matrix
  23172. * @param width defines the viewport width
  23173. * @param height defines the viewport height
  23174. * @param znear defines the near clip plane
  23175. * @param zfar defines the far clip plane
  23176. * @returns a new matrix as a left-handed orthographic projection matrix
  23177. */
  23178. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23179. /**
  23180. * Store a left-handed orthographic projection to a given matrix
  23181. * @param width defines the viewport width
  23182. * @param height defines the viewport height
  23183. * @param znear defines the near clip plane
  23184. * @param zfar defines the far clip plane
  23185. * @param result defines the target matrix
  23186. */
  23187. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23188. /**
  23189. * Create a left-handed orthographic projection matrix
  23190. * @param left defines the viewport left coordinate
  23191. * @param right defines the viewport right coordinate
  23192. * @param bottom defines the viewport bottom coordinate
  23193. * @param top defines the viewport top coordinate
  23194. * @param znear defines the near clip plane
  23195. * @param zfar defines the far clip plane
  23196. * @returns a new matrix as a left-handed orthographic projection matrix
  23197. */
  23198. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23199. /**
  23200. * Stores a left-handed orthographic projection into a given matrix
  23201. * @param left defines the viewport left coordinate
  23202. * @param right defines the viewport right coordinate
  23203. * @param bottom defines the viewport bottom coordinate
  23204. * @param top defines the viewport top coordinate
  23205. * @param znear defines the near clip plane
  23206. * @param zfar defines the far clip plane
  23207. * @param result defines the target matrix
  23208. */
  23209. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23210. /**
  23211. * Creates a right-handed orthographic projection matrix
  23212. * @param left defines the viewport left coordinate
  23213. * @param right defines the viewport right coordinate
  23214. * @param bottom defines the viewport bottom coordinate
  23215. * @param top defines the viewport top coordinate
  23216. * @param znear defines the near clip plane
  23217. * @param zfar defines the far clip plane
  23218. * @returns a new matrix as a right-handed orthographic projection matrix
  23219. */
  23220. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23221. /**
  23222. * Stores a right-handed orthographic projection into a given matrix
  23223. * @param left defines the viewport left coordinate
  23224. * @param right defines the viewport right coordinate
  23225. * @param bottom defines the viewport bottom coordinate
  23226. * @param top defines the viewport top coordinate
  23227. * @param znear defines the near clip plane
  23228. * @param zfar defines the far clip plane
  23229. * @param result defines the target matrix
  23230. */
  23231. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23232. /**
  23233. * Creates a left-handed perspective projection matrix
  23234. * @param width defines the viewport width
  23235. * @param height defines the viewport height
  23236. * @param znear defines the near clip plane
  23237. * @param zfar defines the far clip plane
  23238. * @returns a new matrix as a left-handed perspective projection matrix
  23239. */
  23240. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23241. /**
  23242. * Creates a left-handed perspective projection matrix
  23243. * @param fov defines the horizontal field of view
  23244. * @param aspect defines the aspect ratio
  23245. * @param znear defines the near clip plane
  23246. * @param zfar defines the far clip plane
  23247. * @returns a new matrix as a left-handed perspective projection matrix
  23248. */
  23249. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23250. /**
  23251. * Stores a left-handed perspective projection into a given matrix
  23252. * @param fov defines the horizontal field of view
  23253. * @param aspect defines the aspect ratio
  23254. * @param znear defines the near clip plane
  23255. * @param zfar defines the far clip plane
  23256. * @param result defines the target matrix
  23257. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23258. */
  23259. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23260. /**
  23261. * Creates a right-handed perspective projection matrix
  23262. * @param fov defines the horizontal field of view
  23263. * @param aspect defines the aspect ratio
  23264. * @param znear defines the near clip plane
  23265. * @param zfar defines the far clip plane
  23266. * @returns a new matrix as a right-handed perspective projection matrix
  23267. */
  23268. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23269. /**
  23270. * Stores a right-handed perspective projection into a given matrix
  23271. * @param fov defines the horizontal field of view
  23272. * @param aspect defines the aspect ratio
  23273. * @param znear defines the near clip plane
  23274. * @param zfar defines the far clip plane
  23275. * @param result defines the target matrix
  23276. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23277. */
  23278. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23279. /**
  23280. * Stores a perspective projection for WebVR info a given matrix
  23281. * @param fov defines the field of view
  23282. * @param znear defines the near clip plane
  23283. * @param zfar defines the far clip plane
  23284. * @param result defines the target matrix
  23285. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23286. */
  23287. static PerspectiveFovWebVRToRef(fov: {
  23288. upDegrees: number;
  23289. downDegrees: number;
  23290. leftDegrees: number;
  23291. rightDegrees: number;
  23292. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23293. /**
  23294. * Computes a complete transformation matrix
  23295. * @param viewport defines the viewport to use
  23296. * @param world defines the world matrix
  23297. * @param view defines the view matrix
  23298. * @param projection defines the projection matrix
  23299. * @param zmin defines the near clip plane
  23300. * @param zmax defines the far clip plane
  23301. * @returns the transformation matrix
  23302. */
  23303. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  23304. /**
  23305. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23306. * @param matrix defines the matrix to use
  23307. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23308. */
  23309. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  23310. /**
  23311. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23312. * @param matrix defines the matrix to use
  23313. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23314. */
  23315. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  23316. /**
  23317. * Compute the transpose of a given matrix
  23318. * @param matrix defines the matrix to transpose
  23319. * @returns the new matrix
  23320. */
  23321. static Transpose(matrix: Matrix): Matrix;
  23322. /**
  23323. * Compute the transpose of a matrix and store it in a target matrix
  23324. * @param matrix defines the matrix to transpose
  23325. * @param result defines the target matrix
  23326. */
  23327. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  23328. /**
  23329. * Computes a reflection matrix from a plane
  23330. * @param plane defines the reflection plane
  23331. * @returns a new matrix
  23332. */
  23333. static Reflection(plane: Plane): Matrix;
  23334. /**
  23335. * Computes a reflection matrix from a plane
  23336. * @param plane defines the reflection plane
  23337. * @param result defines the target matrix
  23338. */
  23339. static ReflectionToRef(plane: Plane, result: Matrix): void;
  23340. /**
  23341. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23342. * @param xaxis defines the value of the 1st axis
  23343. * @param yaxis defines the value of the 2nd axis
  23344. * @param zaxis defines the value of the 3rd axis
  23345. * @param result defines the target matrix
  23346. */
  23347. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  23348. /**
  23349. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23350. * @param quat defines the quaternion to use
  23351. * @param result defines the target matrix
  23352. */
  23353. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  23354. }
  23355. /**
  23356. * Represens a plane by the equation ax + by + cz + d = 0
  23357. */
  23358. class Plane {
  23359. /**
  23360. * Normal of the plane (a,b,c)
  23361. */
  23362. normal: Vector3;
  23363. /**
  23364. * d component of the plane
  23365. */
  23366. d: number;
  23367. /**
  23368. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23369. * @param a a component of the plane
  23370. * @param b b component of the plane
  23371. * @param c c component of the plane
  23372. * @param d d component of the plane
  23373. */
  23374. constructor(a: number, b: number, c: number, d: number);
  23375. /**
  23376. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23377. */
  23378. asArray(): number[];
  23379. /**
  23380. * @returns a new plane copied from the current Plane.
  23381. */
  23382. clone(): Plane;
  23383. /**
  23384. * @returns the string "Plane".
  23385. */
  23386. getClassName(): string;
  23387. /**
  23388. * @returns the Plane hash code.
  23389. */
  23390. getHashCode(): number;
  23391. /**
  23392. * Normalize the current Plane in place.
  23393. * @returns the updated Plane.
  23394. */
  23395. normalize(): Plane;
  23396. /**
  23397. * Applies a transformation the plane and returns the result
  23398. * @param transformation the transformation matrix to be applied to the plane
  23399. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23400. */
  23401. transform(transformation: Matrix): Plane;
  23402. /**
  23403. * Calcualtte the dot product between the point and the plane normal
  23404. * @param point point to calculate the dot product with
  23405. * @returns the dot product (float) of the point coordinates and the plane normal.
  23406. */
  23407. dotCoordinate(point: Vector3): number;
  23408. /**
  23409. * Updates the current Plane from the plane defined by the three given points.
  23410. * @param point1 one of the points used to contruct the plane
  23411. * @param point2 one of the points used to contruct the plane
  23412. * @param point3 one of the points used to contruct the plane
  23413. * @returns the updated Plane.
  23414. */
  23415. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23416. /**
  23417. * Checks if the plane is facing a given direction
  23418. * @param direction the direction to check if the plane is facing
  23419. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23420. * @returns True is the vector "direction" is the same side than the plane normal.
  23421. */
  23422. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  23423. /**
  23424. * Calculates the distance to a point
  23425. * @param point point to calculate distance to
  23426. * @returns the signed distance (float) from the given point to the Plane.
  23427. */
  23428. signedDistanceTo(point: Vector3): number;
  23429. /**
  23430. * Creates a plane from an array
  23431. * @param array the array to create a plane from
  23432. * @returns a new Plane from the given array.
  23433. */
  23434. static FromArray(array: ArrayLike<number>): Plane;
  23435. /**
  23436. * Creates a plane from three points
  23437. * @param point1 point used to create the plane
  23438. * @param point2 point used to create the plane
  23439. * @param point3 point used to create the plane
  23440. * @returns a new Plane defined by the three given points.
  23441. */
  23442. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23443. /**
  23444. * Creates a plane from an origin point and a normal
  23445. * @param origin origin of the plane to be constructed
  23446. * @param normal normal of the plane to be constructed
  23447. * @returns a new Plane the normal vector to this plane at the given origin point.
  23448. * Note : the vector "normal" is updated because normalized.
  23449. */
  23450. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  23451. /**
  23452. * Calculates the distance from a plane and a point
  23453. * @param origin origin of the plane to be constructed
  23454. * @param normal normal of the plane to be constructed
  23455. * @param point point to calculate distance to
  23456. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23457. */
  23458. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  23459. }
  23460. /**
  23461. * Class used to represent a viewport on screen
  23462. */
  23463. class Viewport {
  23464. /** viewport left coordinate */
  23465. x: number;
  23466. /** viewport top coordinate */
  23467. y: number;
  23468. /**viewport width */
  23469. width: number;
  23470. /** viewport height */
  23471. height: number;
  23472. /**
  23473. * Creates a Viewport object located at (x, y) and sized (width, height)
  23474. * @param x defines viewport left coordinate
  23475. * @param y defines viewport top coordinate
  23476. * @param width defines the viewport width
  23477. * @param height defines the viewport height
  23478. */
  23479. constructor(
  23480. /** viewport left coordinate */
  23481. x: number,
  23482. /** viewport top coordinate */
  23483. y: number,
  23484. /**viewport width */
  23485. width: number,
  23486. /** viewport height */
  23487. height: number);
  23488. /**
  23489. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23490. * @param renderWidthOrEngine defines either an engine or the rendering width
  23491. * @param renderHeight defines the rendering height
  23492. * @returns a new Viewport
  23493. */
  23494. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23495. /**
  23496. * Returns a new Viewport copied from the current one
  23497. * @returns a new Viewport
  23498. */
  23499. clone(): Viewport;
  23500. }
  23501. /**
  23502. * Reprasents a camera frustum
  23503. */
  23504. class Frustum {
  23505. /**
  23506. * Gets the planes representing the frustum
  23507. * @param transform matrix to be applied to the returned planes
  23508. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23509. */
  23510. static GetPlanes(transform: Matrix): Plane[];
  23511. /**
  23512. * Gets the near frustum plane transformed by the transform matrix
  23513. * @param transform transformation matrix to be applied to the resulting frustum plane
  23514. * @param frustumPlane the resuling frustum plane
  23515. */
  23516. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23517. /**
  23518. * Gets the far frustum plane transformed by the transform matrix
  23519. * @param transform transformation matrix to be applied to the resulting frustum plane
  23520. * @param frustumPlane the resuling frustum plane
  23521. */
  23522. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23523. /**
  23524. * Gets the left frustum plane transformed by the transform matrix
  23525. * @param transform transformation matrix to be applied to the resulting frustum plane
  23526. * @param frustumPlane the resuling frustum plane
  23527. */
  23528. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23529. /**
  23530. * Gets the right frustum plane transformed by the transform matrix
  23531. * @param transform transformation matrix to be applied to the resulting frustum plane
  23532. * @param frustumPlane the resuling frustum plane
  23533. */
  23534. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23535. /**
  23536. * Gets the top frustum plane transformed by the transform matrix
  23537. * @param transform transformation matrix to be applied to the resulting frustum plane
  23538. * @param frustumPlane the resuling frustum plane
  23539. */
  23540. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23541. /**
  23542. * Gets the bottom frustum plane transformed by the transform matrix
  23543. * @param transform transformation matrix to be applied to the resulting frustum plane
  23544. * @param frustumPlane the resuling frustum plane
  23545. */
  23546. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23547. /**
  23548. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23549. * @param transform transformation matrix to be applied to the resulting frustum planes
  23550. * @param frustumPlanes the resuling frustum planes
  23551. */
  23552. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23553. }
  23554. /** Defines supported spaces */
  23555. enum Space {
  23556. /** Local (object) space */
  23557. LOCAL = 0,
  23558. /** World space */
  23559. WORLD = 1,
  23560. /** Bone space */
  23561. BONE = 2
  23562. }
  23563. /** Defines the 3 main axes */
  23564. class Axis {
  23565. /** X axis */
  23566. static X: Vector3;
  23567. /** Y axis */
  23568. static Y: Vector3;
  23569. /** Z axis */
  23570. static Z: Vector3;
  23571. }
  23572. /** Class used to represent a Bezier curve */
  23573. class BezierCurve {
  23574. /**
  23575. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23576. * @param t defines the time
  23577. * @param x1 defines the left coordinate on X axis
  23578. * @param y1 defines the left coordinate on Y axis
  23579. * @param x2 defines the right coordinate on X axis
  23580. * @param y2 defines the right coordinate on Y axis
  23581. * @returns the interpolated value
  23582. */
  23583. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23584. }
  23585. /**
  23586. * Defines potential orientation for back face culling
  23587. */
  23588. enum Orientation {
  23589. /**
  23590. * Clockwise
  23591. */
  23592. CW = 0,
  23593. /** Counter clockwise */
  23594. CCW = 1
  23595. }
  23596. /**
  23597. * Defines angle representation
  23598. */
  23599. class Angle {
  23600. private _radians;
  23601. /**
  23602. * Creates an Angle object of "radians" radians (float).
  23603. */
  23604. constructor(radians: number);
  23605. /**
  23606. * Get value in degrees
  23607. * @returns the Angle value in degrees (float)
  23608. */
  23609. degrees(): number;
  23610. /**
  23611. * Get value in radians
  23612. * @returns the Angle value in radians (float)
  23613. */
  23614. radians(): number;
  23615. /**
  23616. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23617. * @param a defines first vector
  23618. * @param b defines second vector
  23619. * @returns a new Angle
  23620. */
  23621. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23622. /**
  23623. * Gets a new Angle object from the given float in radians
  23624. * @param radians defines the angle value in radians
  23625. * @returns a new Angle
  23626. */
  23627. static FromRadians(radians: number): Angle;
  23628. /**
  23629. * Gets a new Angle object from the given float in degrees
  23630. * @param degrees defines the angle value in degrees
  23631. * @returns a new Angle
  23632. */
  23633. static FromDegrees(degrees: number): Angle;
  23634. }
  23635. /**
  23636. * This represents an arc in a 2d space.
  23637. */
  23638. class Arc2 {
  23639. /** Defines the start point of the arc */
  23640. startPoint: Vector2;
  23641. /** Defines the mid point of the arc */
  23642. midPoint: Vector2;
  23643. /** Defines the end point of the arc */
  23644. endPoint: Vector2;
  23645. /**
  23646. * Defines the center point of the arc.
  23647. */
  23648. centerPoint: Vector2;
  23649. /**
  23650. * Defines the radius of the arc.
  23651. */
  23652. radius: number;
  23653. /**
  23654. * Defines the angle of the arc (from mid point to end point).
  23655. */
  23656. angle: Angle;
  23657. /**
  23658. * Defines the start angle of the arc (from start point to middle point).
  23659. */
  23660. startAngle: Angle;
  23661. /**
  23662. * Defines the orientation of the arc (clock wise/counter clock wise).
  23663. */
  23664. orientation: Orientation;
  23665. /**
  23666. * Creates an Arc object from the three given points : start, middle and end.
  23667. * @param startPoint Defines the start point of the arc
  23668. * @param midPoint Defines the midlle point of the arc
  23669. * @param endPoint Defines the end point of the arc
  23670. */
  23671. constructor(
  23672. /** Defines the start point of the arc */
  23673. startPoint: Vector2,
  23674. /** Defines the mid point of the arc */
  23675. midPoint: Vector2,
  23676. /** Defines the end point of the arc */
  23677. endPoint: Vector2);
  23678. }
  23679. /**
  23680. * Represents a 2D path made up of multiple 2D points
  23681. */
  23682. class Path2 {
  23683. private _points;
  23684. private _length;
  23685. /**
  23686. * If the path start and end point are the same
  23687. */
  23688. closed: boolean;
  23689. /**
  23690. * Creates a Path2 object from the starting 2D coordinates x and y.
  23691. * @param x the starting points x value
  23692. * @param y the starting points y value
  23693. */
  23694. constructor(x: number, y: number);
  23695. /**
  23696. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23697. * @param x the added points x value
  23698. * @param y the added points y value
  23699. * @returns the updated Path2.
  23700. */
  23701. addLineTo(x: number, y: number): Path2;
  23702. /**
  23703. * 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.
  23704. * @param midX middle point x value
  23705. * @param midY middle point y value
  23706. * @param endX end point x value
  23707. * @param endY end point y value
  23708. * @param numberOfSegments (default: 36)
  23709. * @returns the updated Path2.
  23710. */
  23711. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23712. /**
  23713. * Closes the Path2.
  23714. * @returns the Path2.
  23715. */
  23716. close(): Path2;
  23717. /**
  23718. * Gets the sum of the distance between each sequential point in the path
  23719. * @returns the Path2 total length (float).
  23720. */
  23721. length(): number;
  23722. /**
  23723. * Gets the points which construct the path
  23724. * @returns the Path2 internal array of points.
  23725. */
  23726. getPoints(): Vector2[];
  23727. /**
  23728. * Retreives the point at the distance aways from the starting point
  23729. * @param normalizedLengthPosition the length along the path to retreive the point from
  23730. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23731. */
  23732. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23733. /**
  23734. * Creates a new path starting from an x and y position
  23735. * @param x starting x value
  23736. * @param y starting y value
  23737. * @returns a new Path2 starting at the coordinates (x, y).
  23738. */
  23739. static StartingAt(x: number, y: number): Path2;
  23740. }
  23741. /**
  23742. * Represents a 3D path made up of multiple 3D points
  23743. */
  23744. class Path3D {
  23745. /**
  23746. * an array of Vector3, the curve axis of the Path3D
  23747. */
  23748. path: Vector3[];
  23749. private _curve;
  23750. private _distances;
  23751. private _tangents;
  23752. private _normals;
  23753. private _binormals;
  23754. private _raw;
  23755. /**
  23756. * new Path3D(path, normal, raw)
  23757. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23758. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23759. * @param path an array of Vector3, the curve axis of the Path3D
  23760. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23761. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23762. */
  23763. constructor(
  23764. /**
  23765. * an array of Vector3, the curve axis of the Path3D
  23766. */
  23767. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23768. /**
  23769. * Returns the Path3D array of successive Vector3 designing its curve.
  23770. * @returns the Path3D array of successive Vector3 designing its curve.
  23771. */
  23772. getCurve(): Vector3[];
  23773. /**
  23774. * Returns an array populated with tangent vectors on each Path3D curve point.
  23775. * @returns an array populated with tangent vectors on each Path3D curve point.
  23776. */
  23777. getTangents(): Vector3[];
  23778. /**
  23779. * Returns an array populated with normal vectors on each Path3D curve point.
  23780. * @returns an array populated with normal vectors on each Path3D curve point.
  23781. */
  23782. getNormals(): Vector3[];
  23783. /**
  23784. * Returns an array populated with binormal vectors on each Path3D curve point.
  23785. * @returns an array populated with binormal vectors on each Path3D curve point.
  23786. */
  23787. getBinormals(): Vector3[];
  23788. /**
  23789. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23790. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23791. */
  23792. getDistances(): number[];
  23793. /**
  23794. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23795. * @param path path which all values are copied into the curves points
  23796. * @param firstNormal which should be projected onto the curve
  23797. * @returns the same object updated.
  23798. */
  23799. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23800. private _compute;
  23801. private _getFirstNonNullVector;
  23802. private _getLastNonNullVector;
  23803. private _normalVector;
  23804. }
  23805. /**
  23806. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23807. * A Curve3 is designed from a series of successive Vector3.
  23808. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23809. */
  23810. class Curve3 {
  23811. private _points;
  23812. private _length;
  23813. /**
  23814. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23815. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23816. * @param v1 (Vector3) the control point
  23817. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23818. * @param nbPoints (integer) the wanted number of points in the curve
  23819. * @returns the created Curve3
  23820. */
  23821. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23822. /**
  23823. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23824. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23825. * @param v1 (Vector3) the first control point
  23826. * @param v2 (Vector3) the second control point
  23827. * @param v3 (Vector3) the end point of the Cubic Bezier
  23828. * @param nbPoints (integer) the wanted number of points in the curve
  23829. * @returns the created Curve3
  23830. */
  23831. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23832. /**
  23833. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23834. * @param p1 (Vector3) the origin point of the Hermite Spline
  23835. * @param t1 (Vector3) the tangent vector at the origin point
  23836. * @param p2 (Vector3) the end point of the Hermite Spline
  23837. * @param t2 (Vector3) the tangent vector at the end point
  23838. * @param nbPoints (integer) the wanted number of points in the curve
  23839. * @returns the created Curve3
  23840. */
  23841. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23842. /**
  23843. * Returns a Curve3 object along a CatmullRom Spline curve :
  23844. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23845. * @param nbPoints (integer) the wanted number of points between each curve control points
  23846. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23847. * @returns the created Curve3
  23848. */
  23849. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23850. /**
  23851. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23852. * A Curve3 is designed from a series of successive Vector3.
  23853. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23854. * @param points points which make up the curve
  23855. */
  23856. constructor(points: Vector3[]);
  23857. /**
  23858. * @returns the Curve3 stored array of successive Vector3
  23859. */
  23860. getPoints(): Vector3[];
  23861. /**
  23862. * @returns the computed length (float) of the curve.
  23863. */
  23864. length(): number;
  23865. /**
  23866. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23867. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23868. * curveA and curveB keep unchanged.
  23869. * @param curve the curve to continue from this curve
  23870. * @returns the newly constructed curve
  23871. */
  23872. continue(curve: Curve3): Curve3;
  23873. private _computeLength;
  23874. }
  23875. /**
  23876. * Contains position and normal vectors for a vertex
  23877. */
  23878. class PositionNormalVertex {
  23879. /** the position of the vertex (defaut: 0,0,0) */
  23880. position: Vector3;
  23881. /** the normal of the vertex (defaut: 0,1,0) */
  23882. normal: Vector3;
  23883. /**
  23884. * Creates a PositionNormalVertex
  23885. * @param position the position of the vertex (defaut: 0,0,0)
  23886. * @param normal the normal of the vertex (defaut: 0,1,0)
  23887. */
  23888. constructor(
  23889. /** the position of the vertex (defaut: 0,0,0) */
  23890. position?: Vector3,
  23891. /** the normal of the vertex (defaut: 0,1,0) */
  23892. normal?: Vector3);
  23893. /**
  23894. * Clones the PositionNormalVertex
  23895. * @returns the cloned PositionNormalVertex
  23896. */
  23897. clone(): PositionNormalVertex;
  23898. }
  23899. /**
  23900. * Contains position, normal and uv vectors for a vertex
  23901. */
  23902. class PositionNormalTextureVertex {
  23903. /** the position of the vertex (defaut: 0,0,0) */
  23904. position: Vector3;
  23905. /** the normal of the vertex (defaut: 0,1,0) */
  23906. normal: Vector3;
  23907. /** the uv of the vertex (default: 0,0) */
  23908. uv: Vector2;
  23909. /**
  23910. * Creates a PositionNormalTextureVertex
  23911. * @param position the position of the vertex (defaut: 0,0,0)
  23912. * @param normal the normal of the vertex (defaut: 0,1,0)
  23913. * @param uv the uv of the vertex (default: 0,0)
  23914. */
  23915. constructor(
  23916. /** the position of the vertex (defaut: 0,0,0) */
  23917. position?: Vector3,
  23918. /** the normal of the vertex (defaut: 0,1,0) */
  23919. normal?: Vector3,
  23920. /** the uv of the vertex (default: 0,0) */
  23921. uv?: Vector2);
  23922. /**
  23923. * Clones the PositionNormalTextureVertex
  23924. * @returns the cloned PositionNormalTextureVertex
  23925. */
  23926. clone(): PositionNormalTextureVertex;
  23927. }
  23928. /**
  23929. * @hidden
  23930. */
  23931. class Tmp {
  23932. static Color3: Color3[];
  23933. static Color4: Color4[];
  23934. static Vector2: Vector2[];
  23935. static Vector3: Vector3[];
  23936. static Vector4: Vector4[];
  23937. static Quaternion: Quaternion[];
  23938. static Matrix: Matrix[];
  23939. }
  23940. }
  23941. declare module BABYLON {
  23942. /**
  23943. * Class representing spherical polynomial coefficients to the 3rd degree
  23944. */
  23945. class SphericalPolynomial {
  23946. /**
  23947. * The x coefficients of the spherical polynomial
  23948. */
  23949. x: Vector3;
  23950. /**
  23951. * The y coefficients of the spherical polynomial
  23952. */
  23953. y: Vector3;
  23954. /**
  23955. * The z coefficients of the spherical polynomial
  23956. */
  23957. z: Vector3;
  23958. /**
  23959. * The xx coefficients of the spherical polynomial
  23960. */
  23961. xx: Vector3;
  23962. /**
  23963. * The yy coefficients of the spherical polynomial
  23964. */
  23965. yy: Vector3;
  23966. /**
  23967. * The zz coefficients of the spherical polynomial
  23968. */
  23969. zz: Vector3;
  23970. /**
  23971. * The xy coefficients of the spherical polynomial
  23972. */
  23973. xy: Vector3;
  23974. /**
  23975. * The yz coefficients of the spherical polynomial
  23976. */
  23977. yz: Vector3;
  23978. /**
  23979. * The zx coefficients of the spherical polynomial
  23980. */
  23981. zx: Vector3;
  23982. /**
  23983. * Adds an ambient color to the spherical polynomial
  23984. * @param color the color to add
  23985. */
  23986. addAmbient(color: Color3): void;
  23987. /**
  23988. * Scales the spherical polynomial by the given amount
  23989. * @param scale the amount to scale
  23990. */
  23991. scale(scale: number): void;
  23992. /**
  23993. * Gets the spherical polynomial from harmonics
  23994. * @param harmonics the spherical harmonics
  23995. * @returns the spherical polynomial
  23996. */
  23997. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23998. /**
  23999. * Constructs a spherical polynomial from an array.
  24000. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24001. * @returns the spherical polynomial
  24002. */
  24003. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24004. }
  24005. /**
  24006. * Class representing spherical harmonics coefficients to the 3rd degree
  24007. */
  24008. class SphericalHarmonics {
  24009. /**
  24010. * The l0,0 coefficients of the spherical harmonics
  24011. */
  24012. l00: Vector3;
  24013. /**
  24014. * The l1,-1 coefficients of the spherical harmonics
  24015. */
  24016. l1_1: Vector3;
  24017. /**
  24018. * The l1,0 coefficients of the spherical harmonics
  24019. */
  24020. l10: Vector3;
  24021. /**
  24022. * The l1,1 coefficients of the spherical harmonics
  24023. */
  24024. l11: Vector3;
  24025. /**
  24026. * The l2,-2 coefficients of the spherical harmonics
  24027. */
  24028. l2_2: Vector3;
  24029. /**
  24030. * The l2,-1 coefficients of the spherical harmonics
  24031. */
  24032. l2_1: Vector3;
  24033. /**
  24034. * The l2,0 coefficients of the spherical harmonics
  24035. */
  24036. l20: Vector3;
  24037. /**
  24038. * The l2,1 coefficients of the spherical harmonics
  24039. */
  24040. l21: Vector3;
  24041. /**
  24042. * The l2,2 coefficients of the spherical harmonics
  24043. */
  24044. lL22: Vector3;
  24045. /**
  24046. * Adds a light to the spherical harmonics
  24047. * @param direction the direction of the light
  24048. * @param color the color of the light
  24049. * @param deltaSolidAngle the delta solid angle of the light
  24050. */
  24051. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24052. /**
  24053. * Scales the spherical harmonics by the given amount
  24054. * @param scale the amount to scale
  24055. */
  24056. scale(scale: number): void;
  24057. /**
  24058. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24059. *
  24060. * ```
  24061. * E_lm = A_l * L_lm
  24062. * ```
  24063. *
  24064. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24065. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24066. * the scaling factors are given in equation 9.
  24067. */
  24068. convertIncidentRadianceToIrradiance(): void;
  24069. /**
  24070. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24071. *
  24072. * ```
  24073. * L = (1/pi) * E * rho
  24074. * ```
  24075. *
  24076. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24077. */
  24078. convertIrradianceToLambertianRadiance(): void;
  24079. /**
  24080. * Gets the spherical harmonics from polynomial
  24081. * @param polynomial the spherical polynomial
  24082. * @returns the spherical harmonics
  24083. */
  24084. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24085. /**
  24086. * Constructs a spherical harmonics from an array.
  24087. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24088. * @returns the spherical harmonics
  24089. */
  24090. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24091. }
  24092. }
  24093. declare module BABYLON {
  24094. /**
  24095. * Class used to store all common mesh properties
  24096. */
  24097. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24098. /** No occlusion */
  24099. static OCCLUSION_TYPE_NONE: number;
  24100. /** Occlusion set to optimisitic */
  24101. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24102. /** Occlusion set to strict */
  24103. static OCCLUSION_TYPE_STRICT: number;
  24104. /** Use an accurante occlusion algorithm */
  24105. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24106. /** Use a conservative occlusion algorithm */
  24107. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24108. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24109. static readonly CULLINGSTRATEGY_STANDARD: number;
  24110. /** Culling strategy with bounding sphere only and then frustum culling */
  24111. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24112. /**
  24113. * No billboard
  24114. */
  24115. static readonly BILLBOARDMODE_NONE: number;
  24116. /** Billboard on X axis */
  24117. static readonly BILLBOARDMODE_X: number;
  24118. /** Billboard on Y axis */
  24119. static readonly BILLBOARDMODE_Y: number;
  24120. /** Billboard on Z axis */
  24121. static readonly BILLBOARDMODE_Z: number;
  24122. /** Billboard on all axes */
  24123. static readonly BILLBOARDMODE_ALL: number;
  24124. private _facetData;
  24125. /** Gets ot sets the culling strategy to use to find visible meshes */
  24126. cullingStrategy: number;
  24127. /**
  24128. * Gets the number of facets in the mesh
  24129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24130. */
  24131. readonly facetNb: number;
  24132. /**
  24133. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24135. */
  24136. partitioningSubdivisions: number;
  24137. /**
  24138. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24139. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24141. */
  24142. partitioningBBoxRatio: number;
  24143. /**
  24144. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24145. * Works only for updatable meshes.
  24146. * Doesn't work with multi-materials
  24147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24148. */
  24149. mustDepthSortFacets: boolean;
  24150. /**
  24151. * The location (Vector3) where the facet depth sort must be computed from.
  24152. * By default, the active camera position.
  24153. * Used only when facet depth sort is enabled
  24154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24155. */
  24156. facetDepthSortFrom: Vector3;
  24157. /**
  24158. * gets a boolean indicating if facetData is enabled
  24159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24160. */
  24161. readonly isFacetDataEnabled: boolean;
  24162. /** @hidden */
  24163. _updateNonUniformScalingState(value: boolean): boolean;
  24164. /**
  24165. * An event triggered when this mesh collides with another one
  24166. */
  24167. onCollideObservable: Observable<AbstractMesh>;
  24168. private _onCollideObserver;
  24169. /** Set a function to call when this mesh collides with another one */
  24170. onCollide: () => void;
  24171. /**
  24172. * An event triggered when the collision's position changes
  24173. */
  24174. onCollisionPositionChangeObservable: Observable<Vector3>;
  24175. private _onCollisionPositionChangeObserver;
  24176. /** Set a function to call when the collision's position changes */
  24177. onCollisionPositionChange: () => void;
  24178. /**
  24179. * An event triggered when material is changed
  24180. */
  24181. onMaterialChangedObservable: Observable<AbstractMesh>;
  24182. /**
  24183. * Gets or sets the orientation for POV movement & rotation
  24184. */
  24185. definedFacingForward: boolean;
  24186. /** @hidden */
  24187. _occlusionQuery: Nullable<WebGLQuery>;
  24188. private _visibility;
  24189. /**
  24190. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24191. */
  24192. /**
  24193. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24194. */
  24195. visibility: number;
  24196. /** Gets or sets the alpha index used to sort transparent meshes
  24197. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24198. */
  24199. alphaIndex: number;
  24200. /**
  24201. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24202. */
  24203. isVisible: boolean;
  24204. /**
  24205. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24206. */
  24207. isPickable: boolean;
  24208. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24209. showSubMeshesBoundingBox: boolean;
  24210. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24212. */
  24213. isBlocker: boolean;
  24214. /**
  24215. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24216. */
  24217. enablePointerMoveEvents: boolean;
  24218. /**
  24219. * Specifies the rendering group id for this mesh (0 by default)
  24220. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24221. */
  24222. renderingGroupId: number;
  24223. private _material;
  24224. /** Gets or sets current material */
  24225. material: Nullable<Material>;
  24226. private _receiveShadows;
  24227. /**
  24228. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24229. * @see http://doc.babylonjs.com/babylon101/shadows
  24230. */
  24231. receiveShadows: boolean;
  24232. /** Defines color to use when rendering outline */
  24233. outlineColor: Color3;
  24234. /** Define width to use when rendering outline */
  24235. outlineWidth: number;
  24236. /** Defines color to use when rendering overlay */
  24237. overlayColor: Color3;
  24238. /** Defines alpha to use when rendering overlay */
  24239. overlayAlpha: number;
  24240. private _hasVertexAlpha;
  24241. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24242. hasVertexAlpha: boolean;
  24243. private _useVertexColors;
  24244. /** 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) */
  24245. useVertexColors: boolean;
  24246. private _computeBonesUsingShaders;
  24247. /**
  24248. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24249. */
  24250. computeBonesUsingShaders: boolean;
  24251. private _numBoneInfluencers;
  24252. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24253. numBoneInfluencers: number;
  24254. private _applyFog;
  24255. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24256. applyFog: boolean;
  24257. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24258. useOctreeForRenderingSelection: boolean;
  24259. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24260. useOctreeForPicking: boolean;
  24261. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24262. useOctreeForCollisions: boolean;
  24263. private _layerMask;
  24264. /**
  24265. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24266. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24267. */
  24268. layerMask: number;
  24269. /**
  24270. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24271. */
  24272. alwaysSelectAsActiveMesh: boolean;
  24273. /**
  24274. * Gets or sets the current action manager
  24275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24276. */
  24277. actionManager: Nullable<ActionManager>;
  24278. private _checkCollisions;
  24279. private _collisionMask;
  24280. private _collisionGroup;
  24281. /**
  24282. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24283. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24284. */
  24285. ellipsoid: Vector3;
  24286. /**
  24287. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24289. */
  24290. ellipsoidOffset: Vector3;
  24291. private _collider;
  24292. private _oldPositionForCollisions;
  24293. private _diffPositionForCollisions;
  24294. /**
  24295. * Gets or sets a collision mask used to mask collisions (default is -1).
  24296. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24297. */
  24298. collisionMask: number;
  24299. /**
  24300. * Gets or sets the current collision group mask (-1 by default).
  24301. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24302. */
  24303. collisionGroup: number;
  24304. /**
  24305. * Defines edge width used when edgesRenderer is enabled
  24306. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24307. */
  24308. edgesWidth: number;
  24309. /**
  24310. * Defines edge color used when edgesRenderer is enabled
  24311. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24312. */
  24313. edgesColor: Color4;
  24314. /** @hidden */
  24315. _edgesRenderer: Nullable<IEdgesRenderer>;
  24316. /** @hidden */
  24317. _masterMesh: Nullable<AbstractMesh>;
  24318. /** @hidden */
  24319. _boundingInfo: Nullable<BoundingInfo>;
  24320. /** @hidden */
  24321. _renderId: number;
  24322. /**
  24323. * Gets or sets the list of subMeshes
  24324. * @see http://doc.babylonjs.com/how_to/multi_materials
  24325. */
  24326. subMeshes: SubMesh[];
  24327. /** @hidden */
  24328. _intersectionsInProgress: AbstractMesh[];
  24329. /** @hidden */
  24330. _unIndexed: boolean;
  24331. /** @hidden */
  24332. _lightSources: Light[];
  24333. /** @hidden */
  24334. readonly _positions: Nullable<Vector3[]>;
  24335. /** @hidden */
  24336. _waitingActions: any;
  24337. /** @hidden */
  24338. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24339. private _skeleton;
  24340. /** @hidden */
  24341. _bonesTransformMatrices: Nullable<Float32Array>;
  24342. /**
  24343. * Gets or sets a skeleton to apply skining transformations
  24344. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24345. */
  24346. skeleton: Nullable<Skeleton>;
  24347. /**
  24348. * An event triggered when the mesh is rebuilt.
  24349. */
  24350. onRebuildObservable: Observable<AbstractMesh>;
  24351. /**
  24352. * Creates a new AbstractMesh
  24353. * @param name defines the name of the mesh
  24354. * @param scene defines the hosting scene
  24355. */
  24356. constructor(name: string, scene?: Nullable<Scene>);
  24357. /**
  24358. * Returns the string "AbstractMesh"
  24359. * @returns "AbstractMesh"
  24360. */
  24361. getClassName(): string;
  24362. /**
  24363. * Gets a string representation of the current mesh
  24364. * @param fullDetails defines a boolean indicating if full details must be included
  24365. * @returns a string representation of the current mesh
  24366. */
  24367. toString(fullDetails?: boolean): string;
  24368. /** @hidden */
  24369. _rebuild(): void;
  24370. /** @hidden */
  24371. _resyncLightSources(): void;
  24372. /** @hidden */
  24373. _resyncLighSource(light: Light): void;
  24374. /** @hidden */
  24375. _unBindEffect(): void;
  24376. /** @hidden */
  24377. _removeLightSource(light: Light): void;
  24378. private _markSubMeshesAsDirty;
  24379. /** @hidden */
  24380. _markSubMeshesAsLightDirty(): void;
  24381. /** @hidden */
  24382. _markSubMeshesAsAttributesDirty(): void;
  24383. /** @hidden */
  24384. _markSubMeshesAsMiscDirty(): void;
  24385. /**
  24386. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24387. */
  24388. scaling: Vector3;
  24389. /**
  24390. * Returns true if the mesh is blocked. Implemented by child classes
  24391. */
  24392. readonly isBlocked: boolean;
  24393. /**
  24394. * Returns the mesh itself by default. Implemented by child classes
  24395. * @param camera defines the camera to use to pick the right LOD level
  24396. * @returns the currentAbstractMesh
  24397. */
  24398. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24399. /**
  24400. * Returns 0 by default. Implemented by child classes
  24401. * @returns an integer
  24402. */
  24403. getTotalVertices(): number;
  24404. /**
  24405. * Returns null by default. Implemented by child classes
  24406. * @returns null
  24407. */
  24408. getIndices(): Nullable<IndicesArray>;
  24409. /**
  24410. * Returns the array of the requested vertex data kind. Implemented by child classes
  24411. * @param kind defines the vertex data kind to use
  24412. * @returns null
  24413. */
  24414. getVerticesData(kind: string): Nullable<FloatArray>;
  24415. /**
  24416. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24417. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24418. * Note that a new underlying VertexBuffer object is created each call.
  24419. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24420. * @param kind defines vertex data kind:
  24421. * * BABYLON.VertexBuffer.PositionKind
  24422. * * BABYLON.VertexBuffer.UVKind
  24423. * * BABYLON.VertexBuffer.UV2Kind
  24424. * * BABYLON.VertexBuffer.UV3Kind
  24425. * * BABYLON.VertexBuffer.UV4Kind
  24426. * * BABYLON.VertexBuffer.UV5Kind
  24427. * * BABYLON.VertexBuffer.UV6Kind
  24428. * * BABYLON.VertexBuffer.ColorKind
  24429. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24430. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24431. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24432. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24433. * @param data defines the data source
  24434. * @param updatable defines if the data must be flagged as updatable (or static)
  24435. * @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
  24436. * @returns the current mesh
  24437. */
  24438. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24439. /**
  24440. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24441. * If the mesh has no geometry, it is simply returned as it is.
  24442. * @param kind defines vertex data kind:
  24443. * * BABYLON.VertexBuffer.PositionKind
  24444. * * BABYLON.VertexBuffer.UVKind
  24445. * * BABYLON.VertexBuffer.UV2Kind
  24446. * * BABYLON.VertexBuffer.UV3Kind
  24447. * * BABYLON.VertexBuffer.UV4Kind
  24448. * * BABYLON.VertexBuffer.UV5Kind
  24449. * * BABYLON.VertexBuffer.UV6Kind
  24450. * * BABYLON.VertexBuffer.ColorKind
  24451. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24452. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24453. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24454. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24455. * @param data defines the data source
  24456. * @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
  24457. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24458. * @returns the current mesh
  24459. */
  24460. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24461. /**
  24462. * Sets the mesh indices,
  24463. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24464. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24465. * @param totalVertices Defines the total number of vertices
  24466. * @returns the current mesh
  24467. */
  24468. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24469. /**
  24470. * Gets a boolean indicating if specific vertex data is present
  24471. * @param kind defines the vertex data kind to use
  24472. * @returns true is data kind is present
  24473. */
  24474. isVerticesDataPresent(kind: string): boolean;
  24475. /**
  24476. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24477. * @returns a BoundingInfo
  24478. */
  24479. getBoundingInfo(): BoundingInfo;
  24480. /**
  24481. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24482. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24483. * @returns the current mesh
  24484. */
  24485. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24486. /**
  24487. * Overwrite the current bounding info
  24488. * @param boundingInfo defines the new bounding info
  24489. * @returns the current mesh
  24490. */
  24491. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24492. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24493. readonly useBones: boolean;
  24494. /** @hidden */
  24495. _preActivate(): void;
  24496. /** @hidden */
  24497. _preActivateForIntermediateRendering(renderId: number): void;
  24498. /** @hidden */
  24499. _activate(renderId: number): void;
  24500. /**
  24501. * Gets the current world matrix
  24502. * @returns a Matrix
  24503. */
  24504. getWorldMatrix(): Matrix;
  24505. /** @hidden */
  24506. _getWorldMatrixDeterminant(): number;
  24507. /**
  24508. * Perform relative position change from the point of view of behind the front of the mesh.
  24509. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24510. * Supports definition of mesh facing forward or backward
  24511. * @param amountRight defines the distance on the right axis
  24512. * @param amountUp defines the distance on the up axis
  24513. * @param amountForward defines the distance on the forward axis
  24514. * @returns the current mesh
  24515. */
  24516. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24517. /**
  24518. * Calculate relative position change from the point of view of behind the front of the mesh.
  24519. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24520. * Supports definition of mesh facing forward or backward
  24521. * @param amountRight defines the distance on the right axis
  24522. * @param amountUp defines the distance on the up axis
  24523. * @param amountForward defines the distance on the forward axis
  24524. * @returns the new displacement vector
  24525. */
  24526. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24527. /**
  24528. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24529. * Supports definition of mesh facing forward or backward
  24530. * @param flipBack defines the flip
  24531. * @param twirlClockwise defines the twirl
  24532. * @param tiltRight defines the tilt
  24533. * @returns the current mesh
  24534. */
  24535. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24536. /**
  24537. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24538. * Supports definition of mesh facing forward or backward.
  24539. * @param flipBack defines the flip
  24540. * @param twirlClockwise defines the twirl
  24541. * @param tiltRight defines the tilt
  24542. * @returns the new rotation vector
  24543. */
  24544. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24545. /**
  24546. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24547. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24548. * @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
  24549. * @returns the new bounding vectors
  24550. */
  24551. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24552. min: Vector3;
  24553. max: Vector3;
  24554. };
  24555. /**
  24556. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24557. * This means the mesh underlying bounding box and sphere are recomputed.
  24558. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24559. * @returns the current mesh
  24560. */
  24561. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24562. /** @hidden */
  24563. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24564. /** @hidden */
  24565. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24566. /** @hidden */
  24567. _updateBoundingInfo(): AbstractMesh;
  24568. /** @hidden */
  24569. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24570. /** @hidden */
  24571. protected _afterComputeWorldMatrix(): void;
  24572. /**
  24573. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24574. * A mesh is in the frustum if its bounding box intersects the frustum
  24575. * @param frustumPlanes defines the frustum to test
  24576. * @returns true if the mesh is in the frustum planes
  24577. */
  24578. isInFrustum(frustumPlanes: Plane[]): boolean;
  24579. /**
  24580. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24581. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24582. * @param frustumPlanes defines the frustum to test
  24583. * @returns true if the mesh is completely in the frustum planes
  24584. */
  24585. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24586. /**
  24587. * True if the mesh intersects another mesh or a SolidParticle object
  24588. * @param mesh defines a target mesh or SolidParticle to test
  24589. * @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)
  24590. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24591. * @returns true if there is an intersection
  24592. */
  24593. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24594. /**
  24595. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24596. * @param point defines the point to test
  24597. * @returns true if there is an intersection
  24598. */
  24599. intersectsPoint(point: Vector3): boolean;
  24600. /**
  24601. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24603. */
  24604. checkCollisions: boolean;
  24605. /**
  24606. * Gets Collider object used to compute collisions (not physics)
  24607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24608. */
  24609. readonly collider: Collider;
  24610. /**
  24611. * Move the mesh using collision engine
  24612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24613. * @param displacement defines the requested displacement vector
  24614. * @returns the current mesh
  24615. */
  24616. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24617. private _onCollisionPositionChange;
  24618. /** @hidden */
  24619. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24620. /** @hidden */
  24621. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24622. /** @hidden */
  24623. _checkCollision(collider: Collider): AbstractMesh;
  24624. /** @hidden */
  24625. _generatePointsArray(): boolean;
  24626. /**
  24627. * Checks if the passed Ray intersects with the mesh
  24628. * @param ray defines the ray to use
  24629. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24630. * @returns the picking info
  24631. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24632. */
  24633. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24634. /**
  24635. * Clones the current mesh
  24636. * @param name defines the mesh name
  24637. * @param newParent defines the new mesh parent
  24638. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24639. * @returns the new mesh
  24640. */
  24641. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24642. /**
  24643. * Disposes all the submeshes of the current meshnp
  24644. * @returns the current mesh
  24645. */
  24646. releaseSubMeshes(): AbstractMesh;
  24647. /**
  24648. * Releases resources associated with this abstract mesh.
  24649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24651. */
  24652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24653. /**
  24654. * Adds the passed mesh as a child to the current mesh
  24655. * @param mesh defines the child mesh
  24656. * @returns the current mesh
  24657. */
  24658. addChild(mesh: AbstractMesh): AbstractMesh;
  24659. /**
  24660. * Removes the passed mesh from the current mesh children list
  24661. * @param mesh defines the child mesh
  24662. * @returns the current mesh
  24663. */
  24664. removeChild(mesh: AbstractMesh): AbstractMesh;
  24665. /** @hidden */
  24666. private _initFacetData;
  24667. /**
  24668. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24669. * This method can be called within the render loop.
  24670. * 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
  24671. * @returns the current mesh
  24672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24673. */
  24674. updateFacetData(): AbstractMesh;
  24675. /**
  24676. * Returns the facetLocalNormals array.
  24677. * The normals are expressed in the mesh local spac
  24678. * @returns an array of Vector3
  24679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24680. */
  24681. getFacetLocalNormals(): Vector3[];
  24682. /**
  24683. * Returns the facetLocalPositions array.
  24684. * The facet positions are expressed in the mesh local space
  24685. * @returns an array of Vector3
  24686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24687. */
  24688. getFacetLocalPositions(): Vector3[];
  24689. /**
  24690. * Returns the facetLocalPartioning array
  24691. * @returns an array of array of numbers
  24692. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24693. */
  24694. getFacetLocalPartitioning(): number[][];
  24695. /**
  24696. * Returns the i-th facet position in the world system.
  24697. * This method allocates a new Vector3 per call
  24698. * @param i defines the facet index
  24699. * @returns a new Vector3
  24700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24701. */
  24702. getFacetPosition(i: number): Vector3;
  24703. /**
  24704. * Sets the reference Vector3 with the i-th facet position in the world system
  24705. * @param i defines the facet index
  24706. * @param ref defines the target vector
  24707. * @returns the current mesh
  24708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24709. */
  24710. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24711. /**
  24712. * Returns the i-th facet normal in the world system.
  24713. * This method allocates a new Vector3 per call
  24714. * @param i defines the facet index
  24715. * @returns a new Vector3
  24716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24717. */
  24718. getFacetNormal(i: number): Vector3;
  24719. /**
  24720. * Sets the reference Vector3 with the i-th facet normal in the world system
  24721. * @param i defines the facet index
  24722. * @param ref defines the target vector
  24723. * @returns the current mesh
  24724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24725. */
  24726. getFacetNormalToRef(i: number, ref: Vector3): this;
  24727. /**
  24728. * 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)
  24729. * @param x defines x coordinate
  24730. * @param y defines y coordinate
  24731. * @param z defines z coordinate
  24732. * @returns the array of facet indexes
  24733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24734. */
  24735. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24736. /**
  24737. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24738. * @param projected sets as the (x,y,z) world projection on the facet
  24739. * @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
  24740. * @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
  24741. * @param x defines x coordinate
  24742. * @param y defines y coordinate
  24743. * @param z defines z coordinate
  24744. * @returns the face index if found (or null instead)
  24745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24746. */
  24747. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24748. /**
  24749. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24750. * @param projected sets as the (x,y,z) local projection on the facet
  24751. * @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
  24752. * @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
  24753. * @param x defines x coordinate
  24754. * @param y defines y coordinate
  24755. * @param z defines z coordinate
  24756. * @returns the face index if found (or null instead)
  24757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24758. */
  24759. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24760. /**
  24761. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24762. * @returns the parameters
  24763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24764. */
  24765. getFacetDataParameters(): any;
  24766. /**
  24767. * Disables the feature FacetData and frees the related memory
  24768. * @returns the current mesh
  24769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24770. */
  24771. disableFacetData(): AbstractMesh;
  24772. /**
  24773. * Updates the AbstractMesh indices array
  24774. * @param indices defines the data source
  24775. * @returns the current mesh
  24776. */
  24777. updateIndices(indices: IndicesArray): AbstractMesh;
  24778. /**
  24779. * Creates new normals data for the mesh
  24780. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24781. * @returns the current mesh
  24782. */
  24783. createNormals(updatable: boolean): AbstractMesh;
  24784. /**
  24785. * Align the mesh with a normal
  24786. * @param normal defines the normal to use
  24787. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24788. * @returns the current mesh
  24789. */
  24790. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24791. /** @hidden */
  24792. _checkOcclusionQuery(): boolean;
  24793. }
  24794. }
  24795. declare module BABYLON {
  24796. /**
  24797. * Class used to store data that will be store in GPU memory
  24798. */
  24799. class Buffer {
  24800. private _engine;
  24801. private _buffer;
  24802. /** @hidden */
  24803. _data: Nullable<DataArray>;
  24804. private _updatable;
  24805. private _instanced;
  24806. /**
  24807. * Gets the byte stride.
  24808. */
  24809. readonly byteStride: number;
  24810. /**
  24811. * Constructor
  24812. * @param engine the engine
  24813. * @param data the data to use for this buffer
  24814. * @param updatable whether the data is updatable
  24815. * @param stride the stride (optional)
  24816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24817. * @param instanced whether the buffer is instanced (optional)
  24818. * @param useBytes set to true if the stride in in bytes (optional)
  24819. */
  24820. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24821. /**
  24822. * Create a new VertexBuffer based on the current buffer
  24823. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24824. * @param offset defines offset in the buffer (0 by default)
  24825. * @param size defines the size in floats of attributes (position is 3 for instance)
  24826. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24827. * @param instanced defines if the vertex buffer contains indexed data
  24828. * @param useBytes defines if the offset and stride are in bytes
  24829. * @returns the new vertex buffer
  24830. */
  24831. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24832. /**
  24833. * Gets a boolean indicating if the Buffer is updatable?
  24834. * @returns true if the buffer is updatable
  24835. */
  24836. isUpdatable(): boolean;
  24837. /**
  24838. * Gets current buffer's data
  24839. * @returns a DataArray or null
  24840. */
  24841. getData(): Nullable<DataArray>;
  24842. /**
  24843. * Gets underlying native buffer
  24844. * @returns underlying native buffer
  24845. */
  24846. getBuffer(): Nullable<WebGLBuffer>;
  24847. /**
  24848. * Gets the stride in float32 units (i.e. byte stride / 4).
  24849. * May not be an integer if the byte stride is not divisible by 4.
  24850. * DEPRECATED. Use byteStride instead.
  24851. * @returns the stride in float32 units
  24852. */
  24853. getStrideSize(): number;
  24854. /**
  24855. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24856. * @param data defines the data to store
  24857. */
  24858. create(data?: Nullable<DataArray>): void;
  24859. /** @hidden */
  24860. _rebuild(): void;
  24861. /**
  24862. * Update current buffer data
  24863. * @param data defines the data to store
  24864. */
  24865. update(data: DataArray): void;
  24866. /**
  24867. * Updates the data directly.
  24868. * @param data the new data
  24869. * @param offset the new offset
  24870. * @param vertexCount the vertex count (optional)
  24871. * @param useBytes set to true if the offset is in bytes
  24872. */
  24873. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24874. /**
  24875. * Release all resources
  24876. */
  24877. dispose(): void;
  24878. }
  24879. }
  24880. declare module BABYLON {
  24881. /**
  24882. * Class for building Constructive Solid Geometry
  24883. */
  24884. class CSG {
  24885. private polygons;
  24886. /**
  24887. * The world matrix
  24888. */
  24889. matrix: Matrix;
  24890. /**
  24891. * Stores the position
  24892. */
  24893. position: Vector3;
  24894. /**
  24895. * Stores the rotation
  24896. */
  24897. rotation: Vector3;
  24898. /**
  24899. * Stores the rotation quaternion
  24900. */
  24901. rotationQuaternion: Nullable<Quaternion>;
  24902. /**
  24903. * Stores the scaling vector
  24904. */
  24905. scaling: Vector3;
  24906. /**
  24907. * Convert the BABYLON.Mesh to BABYLON.CSG
  24908. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24909. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24910. */
  24911. static FromMesh(mesh: Mesh): CSG;
  24912. /**
  24913. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24914. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24915. */
  24916. private static FromPolygons;
  24917. /**
  24918. * Clones, or makes a deep copy, of the BABYLON.CSG
  24919. * @returns A new BABYLON.CSG
  24920. */
  24921. clone(): CSG;
  24922. /**
  24923. * Unions this CSG with another CSG
  24924. * @param csg The CSG to union against this CSG
  24925. * @returns The unioned CSG
  24926. */
  24927. union(csg: CSG): CSG;
  24928. /**
  24929. * Unions this CSG with another CSG in place
  24930. * @param csg The CSG to union against this CSG
  24931. */
  24932. unionInPlace(csg: CSG): void;
  24933. /**
  24934. * Subtracts this CSG with another CSG
  24935. * @param csg The CSG to subtract against this CSG
  24936. * @returns A new BABYLON.CSG
  24937. */
  24938. subtract(csg: CSG): CSG;
  24939. /**
  24940. * Subtracts this CSG with another CSG in place
  24941. * @param csg The CSG to subtact against this CSG
  24942. */
  24943. subtractInPlace(csg: CSG): void;
  24944. /**
  24945. * Intersect this CSG with another CSG
  24946. * @param csg The CSG to intersect against this CSG
  24947. * @returns A new BABYLON.CSG
  24948. */
  24949. intersect(csg: CSG): CSG;
  24950. /**
  24951. * Intersects this CSG with another CSG in place
  24952. * @param csg The CSG to intersect against this CSG
  24953. */
  24954. intersectInPlace(csg: CSG): void;
  24955. /**
  24956. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24957. * not modified.
  24958. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24959. */
  24960. inverse(): CSG;
  24961. /**
  24962. * Inverses the BABYLON.CSG in place
  24963. */
  24964. inverseInPlace(): void;
  24965. /**
  24966. * This is used to keep meshes transformations so they can be restored
  24967. * when we build back a Babylon Mesh
  24968. * NB : All CSG operations are performed in world coordinates
  24969. * @param csg The BABYLON.CSG to copy the transform attributes from
  24970. * @returns This BABYLON.CSG
  24971. */
  24972. copyTransformAttributes(csg: CSG): CSG;
  24973. /**
  24974. * Build Raw mesh from CSG
  24975. * Coordinates here are in world space
  24976. * @param name The name of the mesh geometry
  24977. * @param scene The BABYLON.Scene
  24978. * @param keepSubMeshes Specifies if the submeshes should be kept
  24979. * @returns A new BABYLON.Mesh
  24980. */
  24981. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24982. /**
  24983. * Build Mesh from CSG taking material and transforms into account
  24984. * @param name The name of the BABYLON.Mesh
  24985. * @param material The material of the BABYLON.Mesh
  24986. * @param scene The BABYLON.Scene
  24987. * @param keepSubMeshes Specifies if submeshes should be kept
  24988. * @returns The new BABYLON.Mesh
  24989. */
  24990. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24991. }
  24992. }
  24993. declare module BABYLON {
  24994. /**
  24995. * Class used to store geometry data (vertex buffers + index buffer)
  24996. */
  24997. class Geometry implements IGetSetVerticesData {
  24998. /**
  24999. * Gets or sets the unique ID of the geometry
  25000. */
  25001. id: string;
  25002. /**
  25003. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25004. */
  25005. delayLoadState: number;
  25006. /**
  25007. * Gets the file containing the data to load when running in delay load state
  25008. */
  25009. delayLoadingFile: Nullable<string>;
  25010. /**
  25011. * Callback called when the geometry is updated
  25012. */
  25013. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25014. private _scene;
  25015. private _engine;
  25016. private _meshes;
  25017. private _totalVertices;
  25018. /** @hidden */
  25019. _indices: IndicesArray;
  25020. /** @hidden */
  25021. _vertexBuffers: {
  25022. [key: string]: VertexBuffer;
  25023. };
  25024. private _isDisposed;
  25025. private _extend;
  25026. private _boundingBias;
  25027. /** @hidden */
  25028. _delayInfo: Array<string>;
  25029. private _indexBuffer;
  25030. private _indexBufferIsUpdatable;
  25031. /** @hidden */
  25032. _boundingInfo: Nullable<BoundingInfo>;
  25033. /** @hidden */
  25034. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25035. /** @hidden */
  25036. _softwareSkinningFrameId: number;
  25037. private _vertexArrayObjects;
  25038. private _updatable;
  25039. /** @hidden */
  25040. _positions: Nullable<Vector3[]>;
  25041. /**
  25042. * 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
  25043. */
  25044. /**
  25045. * 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
  25046. */
  25047. boundingBias: Vector2;
  25048. /**
  25049. * Static function used to attach a new empty geometry to a mesh
  25050. * @param mesh defines the mesh to attach the geometry to
  25051. * @returns the new Geometry
  25052. */
  25053. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25054. /**
  25055. * Creates a new geometry
  25056. * @param id defines the unique ID
  25057. * @param scene defines the hosting scene
  25058. * @param vertexData defines the VertexData used to get geometry data
  25059. * @param updatable defines if geometry must be updatable (false by default)
  25060. * @param mesh defines the mesh that will be associated with the geometry
  25061. */
  25062. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25063. /**
  25064. * Gets the current extend of the geometry
  25065. */
  25066. readonly extend: {
  25067. minimum: Vector3;
  25068. maximum: Vector3;
  25069. };
  25070. /**
  25071. * Gets the hosting scene
  25072. * @returns the hosting Scene
  25073. */
  25074. getScene(): Scene;
  25075. /**
  25076. * Gets the hosting engine
  25077. * @returns the hosting Engine
  25078. */
  25079. getEngine(): Engine;
  25080. /**
  25081. * Defines if the geometry is ready to use
  25082. * @returns true if the geometry is ready to be used
  25083. */
  25084. isReady(): boolean;
  25085. /**
  25086. * Gets a value indicating that the geometry should not be serialized
  25087. */
  25088. readonly doNotSerialize: boolean;
  25089. /** @hidden */
  25090. _rebuild(): void;
  25091. /**
  25092. * Affects all geometry data in one call
  25093. * @param vertexData defines the geometry data
  25094. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25095. */
  25096. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25097. /**
  25098. * Set specific vertex data
  25099. * @param kind defines the data kind (Position, normal, etc...)
  25100. * @param data defines the vertex data to use
  25101. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25102. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25103. */
  25104. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25105. /**
  25106. * Removes a specific vertex data
  25107. * @param kind defines the data kind (Position, normal, etc...)
  25108. */
  25109. removeVerticesData(kind: string): void;
  25110. /**
  25111. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25112. * @param buffer defines the vertex buffer to use
  25113. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25114. */
  25115. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25116. /**
  25117. * Update a specific vertex buffer
  25118. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25119. * It will do nothing if the buffer is not updatable
  25120. * @param kind defines the data kind (Position, normal, etc...)
  25121. * @param data defines the data to use
  25122. * @param offset defines the offset in the target buffer where to store the data
  25123. * @param useBytes set to true if the offset is in bytes
  25124. */
  25125. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25126. /**
  25127. * Update a specific vertex buffer
  25128. * This function will create a new buffer if the current one is not updatable
  25129. * @param kind defines the data kind (Position, normal, etc...)
  25130. * @param data defines the data to use
  25131. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25132. */
  25133. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25134. private _updateBoundingInfo;
  25135. /** @hidden */
  25136. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25137. /**
  25138. * Gets total number of vertices
  25139. * @returns the total number of vertices
  25140. */
  25141. getTotalVertices(): number;
  25142. /**
  25143. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25144. * @param kind defines the data kind (Position, normal, etc...)
  25145. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25146. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25147. * @returns a float array containing vertex data
  25148. */
  25149. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25150. /**
  25151. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25152. * @param kind defines the data kind (Position, normal, etc...)
  25153. * @returns true if the vertex buffer with the specified kind is updatable
  25154. */
  25155. isVertexBufferUpdatable(kind: string): boolean;
  25156. /**
  25157. * Gets a specific vertex buffer
  25158. * @param kind defines the data kind (Position, normal, etc...)
  25159. * @returns a VertexBuffer
  25160. */
  25161. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25162. /**
  25163. * Returns all vertex buffers
  25164. * @return an object holding all vertex buffers indexed by kind
  25165. */
  25166. getVertexBuffers(): Nullable<{
  25167. [key: string]: VertexBuffer;
  25168. }>;
  25169. /**
  25170. * Gets a boolean indicating if specific vertex buffer is present
  25171. * @param kind defines the data kind (Position, normal, etc...)
  25172. * @returns true if data is present
  25173. */
  25174. isVerticesDataPresent(kind: string): boolean;
  25175. /**
  25176. * Gets a list of all attached data kinds (Position, normal, etc...)
  25177. * @returns a list of string containing all kinds
  25178. */
  25179. getVerticesDataKinds(): string[];
  25180. /**
  25181. * Update index buffer
  25182. * @param indices defines the indices to store in the index buffer
  25183. * @param offset defines the offset in the target buffer where to store the data
  25184. */
  25185. updateIndices(indices: IndicesArray, offset?: number): void;
  25186. /**
  25187. * Creates a new index buffer
  25188. * @param indices defines the indices to store in the index buffer
  25189. * @param totalVertices defines the total number of vertices (could be null)
  25190. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25191. */
  25192. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25193. /**
  25194. * Return the total number of indices
  25195. * @returns the total number of indices
  25196. */
  25197. getTotalIndices(): number;
  25198. /**
  25199. * Gets the index buffer array
  25200. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25201. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25202. * @returns the index buffer array
  25203. */
  25204. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25205. /**
  25206. * Gets the index buffer
  25207. * @return the index buffer
  25208. */
  25209. getIndexBuffer(): Nullable<WebGLBuffer>;
  25210. /** @hidden */
  25211. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25212. /**
  25213. * Release the associated resources for a specific mesh
  25214. * @param mesh defines the source mesh
  25215. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25216. */
  25217. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25218. /**
  25219. * Apply current geometry to a given mesh
  25220. * @param mesh defines the mesh to apply geometry to
  25221. */
  25222. applyToMesh(mesh: Mesh): void;
  25223. private _updateExtend;
  25224. private _applyToMesh;
  25225. private notifyUpdate;
  25226. /**
  25227. * Load the geometry if it was flagged as delay loaded
  25228. * @param scene defines the hosting scene
  25229. * @param onLoaded defines a callback called when the geometry is loaded
  25230. */
  25231. load(scene: Scene, onLoaded?: () => void): void;
  25232. private _queueLoad;
  25233. /**
  25234. * Invert the geometry to move from a right handed system to a left handed one.
  25235. */
  25236. toLeftHanded(): void;
  25237. /** @hidden */
  25238. _resetPointsArrayCache(): void;
  25239. /** @hidden */
  25240. _generatePointsArray(): boolean;
  25241. /**
  25242. * Gets a value indicating if the geometry is disposed
  25243. * @returns true if the geometry was disposed
  25244. */
  25245. isDisposed(): boolean;
  25246. private _disposeVertexArrayObjects;
  25247. /**
  25248. * Free all associated resources
  25249. */
  25250. dispose(): void;
  25251. /**
  25252. * Clone the current geometry into a new geometry
  25253. * @param id defines the unique ID of the new geometry
  25254. * @returns a new geometry object
  25255. */
  25256. copy(id: string): Geometry;
  25257. /**
  25258. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25259. * @return a JSON representation of the current geometry data (without the vertices data)
  25260. */
  25261. serialize(): any;
  25262. private toNumberArray;
  25263. /**
  25264. * Serialize all vertices data into a JSON oject
  25265. * @returns a JSON representation of the current geometry data
  25266. */
  25267. serializeVerticeData(): any;
  25268. /**
  25269. * Extracts a clone of a mesh geometry
  25270. * @param mesh defines the source mesh
  25271. * @param id defines the unique ID of the new geometry object
  25272. * @returns the new geometry object
  25273. */
  25274. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25275. /**
  25276. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25277. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25278. * Be aware Math.random() could cause collisions, but:
  25279. * "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"
  25280. * @returns a string containing a new GUID
  25281. */
  25282. static RandomId(): string;
  25283. /** @hidden */
  25284. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25285. private static _CleanMatricesWeights;
  25286. /**
  25287. * Create a new geometry from persisted data (Using .babylon file format)
  25288. * @param parsedVertexData defines the persisted data
  25289. * @param scene defines the hosting scene
  25290. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25291. * @returns the new geometry object
  25292. */
  25293. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25294. }
  25295. /**
  25296. * Abstract class used to provide common services for all typed geometries
  25297. * @hidden
  25298. */
  25299. class _PrimitiveGeometry extends Geometry {
  25300. private _canBeRegenerated;
  25301. private _beingRegenerated;
  25302. /**
  25303. * Creates a new typed geometry
  25304. * @param id defines the unique ID of the geometry
  25305. * @param scene defines the hosting scene
  25306. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25307. * @param mesh defines the hosting mesh (can be null)
  25308. */
  25309. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25310. /**
  25311. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25312. * @returns true if the geometry can be regenerated
  25313. */
  25314. canBeRegenerated(): boolean;
  25315. /**
  25316. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25317. */
  25318. regenerate(): void;
  25319. /**
  25320. * Clone the geometry
  25321. * @param id defines the unique ID of the new geometry
  25322. * @returns the new geometry
  25323. */
  25324. asNewGeometry(id: string): Geometry;
  25325. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25326. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25327. /** @hidden */
  25328. _regenerateVertexData(): VertexData;
  25329. copy(id: string): Geometry;
  25330. serialize(): any;
  25331. }
  25332. /**
  25333. * Creates a ribbon geometry
  25334. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25335. */
  25336. class RibbonGeometry extends _PrimitiveGeometry {
  25337. /**
  25338. * Defines the array of paths to use
  25339. */
  25340. pathArray: Vector3[][];
  25341. /**
  25342. * Defines if the last and first points of each path in your pathArray must be joined
  25343. */
  25344. closeArray: boolean;
  25345. /**
  25346. * Defines if the last and first points of each path in your pathArray must be joined
  25347. */
  25348. closePath: boolean;
  25349. /**
  25350. * Defines the offset between points
  25351. */
  25352. offset: number;
  25353. /**
  25354. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25355. */
  25356. side: number;
  25357. /**
  25358. * Creates a ribbon geometry
  25359. * @param id defines the unique ID of the geometry
  25360. * @param scene defines the hosting scene
  25361. * @param pathArray defines the array of paths to use
  25362. * @param closeArray defines if the last path and the first path must be joined
  25363. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25364. * @param offset defines the offset between points
  25365. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25366. * @param mesh defines the hosting mesh (can be null)
  25367. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25368. */
  25369. constructor(id: string, scene: Scene,
  25370. /**
  25371. * Defines the array of paths to use
  25372. */
  25373. pathArray: Vector3[][],
  25374. /**
  25375. * Defines if the last and first points of each path in your pathArray must be joined
  25376. */
  25377. closeArray: boolean,
  25378. /**
  25379. * Defines if the last and first points of each path in your pathArray must be joined
  25380. */
  25381. closePath: boolean,
  25382. /**
  25383. * Defines the offset between points
  25384. */
  25385. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25386. /**
  25387. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25388. */
  25389. side?: number);
  25390. /** @hidden */
  25391. _regenerateVertexData(): VertexData;
  25392. copy(id: string): Geometry;
  25393. }
  25394. /**
  25395. * Creates a box geometry
  25396. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25397. */
  25398. class BoxGeometry extends _PrimitiveGeometry {
  25399. /**
  25400. * Defines the zise of the box (width, height and depth are the same)
  25401. */
  25402. size: number;
  25403. /**
  25404. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25405. */
  25406. side: number;
  25407. /**
  25408. * Creates a box geometry
  25409. * @param id defines the unique ID of the geometry
  25410. * @param scene defines the hosting scene
  25411. * @param size defines the zise of the box (width, height and depth are the same)
  25412. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25413. * @param mesh defines the hosting mesh (can be null)
  25414. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25415. */
  25416. constructor(id: string, scene: Scene,
  25417. /**
  25418. * Defines the zise of the box (width, height and depth are the same)
  25419. */
  25420. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25421. /**
  25422. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25423. */
  25424. side?: number);
  25425. /** @hidden */
  25426. _regenerateVertexData(): VertexData;
  25427. copy(id: string): Geometry;
  25428. serialize(): any;
  25429. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25430. }
  25431. /**
  25432. * Creates a sphere geometry
  25433. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25434. */
  25435. class SphereGeometry extends _PrimitiveGeometry {
  25436. /**
  25437. * Defines the number of segments to use to create the sphere
  25438. */
  25439. segments: number;
  25440. /**
  25441. * Defines the diameter of the sphere
  25442. */
  25443. diameter: number;
  25444. /**
  25445. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25446. */
  25447. side: number;
  25448. /**
  25449. * Create a new sphere geometry
  25450. * @param id defines the unique ID of the geometry
  25451. * @param scene defines the hosting scene
  25452. * @param segments defines the number of segments to use to create the sphere
  25453. * @param diameter defines the diameter of the sphere
  25454. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25455. * @param mesh defines the hosting mesh (can be null)
  25456. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25457. */
  25458. constructor(id: string, scene: Scene,
  25459. /**
  25460. * Defines the number of segments to use to create the sphere
  25461. */
  25462. segments: number,
  25463. /**
  25464. * Defines the diameter of the sphere
  25465. */
  25466. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25467. /**
  25468. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25469. */
  25470. side?: number);
  25471. /** @hidden */
  25472. _regenerateVertexData(): VertexData;
  25473. copy(id: string): Geometry;
  25474. serialize(): any;
  25475. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25476. }
  25477. /**
  25478. * Creates a disc geometry
  25479. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25480. */
  25481. class DiscGeometry extends _PrimitiveGeometry {
  25482. /**
  25483. * Defines the radius of the disc
  25484. */
  25485. radius: number;
  25486. /**
  25487. * Defines the tesselation factor to apply to the disc
  25488. */
  25489. tessellation: number;
  25490. /**
  25491. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25492. */
  25493. side: number;
  25494. /**
  25495. * Creates a new disc geometry
  25496. * @param id defines the unique ID of the geometry
  25497. * @param scene defines the hosting scene
  25498. * @param radius defines the radius of the disc
  25499. * @param tessellation defines the tesselation factor to apply to the disc
  25500. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25501. * @param mesh defines the hosting mesh (can be null)
  25502. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25503. */
  25504. constructor(id: string, scene: Scene,
  25505. /**
  25506. * Defines the radius of the disc
  25507. */
  25508. radius: number,
  25509. /**
  25510. * Defines the tesselation factor to apply to the disc
  25511. */
  25512. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25513. /**
  25514. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25515. */
  25516. side?: number);
  25517. /** @hidden */
  25518. _regenerateVertexData(): VertexData;
  25519. copy(id: string): Geometry;
  25520. }
  25521. /**
  25522. * Creates a new cylinder geometry
  25523. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25524. */
  25525. class CylinderGeometry extends _PrimitiveGeometry {
  25526. /**
  25527. * Defines the height of the cylinder
  25528. */
  25529. height: number;
  25530. /**
  25531. * Defines the diameter of the cylinder's top cap
  25532. */
  25533. diameterTop: number;
  25534. /**
  25535. * Defines the diameter of the cylinder's bottom cap
  25536. */
  25537. diameterBottom: number;
  25538. /**
  25539. * Defines the tessellation factor to apply to the cylinder
  25540. */
  25541. tessellation: number;
  25542. /**
  25543. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25544. */
  25545. subdivisions: number;
  25546. /**
  25547. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25548. */
  25549. side: number;
  25550. /**
  25551. * Creates a new cylinder geometry
  25552. * @param id defines the unique ID of the geometry
  25553. * @param scene defines the hosting scene
  25554. * @param height defines the height of the cylinder
  25555. * @param diameterTop defines the diameter of the cylinder's top cap
  25556. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25557. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25558. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25559. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25560. * @param mesh defines the hosting mesh (can be null)
  25561. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25562. */
  25563. constructor(id: string, scene: Scene,
  25564. /**
  25565. * Defines the height of the cylinder
  25566. */
  25567. height: number,
  25568. /**
  25569. * Defines the diameter of the cylinder's top cap
  25570. */
  25571. diameterTop: number,
  25572. /**
  25573. * Defines the diameter of the cylinder's bottom cap
  25574. */
  25575. diameterBottom: number,
  25576. /**
  25577. * Defines the tessellation factor to apply to the cylinder
  25578. */
  25579. tessellation: number,
  25580. /**
  25581. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25582. */
  25583. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25584. /**
  25585. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25586. */
  25587. side?: number);
  25588. /** @hidden */
  25589. _regenerateVertexData(): VertexData;
  25590. copy(id: string): Geometry;
  25591. serialize(): any;
  25592. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25593. }
  25594. /**
  25595. * Creates a new torus geometry
  25596. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25597. */
  25598. class TorusGeometry extends _PrimitiveGeometry {
  25599. /**
  25600. * Defines the diameter of the torus
  25601. */
  25602. diameter: number;
  25603. /**
  25604. * Defines the thickness of the torus (ie. internal diameter)
  25605. */
  25606. thickness: number;
  25607. /**
  25608. * Defines the tesselation factor to apply to the torus
  25609. */
  25610. tessellation: number;
  25611. /**
  25612. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25613. */
  25614. side: number;
  25615. /**
  25616. * Creates a new torus geometry
  25617. * @param id defines the unique ID of the geometry
  25618. * @param scene defines the hosting scene
  25619. * @param diameter defines the diameter of the torus
  25620. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25621. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25622. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25623. * @param mesh defines the hosting mesh (can be null)
  25624. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25625. */
  25626. constructor(id: string, scene: Scene,
  25627. /**
  25628. * Defines the diameter of the torus
  25629. */
  25630. diameter: number,
  25631. /**
  25632. * Defines the thickness of the torus (ie. internal diameter)
  25633. */
  25634. thickness: number,
  25635. /**
  25636. * Defines the tesselation factor to apply to the torus
  25637. */
  25638. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25639. /**
  25640. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25641. */
  25642. side?: number);
  25643. /** @hidden */
  25644. _regenerateVertexData(): VertexData;
  25645. copy(id: string): Geometry;
  25646. serialize(): any;
  25647. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25648. }
  25649. /**
  25650. * Creates a new ground geometry
  25651. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25652. */
  25653. class GroundGeometry extends _PrimitiveGeometry {
  25654. /**
  25655. * Defines the width of the ground
  25656. */
  25657. width: number;
  25658. /**
  25659. * Defines the height of the ground
  25660. */
  25661. height: number;
  25662. /**
  25663. * Defines the subdivisions to apply to the ground
  25664. */
  25665. subdivisions: number;
  25666. /**
  25667. * Creates a new ground geometry
  25668. * @param id defines the unique ID of the geometry
  25669. * @param scene defines the hosting scene
  25670. * @param width defines the width of the ground
  25671. * @param height defines the height of the ground
  25672. * @param subdivisions defines the subdivisions to apply to the ground
  25673. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25674. * @param mesh defines the hosting mesh (can be null)
  25675. */
  25676. constructor(id: string, scene: Scene,
  25677. /**
  25678. * Defines the width of the ground
  25679. */
  25680. width: number,
  25681. /**
  25682. * Defines the height of the ground
  25683. */
  25684. height: number,
  25685. /**
  25686. * Defines the subdivisions to apply to the ground
  25687. */
  25688. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25689. /** @hidden */
  25690. _regenerateVertexData(): VertexData;
  25691. copy(id: string): Geometry;
  25692. serialize(): any;
  25693. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25694. }
  25695. /**
  25696. * Creates a tiled ground geometry
  25697. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25698. */
  25699. class TiledGroundGeometry extends _PrimitiveGeometry {
  25700. /**
  25701. * Defines the minimum value on X axis
  25702. */
  25703. xmin: number;
  25704. /**
  25705. * Defines the minimum value on Z axis
  25706. */
  25707. zmin: number;
  25708. /**
  25709. * Defines the maximum value on X axis
  25710. */
  25711. xmax: number;
  25712. /**
  25713. * Defines the maximum value on Z axis
  25714. */
  25715. zmax: number;
  25716. /**
  25717. * Defines the subdivisions to apply to the ground
  25718. */
  25719. subdivisions: {
  25720. w: number;
  25721. h: number;
  25722. };
  25723. /**
  25724. * Defines the precision to use when computing the tiles
  25725. */
  25726. precision: {
  25727. w: number;
  25728. h: number;
  25729. };
  25730. /**
  25731. * Creates a tiled ground geometry
  25732. * @param id defines the unique ID of the geometry
  25733. * @param scene defines the hosting scene
  25734. * @param xmin defines the minimum value on X axis
  25735. * @param zmin defines the minimum value on Z axis
  25736. * @param xmax defines the maximum value on X axis
  25737. * @param zmax defines the maximum value on Z axis
  25738. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25739. * @param precision defines the precision to use when computing the tiles
  25740. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25741. * @param mesh defines the hosting mesh (can be null)
  25742. */
  25743. constructor(id: string, scene: Scene,
  25744. /**
  25745. * Defines the minimum value on X axis
  25746. */
  25747. xmin: number,
  25748. /**
  25749. * Defines the minimum value on Z axis
  25750. */
  25751. zmin: number,
  25752. /**
  25753. * Defines the maximum value on X axis
  25754. */
  25755. xmax: number,
  25756. /**
  25757. * Defines the maximum value on Z axis
  25758. */
  25759. zmax: number,
  25760. /**
  25761. * Defines the subdivisions to apply to the ground
  25762. */
  25763. subdivisions: {
  25764. w: number;
  25765. h: number;
  25766. },
  25767. /**
  25768. * Defines the precision to use when computing the tiles
  25769. */
  25770. precision: {
  25771. w: number;
  25772. h: number;
  25773. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25774. /** @hidden */
  25775. _regenerateVertexData(): VertexData;
  25776. copy(id: string): Geometry;
  25777. }
  25778. /**
  25779. * Creates a plane geometry
  25780. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25781. */
  25782. class PlaneGeometry extends _PrimitiveGeometry {
  25783. /**
  25784. * Defines the size of the plane (width === height)
  25785. */
  25786. size: number;
  25787. /**
  25788. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25789. */
  25790. side: number;
  25791. /**
  25792. * Creates a plane geometry
  25793. * @param id defines the unique ID of the geometry
  25794. * @param scene defines the hosting scene
  25795. * @param size defines the size of the plane (width === height)
  25796. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25797. * @param mesh defines the hosting mesh (can be null)
  25798. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25799. */
  25800. constructor(id: string, scene: Scene,
  25801. /**
  25802. * Defines the size of the plane (width === height)
  25803. */
  25804. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25805. /**
  25806. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25807. */
  25808. side?: number);
  25809. /** @hidden */
  25810. _regenerateVertexData(): VertexData;
  25811. copy(id: string): Geometry;
  25812. serialize(): any;
  25813. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25814. }
  25815. /**
  25816. * Creates a torus knot geometry
  25817. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25818. */
  25819. class TorusKnotGeometry extends _PrimitiveGeometry {
  25820. /**
  25821. * Defines the radius of the torus knot
  25822. */
  25823. radius: number;
  25824. /**
  25825. * Defines the thickness of the torus knot tube
  25826. */
  25827. tube: number;
  25828. /**
  25829. * Defines the number of radial segments
  25830. */
  25831. radialSegments: number;
  25832. /**
  25833. * Defines the number of tubular segments
  25834. */
  25835. tubularSegments: number;
  25836. /**
  25837. * Defines the first number of windings
  25838. */
  25839. p: number;
  25840. /**
  25841. * Defines the second number of windings
  25842. */
  25843. q: number;
  25844. /**
  25845. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25846. */
  25847. side: number;
  25848. /**
  25849. * Creates a torus knot geometry
  25850. * @param id defines the unique ID of the geometry
  25851. * @param scene defines the hosting scene
  25852. * @param radius defines the radius of the torus knot
  25853. * @param tube defines the thickness of the torus knot tube
  25854. * @param radialSegments defines the number of radial segments
  25855. * @param tubularSegments defines the number of tubular segments
  25856. * @param p defines the first number of windings
  25857. * @param q defines the second number of windings
  25858. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25859. * @param mesh defines the hosting mesh (can be null)
  25860. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25861. */
  25862. constructor(id: string, scene: Scene,
  25863. /**
  25864. * Defines the radius of the torus knot
  25865. */
  25866. radius: number,
  25867. /**
  25868. * Defines the thickness of the torus knot tube
  25869. */
  25870. tube: number,
  25871. /**
  25872. * Defines the number of radial segments
  25873. */
  25874. radialSegments: number,
  25875. /**
  25876. * Defines the number of tubular segments
  25877. */
  25878. tubularSegments: number,
  25879. /**
  25880. * Defines the first number of windings
  25881. */
  25882. p: number,
  25883. /**
  25884. * Defines the second number of windings
  25885. */
  25886. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25887. /**
  25888. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25889. */
  25890. side?: number);
  25891. /** @hidden */
  25892. _regenerateVertexData(): VertexData;
  25893. copy(id: string): Geometry;
  25894. serialize(): any;
  25895. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25896. }
  25897. }
  25898. declare module BABYLON {
  25899. /**
  25900. * Mesh representing the gorund
  25901. */
  25902. class GroundMesh extends Mesh {
  25903. /** If octree should be generated */
  25904. generateOctree: boolean;
  25905. private _heightQuads;
  25906. /** @hidden */
  25907. _subdivisionsX: number;
  25908. /** @hidden */
  25909. _subdivisionsY: number;
  25910. /** @hidden */
  25911. _width: number;
  25912. /** @hidden */
  25913. _height: number;
  25914. /** @hidden */
  25915. _minX: number;
  25916. /** @hidden */
  25917. _maxX: number;
  25918. /** @hidden */
  25919. _minZ: number;
  25920. /** @hidden */
  25921. _maxZ: number;
  25922. constructor(name: string, scene: Scene);
  25923. /**
  25924. * "GroundMesh"
  25925. * @returns "GroundMesh"
  25926. */
  25927. getClassName(): string;
  25928. /**
  25929. * The minimum of x and y subdivisions
  25930. */
  25931. readonly subdivisions: number;
  25932. /**
  25933. * X subdivisions
  25934. */
  25935. readonly subdivisionsX: number;
  25936. /**
  25937. * Y subdivisions
  25938. */
  25939. readonly subdivisionsY: number;
  25940. /**
  25941. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25942. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25943. * @param chunksCount the number of subdivisions for x and y
  25944. * @param octreeBlocksSize (Default: 32)
  25945. */
  25946. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25947. /**
  25948. * Returns a height (y) value in the Worl system :
  25949. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25950. * @param x x coordinate
  25951. * @param z z coordinate
  25952. * @returns the ground y position if (x, z) are outside the ground surface.
  25953. */
  25954. getHeightAtCoordinates(x: number, z: number): number;
  25955. /**
  25956. * Returns a normalized vector (Vector3) orthogonal to the ground
  25957. * at the ground coordinates (x, z) expressed in the World system.
  25958. * @param x x coordinate
  25959. * @param z z coordinate
  25960. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25961. */
  25962. getNormalAtCoordinates(x: number, z: number): Vector3;
  25963. /**
  25964. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25965. * at the ground coordinates (x, z) expressed in the World system.
  25966. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25967. * @param x x coordinate
  25968. * @param z z coordinate
  25969. * @param ref vector to store the result
  25970. * @returns the GroundMesh.
  25971. */
  25972. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25973. /**
  25974. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25975. * if the ground has been updated.
  25976. * This can be used in the render loop.
  25977. * @returns the GroundMesh.
  25978. */
  25979. updateCoordinateHeights(): GroundMesh;
  25980. private _getFacetAt;
  25981. private _initHeightQuads;
  25982. private _computeHeightQuads;
  25983. /**
  25984. * Serializes this ground mesh
  25985. * @param serializationObject object to write serialization to
  25986. */
  25987. serialize(serializationObject: any): void;
  25988. /**
  25989. * Parses a serialized ground mesh
  25990. * @param parsedMesh the serialized mesh
  25991. * @param scene the scene to create the ground mesh in
  25992. * @returns the created ground mesh
  25993. */
  25994. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25995. }
  25996. }
  25997. declare module BABYLON {
  25998. /**
  25999. * Creates an instance based on a source mesh.
  26000. */
  26001. class InstancedMesh extends AbstractMesh {
  26002. private _sourceMesh;
  26003. private _currentLOD;
  26004. /** @hidden */
  26005. _indexInSourceMeshInstanceArray: number;
  26006. constructor(name: string, source: Mesh);
  26007. /**
  26008. * Returns the string "InstancedMesh".
  26009. */
  26010. getClassName(): string;
  26011. /**
  26012. * If the source mesh receives shadows
  26013. */
  26014. readonly receiveShadows: boolean;
  26015. /**
  26016. * The material of the source mesh
  26017. */
  26018. readonly material: Nullable<Material>;
  26019. /**
  26020. * Visibility of the source mesh
  26021. */
  26022. readonly visibility: number;
  26023. /**
  26024. * Skeleton of the source mesh
  26025. */
  26026. readonly skeleton: Nullable<Skeleton>;
  26027. /**
  26028. * Rendering ground id of the source mesh
  26029. */
  26030. renderingGroupId: number;
  26031. /**
  26032. * Returns the total number of vertices (integer).
  26033. */
  26034. getTotalVertices(): number;
  26035. /**
  26036. * The source mesh of the instance
  26037. */
  26038. readonly sourceMesh: Mesh;
  26039. /**
  26040. * Is this node ready to be used/rendered
  26041. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26042. * @return {boolean} is it ready
  26043. */
  26044. isReady(completeCheck?: boolean): boolean;
  26045. /**
  26046. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26047. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26048. * @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.
  26049. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26050. */
  26051. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26052. /**
  26053. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26054. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26055. * The `data` are either a numeric array either a Float32Array.
  26056. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26057. * 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).
  26058. * Note that a new underlying VertexBuffer object is created each call.
  26059. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26060. *
  26061. * Possible `kind` values :
  26062. * - BABYLON.VertexBuffer.PositionKind
  26063. * - BABYLON.VertexBuffer.UVKind
  26064. * - BABYLON.VertexBuffer.UV2Kind
  26065. * - BABYLON.VertexBuffer.UV3Kind
  26066. * - BABYLON.VertexBuffer.UV4Kind
  26067. * - BABYLON.VertexBuffer.UV5Kind
  26068. * - BABYLON.VertexBuffer.UV6Kind
  26069. * - BABYLON.VertexBuffer.ColorKind
  26070. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26071. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26072. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26073. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26074. *
  26075. * Returns the Mesh.
  26076. */
  26077. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26078. /**
  26079. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26080. * If the mesh has no geometry, it is simply returned as it is.
  26081. * The `data` are either a numeric array either a Float32Array.
  26082. * No new underlying VertexBuffer object is created.
  26083. * 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.
  26084. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26085. *
  26086. * Possible `kind` values :
  26087. * - BABYLON.VertexBuffer.PositionKind
  26088. * - BABYLON.VertexBuffer.UVKind
  26089. * - BABYLON.VertexBuffer.UV2Kind
  26090. * - BABYLON.VertexBuffer.UV3Kind
  26091. * - BABYLON.VertexBuffer.UV4Kind
  26092. * - BABYLON.VertexBuffer.UV5Kind
  26093. * - BABYLON.VertexBuffer.UV6Kind
  26094. * - BABYLON.VertexBuffer.ColorKind
  26095. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26096. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26097. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26098. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26099. *
  26100. * Returns the Mesh.
  26101. */
  26102. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26103. /**
  26104. * Sets the mesh indices.
  26105. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26106. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26107. * This method creates a new index buffer each call.
  26108. * Returns the Mesh.
  26109. */
  26110. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26111. /**
  26112. * Boolean : True if the mesh owns the requested kind of data.
  26113. */
  26114. isVerticesDataPresent(kind: string): boolean;
  26115. /**
  26116. * Returns an array of indices (IndicesArray).
  26117. */
  26118. getIndices(): Nullable<IndicesArray>;
  26119. readonly _positions: Nullable<Vector3[]>;
  26120. /**
  26121. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26122. * This means the mesh underlying bounding box and sphere are recomputed.
  26123. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26124. * @returns the current mesh
  26125. */
  26126. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26127. /** @hidden */
  26128. _preActivate(): InstancedMesh;
  26129. /** @hidden */
  26130. _activate(renderId: number): InstancedMesh;
  26131. /**
  26132. * Returns the current associated LOD AbstractMesh.
  26133. */
  26134. getLOD(camera: Camera): AbstractMesh;
  26135. /** @hidden */
  26136. _syncSubMeshes(): InstancedMesh;
  26137. /** @hidden */
  26138. _generatePointsArray(): boolean;
  26139. /**
  26140. * Creates a new InstancedMesh from the current mesh.
  26141. * - name (string) : the cloned mesh name
  26142. * - newParent (optional Node) : the optional Node to parent the clone to.
  26143. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26144. *
  26145. * Returns the clone.
  26146. */
  26147. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26148. /**
  26149. * Disposes the InstancedMesh.
  26150. * Returns nothing.
  26151. */
  26152. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26153. }
  26154. }
  26155. declare module BABYLON {
  26156. /**
  26157. * Line mesh
  26158. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26159. */
  26160. class LinesMesh extends Mesh {
  26161. /**
  26162. * If vertex color should be applied to the mesh
  26163. */
  26164. useVertexColor?: boolean | undefined;
  26165. /**
  26166. * If vertex alpha should be applied to the mesh
  26167. */
  26168. useVertexAlpha?: boolean | undefined;
  26169. /**
  26170. * Color of the line (Default: White)
  26171. */
  26172. color: Color3;
  26173. /**
  26174. * Alpha of the line (Default: 1)
  26175. */
  26176. alpha: number;
  26177. /**
  26178. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26179. * This margin is expressed in world space coordinates, so its value may vary.
  26180. * Default value is 0.1
  26181. */
  26182. intersectionThreshold: number;
  26183. private _colorShader;
  26184. /**
  26185. * Creates a new LinesMesh
  26186. * @param name defines the name
  26187. * @param scene defines the hosting scene
  26188. * @param parent defines the parent mesh if any
  26189. * @param source defines the optional source LinesMesh used to clone data from
  26190. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26191. * When false, achieved by calling a clone(), also passing False.
  26192. * This will make creation of children, recursive.
  26193. * @param useVertexColor defines if this LinesMesh supports vertex color
  26194. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26195. */
  26196. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26197. /**
  26198. * If vertex color should be applied to the mesh
  26199. */
  26200. useVertexColor?: boolean | undefined,
  26201. /**
  26202. * If vertex alpha should be applied to the mesh
  26203. */
  26204. useVertexAlpha?: boolean | undefined);
  26205. /**
  26206. * Returns the string "LineMesh"
  26207. */
  26208. getClassName(): string;
  26209. /**
  26210. * @hidden
  26211. */
  26212. /**
  26213. * @hidden
  26214. */
  26215. material: Material;
  26216. /**
  26217. * @hidden
  26218. */
  26219. readonly checkCollisions: boolean;
  26220. /** @hidden */
  26221. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26222. /** @hidden */
  26223. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26224. /**
  26225. * Disposes of the line mesh
  26226. * @param doNotRecurse If children should be disposed
  26227. */
  26228. dispose(doNotRecurse?: boolean): void;
  26229. /**
  26230. * Returns a new LineMesh object cloned from the current one.
  26231. */
  26232. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26233. /**
  26234. * Creates a new InstancedLinesMesh object from the mesh model.
  26235. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26236. * @param name defines the name of the new instance
  26237. * @returns a new InstancedLinesMesh
  26238. */
  26239. createInstance(name: string): InstancedLinesMesh;
  26240. }
  26241. /**
  26242. * Creates an instance based on a source LinesMesh
  26243. */
  26244. class InstancedLinesMesh extends InstancedMesh {
  26245. /**
  26246. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26247. * This margin is expressed in world space coordinates, so its value may vary.
  26248. * Initilized with the intersectionThreshold value of the source LinesMesh
  26249. */
  26250. intersectionThreshold: number;
  26251. constructor(name: string, source: LinesMesh);
  26252. /**
  26253. * Returns the string "InstancedLinesMesh".
  26254. */
  26255. getClassName(): string;
  26256. }
  26257. }
  26258. declare module BABYLON {
  26259. /**
  26260. * @hidden
  26261. **/
  26262. class _CreationDataStorage {
  26263. closePath?: boolean;
  26264. closeArray?: boolean;
  26265. idx: number[];
  26266. dashSize: number;
  26267. gapSize: number;
  26268. path3D: Path3D;
  26269. pathArray: Vector3[][];
  26270. arc: number;
  26271. radius: number;
  26272. cap: number;
  26273. tessellation: number;
  26274. }
  26275. /**
  26276. * @hidden
  26277. **/
  26278. class _InstanceDataStorage {
  26279. visibleInstances: any;
  26280. renderIdForInstances: number[];
  26281. batchCache: _InstancesBatch;
  26282. instancesBufferSize: number;
  26283. instancesBuffer: Nullable<Buffer>;
  26284. instancesData: Float32Array;
  26285. overridenInstanceCount: number;
  26286. }
  26287. /**
  26288. * @hidden
  26289. **/
  26290. class _InstancesBatch {
  26291. mustReturn: boolean;
  26292. visibleInstances: Nullable<InstancedMesh[]>[];
  26293. renderSelf: boolean[];
  26294. }
  26295. /**
  26296. * Class used to represent renderable models
  26297. */
  26298. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26299. /**
  26300. * Mesh side orientation : usually the external or front surface
  26301. */
  26302. static readonly FRONTSIDE: number;
  26303. /**
  26304. * Mesh side orientation : usually the internal or back surface
  26305. */
  26306. static readonly BACKSIDE: number;
  26307. /**
  26308. * Mesh side orientation : both internal and external or front and back surfaces
  26309. */
  26310. static readonly DOUBLESIDE: number;
  26311. /**
  26312. * Mesh side orientation : by default, `FRONTSIDE`
  26313. */
  26314. static readonly DEFAULTSIDE: number;
  26315. /**
  26316. * Mesh cap setting : no cap
  26317. */
  26318. static readonly NO_CAP: number;
  26319. /**
  26320. * Mesh cap setting : one cap at the beginning of the mesh
  26321. */
  26322. static readonly CAP_START: number;
  26323. /**
  26324. * Mesh cap setting : one cap at the end of the mesh
  26325. */
  26326. static readonly CAP_END: number;
  26327. /**
  26328. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26329. */
  26330. static readonly CAP_ALL: number;
  26331. private _onBeforeRenderObservable;
  26332. private _onAfterRenderObservable;
  26333. private _onBeforeDrawObservable;
  26334. /**
  26335. * An event triggered before rendering the mesh
  26336. */
  26337. readonly onBeforeRenderObservable: Observable<Mesh>;
  26338. /**
  26339. * An event triggered after rendering the mesh
  26340. */
  26341. readonly onAfterRenderObservable: Observable<Mesh>;
  26342. /**
  26343. * An event triggered before drawing the mesh
  26344. */
  26345. readonly onBeforeDrawObservable: Observable<Mesh>;
  26346. private _onBeforeDrawObserver;
  26347. /**
  26348. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26349. */
  26350. onBeforeDraw: () => void;
  26351. /**
  26352. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26353. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26354. */
  26355. delayLoadState: number;
  26356. /**
  26357. * Gets the list of instances created from this mesh
  26358. * it is not supposed to be modified manually.
  26359. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26361. */
  26362. instances: InstancedMesh[];
  26363. /**
  26364. * Gets the file containing delay loading data for this mesh
  26365. */
  26366. delayLoadingFile: string;
  26367. /** @hidden */
  26368. _binaryInfo: any;
  26369. private _LODLevels;
  26370. /**
  26371. * User defined function used to change how LOD level selection is done
  26372. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26373. */
  26374. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26375. private _morphTargetManager;
  26376. /**
  26377. * Gets or sets the morph target manager
  26378. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26379. */
  26380. morphTargetManager: Nullable<MorphTargetManager>;
  26381. /** @hidden */
  26382. _creationDataStorage: Nullable<_CreationDataStorage>;
  26383. /** @hidden */
  26384. _geometry: Nullable<Geometry>;
  26385. /** @hidden */
  26386. _delayInfo: Array<string>;
  26387. /** @hidden */
  26388. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26389. /** @hidden */
  26390. _instanceDataStorage: _InstanceDataStorage;
  26391. private _effectiveMaterial;
  26392. /** @hidden */
  26393. _shouldGenerateFlatShading: boolean;
  26394. private _preActivateId;
  26395. /** @hidden */
  26396. _originalBuilderSideOrientation: number;
  26397. /**
  26398. * Use this property to change the original side orientation defined at construction time
  26399. */
  26400. overrideMaterialSideOrientation: Nullable<number>;
  26401. private _areNormalsFrozen;
  26402. private _sourcePositions;
  26403. private _sourceNormals;
  26404. private _source;
  26405. private meshMap;
  26406. /**
  26407. * Gets the source mesh (the one used to clone this one from)
  26408. */
  26409. readonly source: Nullable<Mesh>;
  26410. /**
  26411. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26412. */
  26413. isUnIndexed: boolean;
  26414. /**
  26415. * @constructor
  26416. * @param name The value used by scene.getMeshByName() to do a lookup.
  26417. * @param scene The scene to add this mesh to.
  26418. * @param parent The parent of this mesh, if it has one
  26419. * @param source An optional Mesh from which geometry is shared, cloned.
  26420. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26421. * When false, achieved by calling a clone(), also passing False.
  26422. * This will make creation of children, recursive.
  26423. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26424. */
  26425. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26426. /**
  26427. * Gets the class name
  26428. * @returns the string "Mesh".
  26429. */
  26430. getClassName(): string;
  26431. /**
  26432. * Returns a description of this mesh
  26433. * @param fullDetails define if full details about this mesh must be used
  26434. * @returns a descriptive string representing this mesh
  26435. */
  26436. toString(fullDetails?: boolean): string;
  26437. /** @hidden */
  26438. _unBindEffect(): void;
  26439. /**
  26440. * Gets a boolean indicating if this mesh has LOD
  26441. */
  26442. readonly hasLODLevels: boolean;
  26443. /**
  26444. * Gets the list of MeshLODLevel associated with the current mesh
  26445. * @returns an array of MeshLODLevel
  26446. */
  26447. getLODLevels(): MeshLODLevel[];
  26448. private _sortLODLevels;
  26449. /**
  26450. * Add a mesh as LOD level triggered at the given distance.
  26451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26452. * @param distance The distance from the center of the object to show this level
  26453. * @param mesh The mesh to be added as LOD level (can be null)
  26454. * @return This mesh (for chaining)
  26455. */
  26456. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26457. /**
  26458. * Returns the LOD level mesh at the passed distance or null if not found.
  26459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26460. * @param distance The distance from the center of the object to show this level
  26461. * @returns a Mesh or `null`
  26462. */
  26463. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26464. /**
  26465. * Remove a mesh from the LOD array
  26466. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26467. * @param mesh defines the mesh to be removed
  26468. * @return This mesh (for chaining)
  26469. */
  26470. removeLODLevel(mesh: Mesh): Mesh;
  26471. /**
  26472. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26473. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26474. * @param camera defines the camera to use to compute distance
  26475. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26476. * @return This mesh (for chaining)
  26477. */
  26478. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26479. /**
  26480. * Gets the mesh internal Geometry object
  26481. */
  26482. readonly geometry: Nullable<Geometry>;
  26483. /**
  26484. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26485. * @returns the total number of vertices
  26486. */
  26487. getTotalVertices(): number;
  26488. /**
  26489. * Returns the content of an associated vertex buffer
  26490. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26491. * - BABYLON.VertexBuffer.PositionKind
  26492. * - BABYLON.VertexBuffer.UVKind
  26493. * - BABYLON.VertexBuffer.UV2Kind
  26494. * - BABYLON.VertexBuffer.UV3Kind
  26495. * - BABYLON.VertexBuffer.UV4Kind
  26496. * - BABYLON.VertexBuffer.UV5Kind
  26497. * - BABYLON.VertexBuffer.UV6Kind
  26498. * - BABYLON.VertexBuffer.ColorKind
  26499. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26500. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26501. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26502. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26503. * @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
  26504. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26505. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26506. */
  26507. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26508. /**
  26509. * Returns the mesh VertexBuffer object from the requested `kind`
  26510. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26511. * - BABYLON.VertexBuffer.PositionKind
  26512. * - BABYLON.VertexBuffer.UVKind
  26513. * - BABYLON.VertexBuffer.UV2Kind
  26514. * - BABYLON.VertexBuffer.UV3Kind
  26515. * - BABYLON.VertexBuffer.UV4Kind
  26516. * - BABYLON.VertexBuffer.UV5Kind
  26517. * - BABYLON.VertexBuffer.UV6Kind
  26518. * - BABYLON.VertexBuffer.ColorKind
  26519. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26520. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26521. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26522. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26523. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26524. */
  26525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26526. /**
  26527. * Tests if a specific vertex buffer is associated with this mesh
  26528. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26529. * - BABYLON.VertexBuffer.PositionKind
  26530. * - BABYLON.VertexBuffer.UVKind
  26531. * - BABYLON.VertexBuffer.UV2Kind
  26532. * - BABYLON.VertexBuffer.UV3Kind
  26533. * - BABYLON.VertexBuffer.UV4Kind
  26534. * - BABYLON.VertexBuffer.UV5Kind
  26535. * - BABYLON.VertexBuffer.UV6Kind
  26536. * - BABYLON.VertexBuffer.ColorKind
  26537. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26538. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26539. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26540. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26541. * @returns a boolean
  26542. */
  26543. isVerticesDataPresent(kind: string): boolean;
  26544. /**
  26545. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26546. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26547. * - BABYLON.VertexBuffer.PositionKind
  26548. * - BABYLON.VertexBuffer.UVKind
  26549. * - BABYLON.VertexBuffer.UV2Kind
  26550. * - BABYLON.VertexBuffer.UV3Kind
  26551. * - BABYLON.VertexBuffer.UV4Kind
  26552. * - BABYLON.VertexBuffer.UV5Kind
  26553. * - BABYLON.VertexBuffer.UV6Kind
  26554. * - BABYLON.VertexBuffer.ColorKind
  26555. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26556. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26557. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26558. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26559. * @returns a boolean
  26560. */
  26561. isVertexBufferUpdatable(kind: string): boolean;
  26562. /**
  26563. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26564. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26565. * - BABYLON.VertexBuffer.PositionKind
  26566. * - BABYLON.VertexBuffer.UVKind
  26567. * - BABYLON.VertexBuffer.UV2Kind
  26568. * - BABYLON.VertexBuffer.UV3Kind
  26569. * - BABYLON.VertexBuffer.UV4Kind
  26570. * - BABYLON.VertexBuffer.UV5Kind
  26571. * - BABYLON.VertexBuffer.UV6Kind
  26572. * - BABYLON.VertexBuffer.ColorKind
  26573. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26574. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26575. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26576. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26577. * @returns an array of strings
  26578. */
  26579. getVerticesDataKinds(): string[];
  26580. /**
  26581. * Returns a positive integer : the total number of indices in this mesh geometry.
  26582. * @returns the numner of indices or zero if the mesh has no geometry.
  26583. */
  26584. getTotalIndices(): number;
  26585. /**
  26586. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26587. * @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.
  26588. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26589. * @returns the indices array or an empty array if the mesh has no geometry
  26590. */
  26591. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26592. readonly isBlocked: boolean;
  26593. /**
  26594. * Determine if the current mesh is ready to be rendered
  26595. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26596. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26597. * @returns true if all associated assets are ready (material, textures, shaders)
  26598. */
  26599. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26600. /**
  26601. * 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.
  26602. */
  26603. readonly areNormalsFrozen: boolean;
  26604. /**
  26605. * 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.
  26606. * @returns the current mesh
  26607. */
  26608. freezeNormals(): Mesh;
  26609. /**
  26610. * 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
  26611. * @returns the current mesh
  26612. */
  26613. unfreezeNormals(): Mesh;
  26614. /**
  26615. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26616. */
  26617. overridenInstanceCount: number;
  26618. /** @hidden */
  26619. _preActivate(): Mesh;
  26620. /** @hidden */
  26621. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26622. /** @hidden */
  26623. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26624. /**
  26625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26626. * This means the mesh underlying bounding box and sphere are recomputed.
  26627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26628. * @returns the current mesh
  26629. */
  26630. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26631. /** @hidden */
  26632. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26633. /**
  26634. * This function will subdivide the mesh into multiple submeshes
  26635. * @param count defines the expected number of submeshes
  26636. */
  26637. subdivide(count: number): void;
  26638. /**
  26639. * Copy a FloatArray into a specific associated vertex buffer
  26640. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26641. * - BABYLON.VertexBuffer.PositionKind
  26642. * - BABYLON.VertexBuffer.UVKind
  26643. * - BABYLON.VertexBuffer.UV2Kind
  26644. * - BABYLON.VertexBuffer.UV3Kind
  26645. * - BABYLON.VertexBuffer.UV4Kind
  26646. * - BABYLON.VertexBuffer.UV5Kind
  26647. * - BABYLON.VertexBuffer.UV6Kind
  26648. * - BABYLON.VertexBuffer.ColorKind
  26649. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26650. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26651. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26652. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26653. * @param data defines the data source
  26654. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26655. * @param stride defines the data stride size (can be null)
  26656. * @returns the current mesh
  26657. */
  26658. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26659. /**
  26660. * Flags an associated vertex buffer as updatable
  26661. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26662. * - BABYLON.VertexBuffer.PositionKind
  26663. * - BABYLON.VertexBuffer.UVKind
  26664. * - BABYLON.VertexBuffer.UV2Kind
  26665. * - BABYLON.VertexBuffer.UV3Kind
  26666. * - BABYLON.VertexBuffer.UV4Kind
  26667. * - BABYLON.VertexBuffer.UV5Kind
  26668. * - BABYLON.VertexBuffer.UV6Kind
  26669. * - BABYLON.VertexBuffer.ColorKind
  26670. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26671. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26672. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26673. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26674. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26675. */
  26676. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26677. /**
  26678. * Sets the mesh global Vertex Buffer
  26679. * @param buffer defines the buffer to use
  26680. * @returns the current mesh
  26681. */
  26682. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26683. /**
  26684. * Update a specific associated vertex buffer
  26685. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26686. * - BABYLON.VertexBuffer.PositionKind
  26687. * - BABYLON.VertexBuffer.UVKind
  26688. * - BABYLON.VertexBuffer.UV2Kind
  26689. * - BABYLON.VertexBuffer.UV3Kind
  26690. * - BABYLON.VertexBuffer.UV4Kind
  26691. * - BABYLON.VertexBuffer.UV5Kind
  26692. * - BABYLON.VertexBuffer.UV6Kind
  26693. * - BABYLON.VertexBuffer.ColorKind
  26694. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26695. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26696. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26697. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26698. * @param data defines the data source
  26699. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26700. * @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)
  26701. * @returns the current mesh
  26702. */
  26703. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26704. /**
  26705. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26706. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26707. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26708. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26709. * @returns the current mesh
  26710. */
  26711. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26712. /**
  26713. * Creates a un-shared specific occurence of the geometry for the mesh.
  26714. * @returns the current mesh
  26715. */
  26716. makeGeometryUnique(): Mesh;
  26717. /**
  26718. * Set the index buffer of this mesh
  26719. * @param indices defines the source data
  26720. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26721. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26722. * @returns the current mesh
  26723. */
  26724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26725. /**
  26726. * Update the current index buffer
  26727. * @param indices defines the source data
  26728. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26729. * @returns the current mesh
  26730. */
  26731. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26732. /**
  26733. * Invert the geometry to move from a right handed system to a left handed one.
  26734. * @returns the current mesh
  26735. */
  26736. toLeftHanded(): Mesh;
  26737. /** @hidden */
  26738. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26739. /** @hidden */
  26740. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26741. /**
  26742. * Registers for this mesh a javascript function called just before the rendering process
  26743. * @param func defines the function to call before rendering this mesh
  26744. * @returns the current mesh
  26745. */
  26746. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26747. /**
  26748. * Disposes a previously registered javascript function called before the rendering
  26749. * @param func defines the function to remove
  26750. * @returns the current mesh
  26751. */
  26752. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26753. /**
  26754. * Registers for this mesh a javascript function called just after the rendering is complete
  26755. * @param func defines the function to call after rendering this mesh
  26756. * @returns the current mesh
  26757. */
  26758. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26759. /**
  26760. * Disposes a previously registered javascript function called after the rendering.
  26761. * @param func defines the function to remove
  26762. * @returns the current mesh
  26763. */
  26764. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26765. /** @hidden */
  26766. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26767. /** @hidden */
  26768. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26769. /** @hidden */
  26770. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26771. /**
  26772. * 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
  26773. * @param subMesh defines the subMesh to render
  26774. * @param enableAlphaMode defines if alpha mode can be changed
  26775. * @returns the current mesh
  26776. */
  26777. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26778. private _onBeforeDraw;
  26779. /**
  26780. * Renormalize the mesh and patch it up if there are no weights
  26781. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26782. * However in the case of zero weights then we set just a single influence to 1.
  26783. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26784. */
  26785. cleanMatrixWeights(): void;
  26786. private normalizeSkinFourWeights;
  26787. private normalizeSkinWeightsAndExtra;
  26788. /**
  26789. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26790. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26791. * the user know there was an issue with importing the mesh
  26792. * @returns a validation object with skinned, valid and report string
  26793. */
  26794. validateSkinning(): {
  26795. skinned: boolean;
  26796. valid: boolean;
  26797. report: string;
  26798. };
  26799. /** @hidden */
  26800. _checkDelayState(): Mesh;
  26801. private _queueLoad;
  26802. /**
  26803. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26804. * A mesh is in the frustum if its bounding box intersects the frustum
  26805. * @param frustumPlanes defines the frustum to test
  26806. * @returns true if the mesh is in the frustum planes
  26807. */
  26808. isInFrustum(frustumPlanes: Plane[]): boolean;
  26809. /**
  26810. * Sets the mesh material by the material or multiMaterial `id` property
  26811. * @param id is a string identifying the material or the multiMaterial
  26812. * @returns the current mesh
  26813. */
  26814. setMaterialByID(id: string): Mesh;
  26815. /**
  26816. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26817. * @returns an array of IAnimatable
  26818. */
  26819. getAnimatables(): IAnimatable[];
  26820. /**
  26821. * Modifies the mesh geometry according to the passed transformation matrix.
  26822. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26823. * The mesh normals are modified using the same transformation.
  26824. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26825. * @param transform defines the transform matrix to use
  26826. * @see http://doc.babylonjs.com/resources/baking_transformations
  26827. * @returns the current mesh
  26828. */
  26829. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26830. /**
  26831. * Modifies the mesh geometry according to its own current World Matrix.
  26832. * The mesh World Matrix is then reset.
  26833. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26834. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26835. * @see http://doc.babylonjs.com/resources/baking_transformations
  26836. * @returns the current mesh
  26837. */
  26838. bakeCurrentTransformIntoVertices(): Mesh;
  26839. /** @hidden */
  26840. readonly _positions: Nullable<Vector3[]>;
  26841. /** @hidden */
  26842. _resetPointsArrayCache(): Mesh;
  26843. /** @hidden */
  26844. _generatePointsArray(): boolean;
  26845. /**
  26846. * Returns a new Mesh object generated from the current mesh properties.
  26847. * This method must not get confused with createInstance()
  26848. * @param name is a string, the name given to the new mesh
  26849. * @param newParent can be any Node object (default `null`)
  26850. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26851. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26852. * @returns a new mesh
  26853. */
  26854. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26855. /**
  26856. * Releases resources associated with this mesh.
  26857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26859. */
  26860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26861. /**
  26862. * Modifies the mesh geometry according to a displacement map.
  26863. * 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.
  26864. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26865. * @param url is a string, the URL from the image file is to be downloaded.
  26866. * @param minHeight is the lower limit of the displacement.
  26867. * @param maxHeight is the upper limit of the displacement.
  26868. * @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.
  26869. * @param uvOffset is an optional vector2 used to offset UV.
  26870. * @param uvScale is an optional vector2 used to scale UV.
  26871. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26872. * @returns the Mesh.
  26873. */
  26874. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26875. /**
  26876. * Modifies the mesh geometry according to a displacementMap buffer.
  26877. * 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.
  26878. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26879. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26880. * @param heightMapWidth is the width of the buffer image.
  26881. * @param heightMapHeight is the height of the buffer image.
  26882. * @param minHeight is the lower limit of the displacement.
  26883. * @param maxHeight is the upper limit of the displacement.
  26884. * @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.
  26885. * @param uvOffset is an optional vector2 used to offset UV.
  26886. * @param uvScale is an optional vector2 used to scale UV.
  26887. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26888. * @returns the Mesh.
  26889. */
  26890. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26891. /**
  26892. * Modify the mesh to get a flat shading rendering.
  26893. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26894. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26895. * @returns current mesh
  26896. */
  26897. convertToFlatShadedMesh(): Mesh;
  26898. /**
  26899. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26900. * In other words, more vertices, no more indices and a single bigger VBO.
  26901. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26902. * @returns current mesh
  26903. */
  26904. convertToUnIndexedMesh(): Mesh;
  26905. /**
  26906. * Inverses facet orientations.
  26907. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26908. * @param flipNormals will also inverts the normals
  26909. * @returns current mesh
  26910. */
  26911. flipFaces(flipNormals?: boolean): Mesh;
  26912. /**
  26913. * Creates a new InstancedMesh object from the mesh model.
  26914. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26915. * @param name defines the name of the new instance
  26916. * @returns a new InstancedMesh
  26917. */
  26918. createInstance(name: string): InstancedMesh;
  26919. /**
  26920. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26921. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26922. * @returns the current mesh
  26923. */
  26924. synchronizeInstances(): Mesh;
  26925. /**
  26926. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26927. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26928. * This should be used together with the simplification to avoid disappearing triangles.
  26929. * @param successCallback an optional success callback to be called after the optimization finished.
  26930. * @returns the current mesh
  26931. */
  26932. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26933. /**
  26934. * Serialize current mesh
  26935. * @param serializationObject defines the object which will receive the serialization data
  26936. */
  26937. serialize(serializationObject: any): void;
  26938. /** @hidden */
  26939. _syncGeometryWithMorphTargetManager(): void;
  26940. /**
  26941. * Returns a new Mesh object parsed from the source provided.
  26942. * @param parsedMesh is the source
  26943. * @param scene defines the hosting scene
  26944. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26945. * @returns a new Mesh
  26946. */
  26947. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26948. /**
  26949. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26950. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26951. * @param name defines the name of the mesh to create
  26952. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26953. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26954. * @param closePath creates a seam between the first and the last points of each path of the path array
  26955. * @param offset is taken in account only if the `pathArray` is containing a single path
  26956. * @param scene defines the hosting scene
  26957. * @param updatable defines if the mesh must be flagged as updatable
  26958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26959. * @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)
  26960. * @returns a new Mesh
  26961. */
  26962. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26963. /**
  26964. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26965. * @param name defines the name of the mesh to create
  26966. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26967. * @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
  26968. * @param scene defines the hosting scene
  26969. * @param updatable defines if the mesh must be flagged as updatable
  26970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26971. * @returns a new Mesh
  26972. */
  26973. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26974. /**
  26975. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26976. * @param name defines the name of the mesh to create
  26977. * @param size sets the size (float) of each box side (default 1)
  26978. * @param scene defines the hosting scene
  26979. * @param updatable defines if the mesh must be flagged as updatable
  26980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26981. * @returns a new Mesh
  26982. */
  26983. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26984. /**
  26985. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26986. * @param name defines the name of the mesh to create
  26987. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26988. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26989. * @param scene defines the hosting scene
  26990. * @param updatable defines if the mesh must be flagged as updatable
  26991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26992. * @returns a new Mesh
  26993. */
  26994. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26995. /**
  26996. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26997. * @param name defines the name of the mesh to create
  26998. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26999. * @param diameterTop set the top cap diameter (floats, default 1)
  27000. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27001. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27002. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27003. * @param scene defines the hosting scene
  27004. * @param updatable defines if the mesh must be flagged as updatable
  27005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27006. * @returns a new Mesh
  27007. */
  27008. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27009. /**
  27010. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27011. * @param name defines the name of the mesh to create
  27012. * @param diameter sets the diameter size (float) of the torus (default 1)
  27013. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27014. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27015. * @param scene defines the hosting scene
  27016. * @param updatable defines if the mesh must be flagged as updatable
  27017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27018. * @returns a new Mesh
  27019. */
  27020. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27021. /**
  27022. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27023. * @param name defines the name of the mesh to create
  27024. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27025. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27026. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27027. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27028. * @param p the number of windings on X axis (positive integers, default 2)
  27029. * @param q the number of windings on Y axis (positive integers, default 3)
  27030. * @param scene defines the hosting scene
  27031. * @param updatable defines if the mesh must be flagged as updatable
  27032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27033. * @returns a new Mesh
  27034. */
  27035. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27036. /**
  27037. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27038. * @param name defines the name of the mesh to create
  27039. * @param points is an array successive Vector3
  27040. * @param scene defines the hosting scene
  27041. * @param updatable defines if the mesh must be flagged as updatable
  27042. * @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).
  27043. * @returns a new Mesh
  27044. */
  27045. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27046. /**
  27047. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27048. * @param name defines the name of the mesh to create
  27049. * @param points is an array successive Vector3
  27050. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27051. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27052. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27053. * @param scene defines the hosting scene
  27054. * @param updatable defines if the mesh must be flagged as updatable
  27055. * @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)
  27056. * @returns a new Mesh
  27057. */
  27058. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27059. /**
  27060. * Creates a polygon mesh.
  27061. * Please consider using the same method from the MeshBuilder class instead.
  27062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27063. * 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.
  27064. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27065. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27066. * Remember you can only change the shape positions, not their number when updating a polygon.
  27067. */
  27068. /**
  27069. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27070. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27071. * @param name defines the name of the mesh to create
  27072. * @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
  27073. * @param scene defines the hosting scene
  27074. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27075. * @param updatable defines if the mesh must be flagged as updatable
  27076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27077. * @returns a new Mesh
  27078. */
  27079. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27080. /**
  27081. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27082. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27083. * @param name defines the name of the mesh to create
  27084. * @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
  27085. * @param depth defines the height of extrusion
  27086. * @param scene defines the hosting scene
  27087. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27088. * @param updatable defines if the mesh must be flagged as updatable
  27089. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27090. * @returns a new Mesh
  27091. */
  27092. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27093. /**
  27094. * Creates an extruded shape mesh.
  27095. * 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
  27096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27097. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27098. * @param name defines the name of the mesh to create
  27099. * @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
  27100. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27101. * @param scale is the value to scale the shape
  27102. * @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
  27103. * @param 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
  27104. * @param scene defines the hosting scene
  27105. * @param updatable defines if the mesh must be flagged as updatable
  27106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27107. * @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)
  27108. * @returns a new Mesh
  27109. */
  27110. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27111. /**
  27112. * Creates an custom extruded shape mesh.
  27113. * The custom extrusion is a parametric shape.
  27114. * It has no predefined shape. Its final shape will depend on the input parameters.
  27115. * Please consider using the same method from the MeshBuilder class instead
  27116. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27117. * @param name defines the name of the mesh to create
  27118. * @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
  27119. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27120. * @param scaleFunction is a custom Javascript function called on each path point
  27121. * @param rotationFunction is a custom Javascript function called on each path point
  27122. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27123. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27124. * @param 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
  27125. * @param scene defines the hosting scene
  27126. * @param updatable defines if the mesh must be flagged as updatable
  27127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27128. * @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)
  27129. * @returns a new Mesh
  27130. */
  27131. 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;
  27132. /**
  27133. * Creates lathe mesh.
  27134. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27135. * Please consider using the same method from the MeshBuilder class instead
  27136. * @param name defines the name of the mesh to create
  27137. * @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
  27138. * @param radius is the radius value of the lathe
  27139. * @param tessellation is the side number of the lathe.
  27140. * @param scene defines the hosting scene
  27141. * @param updatable defines if the mesh must be flagged as updatable
  27142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27143. * @returns a new Mesh
  27144. */
  27145. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27146. /**
  27147. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27148. * @param name defines the name of the mesh to create
  27149. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27150. * @param scene defines the hosting scene
  27151. * @param updatable defines if the mesh must be flagged as updatable
  27152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27153. * @returns a new Mesh
  27154. */
  27155. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27156. /**
  27157. * Creates a ground mesh.
  27158. * Please consider using the same method from the MeshBuilder class instead
  27159. * @param name defines the name of the mesh to create
  27160. * @param width set the width of the ground
  27161. * @param height set the height of the ground
  27162. * @param subdivisions sets the number of subdivisions per side
  27163. * @param scene defines the hosting scene
  27164. * @param updatable defines if the mesh must be flagged as updatable
  27165. * @returns a new Mesh
  27166. */
  27167. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27168. /**
  27169. * Creates a tiled ground mesh.
  27170. * Please consider using the same method from the MeshBuilder class instead
  27171. * @param name defines the name of the mesh to create
  27172. * @param xmin set the ground minimum X coordinate
  27173. * @param zmin set the ground minimum Y coordinate
  27174. * @param xmax set the ground maximum X coordinate
  27175. * @param zmax set the ground maximum Z coordinate
  27176. * @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
  27177. * @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
  27178. * @param scene defines the hosting scene
  27179. * @param updatable defines if the mesh must be flagged as updatable
  27180. * @returns a new Mesh
  27181. */
  27182. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27183. w: number;
  27184. h: number;
  27185. }, precision: {
  27186. w: number;
  27187. h: number;
  27188. }, scene: Scene, updatable?: boolean): Mesh;
  27189. /**
  27190. * Creates a ground mesh from a height map.
  27191. * Please consider using the same method from the MeshBuilder class instead
  27192. * @see http://doc.babylonjs.com/babylon101/height_map
  27193. * @param name defines the name of the mesh to create
  27194. * @param url sets the URL of the height map image resource
  27195. * @param width set the ground width size
  27196. * @param height set the ground height size
  27197. * @param subdivisions sets the number of subdivision per side
  27198. * @param minHeight is the minimum altitude on the ground
  27199. * @param maxHeight is the maximum altitude on the ground
  27200. * @param scene defines the hosting scene
  27201. * @param updatable defines if the mesh must be flagged as updatable
  27202. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27203. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27204. * @returns a new Mesh
  27205. */
  27206. 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;
  27207. /**
  27208. * Creates a tube mesh.
  27209. * The tube is a parametric shape.
  27210. * It has no predefined shape. Its final shape will depend on the input parameters.
  27211. * Please consider using the same method from the MeshBuilder class instead
  27212. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27213. * @param name defines the name of the mesh to create
  27214. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27215. * @param radius sets the tube radius size
  27216. * @param tessellation is the number of sides on the tubular surface
  27217. * @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
  27218. * @param 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
  27219. * @param scene defines the hosting scene
  27220. * @param updatable defines if the mesh must be flagged as updatable
  27221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27222. * @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)
  27223. * @returns a new Mesh
  27224. */
  27225. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27226. (i: number, distance: number): number;
  27227. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27228. /**
  27229. * Creates a polyhedron mesh.
  27230. * Please consider using the same method from the MeshBuilder class instead.
  27231. * * 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
  27232. * * The parameter `size` (positive float, default 1) sets the polygon size
  27233. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27234. * * 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`
  27235. * * 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
  27236. * * 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)`)
  27237. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27238. * * 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
  27239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27240. * * 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
  27241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27242. * @param name defines the name of the mesh to create
  27243. * @param options defines the options used to create the mesh
  27244. * @param scene defines the hosting scene
  27245. * @returns a new Mesh
  27246. */
  27247. static CreatePolyhedron(name: string, options: {
  27248. type?: number;
  27249. size?: number;
  27250. sizeX?: number;
  27251. sizeY?: number;
  27252. sizeZ?: number;
  27253. custom?: any;
  27254. faceUV?: Vector4[];
  27255. faceColors?: Color4[];
  27256. updatable?: boolean;
  27257. sideOrientation?: number;
  27258. }, scene: Scene): Mesh;
  27259. /**
  27260. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27261. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27262. * * 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`)
  27263. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27264. * * 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
  27265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27266. * * 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
  27267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27268. * @param name defines the name of the mesh
  27269. * @param options defines the options used to create the mesh
  27270. * @param scene defines the hosting scene
  27271. * @returns a new Mesh
  27272. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27273. */
  27274. static CreateIcoSphere(name: string, options: {
  27275. radius?: number;
  27276. flat?: boolean;
  27277. subdivisions?: number;
  27278. sideOrientation?: number;
  27279. updatable?: boolean;
  27280. }, scene: Scene): Mesh;
  27281. /**
  27282. * Creates a decal mesh.
  27283. * Please consider using the same method from the MeshBuilder class instead.
  27284. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27285. * @param name defines the name of the mesh
  27286. * @param sourceMesh defines the mesh receiving the decal
  27287. * @param position sets the position of the decal in world coordinates
  27288. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27289. * @param size sets the decal scaling
  27290. * @param angle sets the angle to rotate the decal
  27291. * @returns a new Mesh
  27292. */
  27293. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27294. /**
  27295. * Prepare internal position array for software CPU skinning
  27296. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27297. */
  27298. setPositionsForCPUSkinning(): Float32Array;
  27299. /**
  27300. * Prepare internal normal array for software CPU skinning
  27301. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27302. */
  27303. setNormalsForCPUSkinning(): Float32Array;
  27304. /**
  27305. * Updates the vertex buffer by applying transformation from the bones
  27306. * @param skeleton defines the skeleton to apply to current mesh
  27307. * @returns the current mesh
  27308. */
  27309. applySkeleton(skeleton: Skeleton): Mesh;
  27310. /**
  27311. * 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
  27312. * @param meshes defines the list of meshes to scan
  27313. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27314. */
  27315. static MinMax(meshes: AbstractMesh[]): {
  27316. min: Vector3;
  27317. max: Vector3;
  27318. };
  27319. /**
  27320. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27321. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27322. * @returns a vector3
  27323. */
  27324. static Center(meshesOrMinMaxVector: {
  27325. min: Vector3;
  27326. max: Vector3;
  27327. } | AbstractMesh[]): Vector3;
  27328. /**
  27329. * Merge the array of meshes into a single mesh for performance reasons.
  27330. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27331. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27332. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27333. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27334. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27335. * @returns a new mesh
  27336. */
  27337. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27338. /** @hidden */
  27339. addInstance(instance: InstancedMesh): void;
  27340. /** @hidden */
  27341. removeInstance(instance: InstancedMesh): void;
  27342. }
  27343. }
  27344. declare module BABYLON {
  27345. /**
  27346. * Define an interface for all classes that will get and set the data on vertices
  27347. */
  27348. interface IGetSetVerticesData {
  27349. /**
  27350. * Gets a boolean indicating if specific vertex data is present
  27351. * @param kind defines the vertex data kind to use
  27352. * @returns true is data kind is present
  27353. */
  27354. isVerticesDataPresent(kind: string): boolean;
  27355. /**
  27356. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27357. * @param kind defines the data kind (Position, normal, etc...)
  27358. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27359. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27360. * @returns a float array containing vertex data
  27361. */
  27362. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27363. /**
  27364. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27365. * @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.
  27366. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27367. * @returns the indices array or an empty array if the mesh has no geometry
  27368. */
  27369. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27370. /**
  27371. * Set specific vertex data
  27372. * @param kind defines the data kind (Position, normal, etc...)
  27373. * @param data defines the vertex data to use
  27374. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27375. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27376. */
  27377. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27378. /**
  27379. * Update a specific associated vertex buffer
  27380. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27381. * - BABYLON.VertexBuffer.PositionKind
  27382. * - BABYLON.VertexBuffer.UVKind
  27383. * - BABYLON.VertexBuffer.UV2Kind
  27384. * - BABYLON.VertexBuffer.UV3Kind
  27385. * - BABYLON.VertexBuffer.UV4Kind
  27386. * - BABYLON.VertexBuffer.UV5Kind
  27387. * - BABYLON.VertexBuffer.UV6Kind
  27388. * - BABYLON.VertexBuffer.ColorKind
  27389. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27390. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27391. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27392. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27393. * @param data defines the data source
  27394. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27395. * @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)
  27396. */
  27397. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27398. /**
  27399. * Creates a new index buffer
  27400. * @param indices defines the indices to store in the index buffer
  27401. * @param totalVertices defines the total number of vertices (could be null)
  27402. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27403. */
  27404. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27405. }
  27406. /**
  27407. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27408. */
  27409. class VertexData {
  27410. /**
  27411. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27412. */
  27413. positions: Nullable<FloatArray>;
  27414. /**
  27415. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27416. */
  27417. normals: Nullable<FloatArray>;
  27418. /**
  27419. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27420. */
  27421. tangents: Nullable<FloatArray>;
  27422. /**
  27423. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27424. */
  27425. uvs: Nullable<FloatArray>;
  27426. /**
  27427. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27428. */
  27429. uvs2: Nullable<FloatArray>;
  27430. /**
  27431. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27432. */
  27433. uvs3: Nullable<FloatArray>;
  27434. /**
  27435. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27436. */
  27437. uvs4: Nullable<FloatArray>;
  27438. /**
  27439. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27440. */
  27441. uvs5: Nullable<FloatArray>;
  27442. /**
  27443. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27444. */
  27445. uvs6: Nullable<FloatArray>;
  27446. /**
  27447. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27448. */
  27449. colors: Nullable<FloatArray>;
  27450. /**
  27451. * 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).
  27452. */
  27453. matricesIndices: Nullable<FloatArray>;
  27454. /**
  27455. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27456. */
  27457. matricesWeights: Nullable<FloatArray>;
  27458. /**
  27459. * An array extending the number of possible indices
  27460. */
  27461. matricesIndicesExtra: Nullable<FloatArray>;
  27462. /**
  27463. * An array extending the number of possible weights when the number of indices is extended
  27464. */
  27465. matricesWeightsExtra: Nullable<FloatArray>;
  27466. /**
  27467. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27468. */
  27469. indices: Nullable<IndicesArray>;
  27470. /**
  27471. * Uses the passed data array to set the set the values for the specified kind of data
  27472. * @param data a linear array of floating numbers
  27473. * @param kind the type of data that is being set, eg positions, colors etc
  27474. */
  27475. set(data: FloatArray, kind: string): void;
  27476. /**
  27477. * Associates the vertexData to the passed Mesh.
  27478. * Sets it as updatable or not (default `false`)
  27479. * @param mesh the mesh the vertexData is applied to
  27480. * @param updatable when used and having the value true allows new data to update the vertexData
  27481. * @returns the VertexData
  27482. */
  27483. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27484. /**
  27485. * Associates the vertexData to the passed Geometry.
  27486. * Sets it as updatable or not (default `false`)
  27487. * @param geometry the geometry the vertexData is applied to
  27488. * @param updatable when used and having the value true allows new data to update the vertexData
  27489. * @returns VertexData
  27490. */
  27491. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27492. /**
  27493. * Updates the associated mesh
  27494. * @param mesh the mesh to be updated
  27495. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27496. * @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
  27497. * @returns VertexData
  27498. */
  27499. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27500. /**
  27501. * Updates the associated geometry
  27502. * @param geometry the geometry to be updated
  27503. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27504. * @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
  27505. * @returns VertexData.
  27506. */
  27507. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27508. private _applyTo;
  27509. private _update;
  27510. /**
  27511. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27512. * @param matrix the transforming matrix
  27513. * @returns the VertexData
  27514. */
  27515. transform(matrix: Matrix): VertexData;
  27516. /**
  27517. * Merges the passed VertexData into the current one
  27518. * @param other the VertexData to be merged into the current one
  27519. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27520. * @returns the modified VertexData
  27521. */
  27522. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27523. private _mergeElement;
  27524. private _validate;
  27525. /**
  27526. * Serializes the VertexData
  27527. * @returns a serialized object
  27528. */
  27529. serialize(): any;
  27530. /**
  27531. * Extracts the vertexData from a mesh
  27532. * @param mesh the mesh from which to extract the VertexData
  27533. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27534. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27535. * @returns the object VertexData associated to the passed mesh
  27536. */
  27537. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27538. /**
  27539. * Extracts the vertexData from the geometry
  27540. * @param geometry the geometry from which to extract the VertexData
  27541. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27542. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27543. * @returns the object VertexData associated to the passed mesh
  27544. */
  27545. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27546. private static _ExtractFrom;
  27547. /**
  27548. * Creates the VertexData for a Ribbon
  27549. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27550. * * pathArray array of paths, each of which an array of successive Vector3
  27551. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27552. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27553. * * 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
  27554. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27555. * * 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)
  27556. * * 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)
  27557. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27558. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27559. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27560. * @returns the VertexData of the ribbon
  27561. */
  27562. static CreateRibbon(options: {
  27563. pathArray: Vector3[][];
  27564. closeArray?: boolean;
  27565. closePath?: boolean;
  27566. offset?: number;
  27567. sideOrientation?: number;
  27568. frontUVs?: Vector4;
  27569. backUVs?: Vector4;
  27570. invertUV?: boolean;
  27571. uvs?: Vector2[];
  27572. colors?: Color4[];
  27573. }): VertexData;
  27574. /**
  27575. * Creates the VertexData for a box
  27576. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27577. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27578. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27579. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27580. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27581. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27582. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27583. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27584. * * 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)
  27585. * * 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)
  27586. * @returns the VertexData of the box
  27587. */
  27588. static CreateBox(options: {
  27589. size?: number;
  27590. width?: number;
  27591. height?: number;
  27592. depth?: number;
  27593. faceUV?: Vector4[];
  27594. faceColors?: Color4[];
  27595. sideOrientation?: number;
  27596. frontUVs?: Vector4;
  27597. backUVs?: Vector4;
  27598. }): VertexData;
  27599. /**
  27600. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27601. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27602. * * segments sets the number of horizontal strips optional, default 32
  27603. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27604. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27605. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27606. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27607. * * 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
  27608. * * 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
  27609. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27610. * * 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)
  27611. * * 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)
  27612. * @returns the VertexData of the ellipsoid
  27613. */
  27614. static CreateSphere(options: {
  27615. segments?: number;
  27616. diameter?: number;
  27617. diameterX?: number;
  27618. diameterY?: number;
  27619. diameterZ?: number;
  27620. arc?: number;
  27621. slice?: number;
  27622. sideOrientation?: number;
  27623. frontUVs?: Vector4;
  27624. backUVs?: Vector4;
  27625. }): VertexData;
  27626. /**
  27627. * Creates the VertexData for a cylinder, cone or prism
  27628. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27629. * * height sets the height (y direction) of the cylinder, optional, default 2
  27630. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27631. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27632. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27633. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27634. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27635. * * 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
  27636. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27637. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27638. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27639. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27640. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27641. * * 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)
  27642. * * 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)
  27643. * @returns the VertexData of the cylinder, cone or prism
  27644. */
  27645. static CreateCylinder(options: {
  27646. height?: number;
  27647. diameterTop?: number;
  27648. diameterBottom?: number;
  27649. diameter?: number;
  27650. tessellation?: number;
  27651. subdivisions?: number;
  27652. arc?: number;
  27653. faceColors?: Color4[];
  27654. faceUV?: Vector4[];
  27655. hasRings?: boolean;
  27656. enclose?: boolean;
  27657. sideOrientation?: number;
  27658. frontUVs?: Vector4;
  27659. backUVs?: Vector4;
  27660. }): VertexData;
  27661. /**
  27662. * Creates the VertexData for a torus
  27663. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27664. * * diameter the diameter of the torus, optional default 1
  27665. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27666. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27667. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27668. * * 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)
  27669. * * 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)
  27670. * @returns the VertexData of the torus
  27671. */
  27672. static CreateTorus(options: {
  27673. diameter?: number;
  27674. thickness?: number;
  27675. tessellation?: number;
  27676. sideOrientation?: number;
  27677. frontUVs?: Vector4;
  27678. backUVs?: Vector4;
  27679. }): VertexData;
  27680. /**
  27681. * Creates the VertexData of the LineSystem
  27682. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27683. * - lines an array of lines, each line being an array of successive Vector3
  27684. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27685. * @returns the VertexData of the LineSystem
  27686. */
  27687. static CreateLineSystem(options: {
  27688. lines: Vector3[][];
  27689. colors?: Nullable<Color4[][]>;
  27690. }): VertexData;
  27691. /**
  27692. * Create the VertexData for a DashedLines
  27693. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27694. * - points an array successive Vector3
  27695. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27696. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27697. * - dashNb the intended total number of dashes, optional, default 200
  27698. * @returns the VertexData for the DashedLines
  27699. */
  27700. static CreateDashedLines(options: {
  27701. points: Vector3[];
  27702. dashSize?: number;
  27703. gapSize?: number;
  27704. dashNb?: number;
  27705. }): VertexData;
  27706. /**
  27707. * Creates the VertexData for a Ground
  27708. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27709. * - width the width (x direction) of the ground, optional, default 1
  27710. * - height the height (z direction) of the ground, optional, default 1
  27711. * - subdivisions the number of subdivisions per side, optional, default 1
  27712. * @returns the VertexData of the Ground
  27713. */
  27714. static CreateGround(options: {
  27715. width?: number;
  27716. height?: number;
  27717. subdivisions?: number;
  27718. subdivisionsX?: number;
  27719. subdivisionsY?: number;
  27720. }): VertexData;
  27721. /**
  27722. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27723. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27724. * * xmin the ground minimum X coordinate, optional, default -1
  27725. * * zmin the ground minimum Z coordinate, optional, default -1
  27726. * * xmax the ground maximum X coordinate, optional, default 1
  27727. * * zmax the ground maximum Z coordinate, optional, default 1
  27728. * * 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}
  27729. * * 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}
  27730. * @returns the VertexData of the TiledGround
  27731. */
  27732. static CreateTiledGround(options: {
  27733. xmin: number;
  27734. zmin: number;
  27735. xmax: number;
  27736. zmax: number;
  27737. subdivisions?: {
  27738. w: number;
  27739. h: number;
  27740. };
  27741. precision?: {
  27742. w: number;
  27743. h: number;
  27744. };
  27745. }): VertexData;
  27746. /**
  27747. * Creates the VertexData of the Ground designed from a heightmap
  27748. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27749. * * width the width (x direction) of the ground
  27750. * * height the height (z direction) of the ground
  27751. * * subdivisions the number of subdivisions per side
  27752. * * minHeight the minimum altitude on the ground, optional, default 0
  27753. * * maxHeight the maximum altitude on the ground, optional default 1
  27754. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27755. * * buffer the array holding the image color data
  27756. * * bufferWidth the width of image
  27757. * * bufferHeight the height of image
  27758. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27759. * @returns the VertexData of the Ground designed from a heightmap
  27760. */
  27761. static CreateGroundFromHeightMap(options: {
  27762. width: number;
  27763. height: number;
  27764. subdivisions: number;
  27765. minHeight: number;
  27766. maxHeight: number;
  27767. colorFilter: Color3;
  27768. buffer: Uint8Array;
  27769. bufferWidth: number;
  27770. bufferHeight: number;
  27771. alphaFilter: number;
  27772. }): VertexData;
  27773. /**
  27774. * Creates the VertexData for a Plane
  27775. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27776. * * size sets the width and height of the plane to the value of size, optional default 1
  27777. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27778. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27779. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27780. * * 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)
  27781. * * 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)
  27782. * @returns the VertexData of the box
  27783. */
  27784. static CreatePlane(options: {
  27785. size?: number;
  27786. width?: number;
  27787. height?: number;
  27788. sideOrientation?: number;
  27789. frontUVs?: Vector4;
  27790. backUVs?: Vector4;
  27791. }): VertexData;
  27792. /**
  27793. * Creates the VertexData of the Disc or regular Polygon
  27794. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27795. * * radius the radius of the disc, optional default 0.5
  27796. * * tessellation the number of polygon sides, optional, default 64
  27797. * * 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
  27798. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27799. * * 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)
  27800. * * 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)
  27801. * @returns the VertexData of the box
  27802. */
  27803. static CreateDisc(options: {
  27804. radius?: number;
  27805. tessellation?: number;
  27806. arc?: number;
  27807. sideOrientation?: number;
  27808. frontUVs?: Vector4;
  27809. backUVs?: Vector4;
  27810. }): VertexData;
  27811. /**
  27812. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27813. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27814. * @param polygon a mesh built from polygonTriangulation.build()
  27815. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27816. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27817. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27818. * @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)
  27819. * @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)
  27820. * @returns the VertexData of the Polygon
  27821. */
  27822. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27823. /**
  27824. * Creates the VertexData of the IcoSphere
  27825. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27826. * * radius the radius of the IcoSphere, optional default 1
  27827. * * radiusX allows stretching in the x direction, optional, default radius
  27828. * * radiusY allows stretching in the y direction, optional, default radius
  27829. * * radiusZ allows stretching in the z direction, optional, default radius
  27830. * * flat when true creates a flat shaded mesh, optional, default true
  27831. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27832. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27833. * * 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)
  27834. * * 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)
  27835. * @returns the VertexData of the IcoSphere
  27836. */
  27837. static CreateIcoSphere(options: {
  27838. radius?: number;
  27839. radiusX?: number;
  27840. radiusY?: number;
  27841. radiusZ?: number;
  27842. flat?: boolean;
  27843. subdivisions?: number;
  27844. sideOrientation?: number;
  27845. frontUVs?: Vector4;
  27846. backUVs?: Vector4;
  27847. }): VertexData;
  27848. /**
  27849. * Creates the VertexData for a Polyhedron
  27850. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27851. * * type provided types are:
  27852. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27853. * * 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)
  27854. * * size the size of the IcoSphere, optional default 1
  27855. * * sizeX allows stretching in the x direction, optional, default size
  27856. * * sizeY allows stretching in the y direction, optional, default size
  27857. * * sizeZ allows stretching in the z direction, optional, default size
  27858. * * 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
  27859. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27860. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27861. * * flat when true creates a flat shaded mesh, optional, default true
  27862. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27863. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27864. * * 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)
  27865. * * 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)
  27866. * @returns the VertexData of the Polyhedron
  27867. */
  27868. static CreatePolyhedron(options: {
  27869. type?: number;
  27870. size?: number;
  27871. sizeX?: number;
  27872. sizeY?: number;
  27873. sizeZ?: number;
  27874. custom?: any;
  27875. faceUV?: Vector4[];
  27876. faceColors?: Color4[];
  27877. flat?: boolean;
  27878. sideOrientation?: number;
  27879. frontUVs?: Vector4;
  27880. backUVs?: Vector4;
  27881. }): VertexData;
  27882. /**
  27883. * Creates the VertexData for a TorusKnot
  27884. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27885. * * radius the radius of the torus knot, optional, default 2
  27886. * * tube the thickness of the tube, optional, default 0.5
  27887. * * radialSegments the number of sides on each tube segments, optional, default 32
  27888. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27889. * * p the number of windings around the z axis, optional, default 2
  27890. * * q the number of windings around the x axis, optional, default 3
  27891. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27892. * * 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)
  27893. * * 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)
  27894. * @returns the VertexData of the Torus Knot
  27895. */
  27896. static CreateTorusKnot(options: {
  27897. radius?: number;
  27898. tube?: number;
  27899. radialSegments?: number;
  27900. tubularSegments?: number;
  27901. p?: number;
  27902. q?: number;
  27903. sideOrientation?: number;
  27904. frontUVs?: Vector4;
  27905. backUVs?: Vector4;
  27906. }): VertexData;
  27907. /**
  27908. * Compute normals for given positions and indices
  27909. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27910. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27911. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27912. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27913. * * facetNormals : optional array of facet normals (vector3)
  27914. * * facetPositions : optional array of facet positions (vector3)
  27915. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27916. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27917. * * bInfo : optional bounding info, required for facetPartitioning computation
  27918. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27919. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27920. * * useRightHandedSystem: optional boolean to for right handed system computation
  27921. * * depthSort : optional boolean to enable the facet depth sort computation
  27922. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27923. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27924. */
  27925. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27926. facetNormals?: any;
  27927. facetPositions?: any;
  27928. facetPartitioning?: any;
  27929. ratio?: number;
  27930. bInfo?: any;
  27931. bbSize?: Vector3;
  27932. subDiv?: any;
  27933. useRightHandedSystem?: boolean;
  27934. depthSort?: boolean;
  27935. distanceTo?: Vector3;
  27936. depthSortedFacets?: any;
  27937. }): void;
  27938. private static _ComputeSides;
  27939. /**
  27940. * Applies VertexData created from the imported parameters to the geometry
  27941. * @param parsedVertexData the parsed data from an imported file
  27942. * @param geometry the geometry to apply the VertexData to
  27943. */
  27944. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27945. }
  27946. }
  27947. declare module BABYLON {
  27948. /**
  27949. * Class containing static functions to help procedurally build meshes
  27950. */
  27951. class MeshBuilder {
  27952. private static updateSideOrientation;
  27953. /**
  27954. * Creates a box mesh
  27955. * * The parameter `size` sets the size (float) of each box side (default 1)
  27956. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27957. * * 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)
  27958. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27960. * * 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
  27961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27962. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27963. * @param name defines the name of the mesh
  27964. * @param options defines the options used to create the mesh
  27965. * @param scene defines the hosting scene
  27966. * @returns the box mesh
  27967. */
  27968. static CreateBox(name: string, options: {
  27969. size?: number;
  27970. width?: number;
  27971. height?: number;
  27972. depth?: number;
  27973. faceUV?: Vector4[];
  27974. faceColors?: Color4[];
  27975. sideOrientation?: number;
  27976. frontUVs?: Vector4;
  27977. backUVs?: Vector4;
  27978. updatable?: boolean;
  27979. }, scene?: Nullable<Scene>): Mesh;
  27980. /**
  27981. * Creates a sphere mesh
  27982. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27983. * * 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`)
  27984. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27985. * * 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
  27986. * * 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)
  27987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27988. * * 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
  27989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27990. * @param name defines the name of the mesh
  27991. * @param options defines the options used to create the mesh
  27992. * @param scene defines the hosting scene
  27993. * @returns the sphere mesh
  27994. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27995. */
  27996. static CreateSphere(name: string, options: {
  27997. segments?: number;
  27998. diameter?: number;
  27999. diameterX?: number;
  28000. diameterY?: number;
  28001. diameterZ?: number;
  28002. arc?: number;
  28003. slice?: number;
  28004. sideOrientation?: number;
  28005. frontUVs?: Vector4;
  28006. backUVs?: Vector4;
  28007. updatable?: boolean;
  28008. }, scene: any): Mesh;
  28009. /**
  28010. * Creates a plane polygonal mesh. By default, this is a disc
  28011. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28012. * * 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
  28013. * * 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
  28014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28015. * * 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
  28016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28017. * @param name defines the name of the mesh
  28018. * @param options defines the options used to create the mesh
  28019. * @param scene defines the hosting scene
  28020. * @returns the plane polygonal mesh
  28021. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28022. */
  28023. static CreateDisc(name: string, options: {
  28024. radius?: number;
  28025. tessellation?: number;
  28026. arc?: number;
  28027. updatable?: boolean;
  28028. sideOrientation?: number;
  28029. frontUVs?: Vector4;
  28030. backUVs?: Vector4;
  28031. }, scene?: Nullable<Scene>): Mesh;
  28032. /**
  28033. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28034. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28035. * * 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`)
  28036. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28037. * * 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
  28038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28039. * * 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
  28040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28041. * @param name defines the name of the mesh
  28042. * @param options defines the options used to create the mesh
  28043. * @param scene defines the hosting scene
  28044. * @returns the icosahedron mesh
  28045. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28046. */
  28047. static CreateIcoSphere(name: string, options: {
  28048. radius?: number;
  28049. radiusX?: number;
  28050. radiusY?: number;
  28051. radiusZ?: number;
  28052. flat?: boolean;
  28053. subdivisions?: number;
  28054. sideOrientation?: number;
  28055. frontUVs?: Vector4;
  28056. backUVs?: Vector4;
  28057. updatable?: boolean;
  28058. }, scene: Scene): Mesh;
  28059. /**
  28060. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28061. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28062. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28063. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28064. * * 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
  28065. * * 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
  28066. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  28067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28068. * * 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
  28069. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28070. * * 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
  28071. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28072. * * 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
  28073. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28075. * @param name defines the name of the mesh
  28076. * @param options defines the options used to create the mesh
  28077. * @param scene defines the hosting scene
  28078. * @returns the ribbon mesh
  28079. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  28080. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28081. */
  28082. static CreateRibbon(name: string, options: {
  28083. pathArray: Vector3[][];
  28084. closeArray?: boolean;
  28085. closePath?: boolean;
  28086. offset?: number;
  28087. updatable?: boolean;
  28088. sideOrientation?: number;
  28089. frontUVs?: Vector4;
  28090. backUVs?: Vector4;
  28091. instance?: Mesh;
  28092. invertUV?: boolean;
  28093. uvs?: Vector2[];
  28094. colors?: Color4[];
  28095. }, scene?: Nullable<Scene>): Mesh;
  28096. /**
  28097. * Creates a cylinder or a cone mesh
  28098. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28099. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28100. * * 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.
  28101. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28102. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28103. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28104. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28105. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28106. * * 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).
  28107. * * 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
  28108. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28109. * * 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
  28110. * * 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.
  28111. * * If `enclose` is false, a ring surface is one element.
  28112. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28113. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  28114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28115. * * 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
  28116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28117. * @param name defines the name of the mesh
  28118. * @param options defines the options used to create the mesh
  28119. * @param scene defines the hosting scene
  28120. * @returns the cylinder mesh
  28121. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28122. */
  28123. static CreateCylinder(name: string, options: {
  28124. height?: number;
  28125. diameterTop?: number;
  28126. diameterBottom?: number;
  28127. diameter?: number;
  28128. tessellation?: number;
  28129. subdivisions?: number;
  28130. arc?: number;
  28131. faceColors?: Color4[];
  28132. faceUV?: Vector4[];
  28133. updatable?: boolean;
  28134. hasRings?: boolean;
  28135. enclose?: boolean;
  28136. sideOrientation?: number;
  28137. frontUVs?: Vector4;
  28138. backUVs?: Vector4;
  28139. }, scene: any): Mesh;
  28140. /**
  28141. * Creates a torus mesh
  28142. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28143. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28144. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28146. * * 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
  28147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28148. * @param name defines the name of the mesh
  28149. * @param options defines the options used to create the mesh
  28150. * @param scene defines the hosting scene
  28151. * @returns the torus mesh
  28152. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28153. */
  28154. static CreateTorus(name: string, options: {
  28155. diameter?: number;
  28156. thickness?: number;
  28157. tessellation?: number;
  28158. updatable?: boolean;
  28159. sideOrientation?: number;
  28160. frontUVs?: Vector4;
  28161. backUVs?: Vector4;
  28162. }, scene: any): Mesh;
  28163. /**
  28164. * Creates a torus knot mesh
  28165. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28166. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28167. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28168. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28170. * * 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
  28171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28172. * @param name defines the name of the mesh
  28173. * @param options defines the options used to create the mesh
  28174. * @param scene defines the hosting scene
  28175. * @returns the torus knot mesh
  28176. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28177. */
  28178. static CreateTorusKnot(name: string, options: {
  28179. radius?: number;
  28180. tube?: number;
  28181. radialSegments?: number;
  28182. tubularSegments?: number;
  28183. p?: number;
  28184. q?: number;
  28185. updatable?: boolean;
  28186. sideOrientation?: number;
  28187. frontUVs?: Vector4;
  28188. backUVs?: Vector4;
  28189. }, scene: any): Mesh;
  28190. /**
  28191. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28192. * * 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
  28193. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28194. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28195. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28196. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28197. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28198. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28199. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28201. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28202. * @param name defines the name of the new line system
  28203. * @param options defines the options used to create the line system
  28204. * @param scene defines the hosting scene
  28205. * @returns a new line system mesh
  28206. */
  28207. static CreateLineSystem(name: string, options: {
  28208. lines: Vector3[][];
  28209. updatable?: boolean;
  28210. instance?: Nullable<LinesMesh>;
  28211. colors?: Nullable<Color4[][]>;
  28212. useVertexAlpha?: boolean;
  28213. }, scene: Nullable<Scene>): LinesMesh;
  28214. /**
  28215. * Creates a line mesh
  28216. * 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
  28217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28218. * * The parameter `points` is an array successive Vector3
  28219. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28220. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28222. * * When updating an instance, remember that only point positions can change, not the number of points
  28223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28224. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28225. * @param name defines the name of the new line system
  28226. * @param options defines the options used to create the line system
  28227. * @param scene defines the hosting scene
  28228. * @returns a new line mesh
  28229. */
  28230. static CreateLines(name: string, options: {
  28231. points: Vector3[];
  28232. updatable?: boolean;
  28233. instance?: Nullable<LinesMesh>;
  28234. colors?: Color4[];
  28235. useVertexAlpha?: boolean;
  28236. }, scene?: Nullable<Scene>): LinesMesh;
  28237. /**
  28238. * Creates a dashed line mesh
  28239. * * 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
  28240. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28241. * * The parameter `points` is an array successive Vector3
  28242. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28243. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28244. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28245. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28246. * * When updating an instance, remember that only point positions can change, not the number of points
  28247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28248. * @param name defines the name of the mesh
  28249. * @param options defines the options used to create the mesh
  28250. * @param scene defines the hosting scene
  28251. * @returns the dashed line mesh
  28252. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28253. */
  28254. static CreateDashedLines(name: string, options: {
  28255. points: Vector3[];
  28256. dashSize?: number;
  28257. gapSize?: number;
  28258. dashNb?: number;
  28259. updatable?: boolean;
  28260. instance?: LinesMesh;
  28261. }, scene?: Nullable<Scene>): LinesMesh;
  28262. /**
  28263. * 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.
  28264. * * 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.
  28265. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28266. * * 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.
  28267. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28268. * * 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
  28269. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28270. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28272. * * 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
  28273. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28275. * @param name defines the name of the mesh
  28276. * @param options defines the options used to create the mesh
  28277. * @param scene defines the hosting scene
  28278. * @returns the extruded shape mesh
  28279. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28280. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28281. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28282. */
  28283. static ExtrudeShape(name: string, options: {
  28284. shape: Vector3[];
  28285. path: Vector3[];
  28286. scale?: number;
  28287. rotation?: number;
  28288. cap?: number;
  28289. updatable?: boolean;
  28290. sideOrientation?: number;
  28291. frontUVs?: Vector4;
  28292. backUVs?: Vector4;
  28293. instance?: Mesh;
  28294. invertUV?: boolean;
  28295. }, scene?: Nullable<Scene>): Mesh;
  28296. /**
  28297. * Creates an custom extruded shape mesh.
  28298. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28299. * * 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.
  28300. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28301. * * 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
  28302. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28303. * * 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
  28304. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28305. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28306. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28307. * * 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
  28308. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28309. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28311. * * 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
  28312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28314. * @param name defines the name of the mesh
  28315. * @param options defines the options used to create the mesh
  28316. * @param scene defines the hosting scene
  28317. * @returns the custom extruded shape mesh
  28318. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28319. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28320. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28321. */
  28322. static ExtrudeShapeCustom(name: string, options: {
  28323. shape: Vector3[];
  28324. path: Vector3[];
  28325. scaleFunction?: any;
  28326. rotationFunction?: any;
  28327. ribbonCloseArray?: boolean;
  28328. ribbonClosePath?: boolean;
  28329. cap?: number;
  28330. updatable?: boolean;
  28331. sideOrientation?: number;
  28332. frontUVs?: Vector4;
  28333. backUVs?: Vector4;
  28334. instance?: Mesh;
  28335. invertUV?: boolean;
  28336. }, scene: Scene): Mesh;
  28337. /**
  28338. * Creates lathe mesh.
  28339. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28340. * * 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
  28341. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28342. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28343. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28344. * * 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
  28345. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28346. * * 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
  28347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28348. * * 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
  28349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28351. * @param name defines the name of the mesh
  28352. * @param options defines the options used to create the mesh
  28353. * @param scene defines the hosting scene
  28354. * @returns the lathe mesh
  28355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28356. */
  28357. static CreateLathe(name: string, options: {
  28358. shape: Vector3[];
  28359. radius?: number;
  28360. tessellation?: number;
  28361. clip?: number;
  28362. arc?: number;
  28363. closed?: boolean;
  28364. updatable?: boolean;
  28365. sideOrientation?: number;
  28366. frontUVs?: Vector4;
  28367. backUVs?: Vector4;
  28368. cap?: number;
  28369. invertUV?: boolean;
  28370. }, scene: Scene): Mesh;
  28371. /**
  28372. * Creates a plane mesh
  28373. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28374. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28375. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28377. * * 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
  28378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28379. * @param name defines the name of the mesh
  28380. * @param options defines the options used to create the mesh
  28381. * @param scene defines the hosting scene
  28382. * @returns the plane mesh
  28383. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28384. */
  28385. static CreatePlane(name: string, options: {
  28386. size?: number;
  28387. width?: number;
  28388. height?: number;
  28389. sideOrientation?: number;
  28390. frontUVs?: Vector4;
  28391. backUVs?: Vector4;
  28392. updatable?: boolean;
  28393. sourcePlane?: Plane;
  28394. }, scene: Scene): Mesh;
  28395. /**
  28396. * Creates a ground mesh
  28397. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28398. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28400. * @param name defines the name of the mesh
  28401. * @param options defines the options used to create the mesh
  28402. * @param scene defines the hosting scene
  28403. * @returns the ground mesh
  28404. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28405. */
  28406. static CreateGround(name: string, options: {
  28407. width?: number;
  28408. height?: number;
  28409. subdivisions?: number;
  28410. subdivisionsX?: number;
  28411. subdivisionsY?: number;
  28412. updatable?: boolean;
  28413. }, scene: any): Mesh;
  28414. /**
  28415. * Creates a tiled ground mesh
  28416. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28417. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28418. * * 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
  28419. * * 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
  28420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28421. * @param name defines the name of the mesh
  28422. * @param options defines the options used to create the mesh
  28423. * @param scene defines the hosting scene
  28424. * @returns the tiled ground mesh
  28425. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28426. */
  28427. static CreateTiledGround(name: string, options: {
  28428. xmin: number;
  28429. zmin: number;
  28430. xmax: number;
  28431. zmax: number;
  28432. subdivisions?: {
  28433. w: number;
  28434. h: number;
  28435. };
  28436. precision?: {
  28437. w: number;
  28438. h: number;
  28439. };
  28440. updatable?: boolean;
  28441. }, scene: Scene): Mesh;
  28442. /**
  28443. * Creates a ground mesh from a height map
  28444. * * The parameter `url` sets the URL of the height map image resource.
  28445. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28446. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28447. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28448. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28449. * * 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.
  28450. * * 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).
  28451. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28453. * @param name defines the name of the mesh
  28454. * @param url defines the url to the height map
  28455. * @param options defines the options used to create the mesh
  28456. * @param scene defines the hosting scene
  28457. * @returns the ground mesh
  28458. * @see http://doc.babylonjs.com/babylon101/height_map
  28459. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28460. */
  28461. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28462. width?: number;
  28463. height?: number;
  28464. subdivisions?: number;
  28465. minHeight?: number;
  28466. maxHeight?: number;
  28467. colorFilter?: Color3;
  28468. alphaFilter?: number;
  28469. updatable?: boolean;
  28470. onReady?: (mesh: GroundMesh) => void;
  28471. }, scene: Scene): GroundMesh;
  28472. /**
  28473. * Creates a polygon mesh
  28474. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28475. * * 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
  28476. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28478. * * 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)
  28479. * * Remember you can only change the shape positions, not their number when updating a polygon
  28480. * @param name defines the name of the mesh
  28481. * @param options defines the options used to create the mesh
  28482. * @param scene defines the hosting scene
  28483. * @returns the polygon mesh
  28484. */
  28485. static CreatePolygon(name: string, options: {
  28486. shape: Vector3[];
  28487. holes?: Vector3[][];
  28488. depth?: number;
  28489. faceUV?: Vector4[];
  28490. faceColors?: Color4[];
  28491. updatable?: boolean;
  28492. sideOrientation?: number;
  28493. frontUVs?: Vector4;
  28494. backUVs?: Vector4;
  28495. }, scene: Scene): Mesh;
  28496. /**
  28497. * Creates an extruded polygon mesh, with depth in the Y direction.
  28498. * * 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)
  28499. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28500. * @param name defines the name of the mesh
  28501. * @param options defines the options used to create the mesh
  28502. * @param scene defines the hosting scene
  28503. * @returns the polygon mesh
  28504. */
  28505. static ExtrudePolygon(name: string, options: {
  28506. shape: Vector3[];
  28507. holes?: Vector3[][];
  28508. depth?: number;
  28509. faceUV?: Vector4[];
  28510. faceColors?: Color4[];
  28511. updatable?: boolean;
  28512. sideOrientation?: number;
  28513. frontUVs?: Vector4;
  28514. backUVs?: Vector4;
  28515. }, scene: Scene): Mesh;
  28516. /**
  28517. * Creates a tube mesh.
  28518. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28519. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28520. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28521. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28522. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28523. * * 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)
  28524. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28525. * * 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
  28526. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  28527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28528. * * 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
  28529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28531. * @param name defines the name of the mesh
  28532. * @param options defines the options used to create the mesh
  28533. * @param scene defines the hosting scene
  28534. * @returns the tube mesh
  28535. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28536. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28537. */
  28538. static CreateTube(name: string, options: {
  28539. path: Vector3[];
  28540. radius?: number;
  28541. tessellation?: number;
  28542. radiusFunction?: {
  28543. (i: number, distance: number): number;
  28544. };
  28545. cap?: number;
  28546. arc?: number;
  28547. updatable?: boolean;
  28548. sideOrientation?: number;
  28549. frontUVs?: Vector4;
  28550. backUVs?: Vector4;
  28551. instance?: Mesh;
  28552. invertUV?: boolean;
  28553. }, scene: Scene): Mesh;
  28554. /**
  28555. * Creates a polyhedron mesh
  28556. * * 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
  28557. * * The parameter `size` (positive float, default 1) sets the polygon size
  28558. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28559. * * 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`
  28560. * * 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
  28561. * * 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)`)
  28562. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28563. * * 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
  28564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28565. * * 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
  28566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28567. * @param name defines the name of the mesh
  28568. * @param options defines the options used to create the mesh
  28569. * @param scene defines the hosting scene
  28570. * @returns the polyhedron mesh
  28571. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28572. */
  28573. static CreatePolyhedron(name: string, options: {
  28574. type?: number;
  28575. size?: number;
  28576. sizeX?: number;
  28577. sizeY?: number;
  28578. sizeZ?: number;
  28579. custom?: any;
  28580. faceUV?: Vector4[];
  28581. faceColors?: Color4[];
  28582. flat?: boolean;
  28583. updatable?: boolean;
  28584. sideOrientation?: number;
  28585. frontUVs?: Vector4;
  28586. backUVs?: Vector4;
  28587. }, scene: Scene): Mesh;
  28588. /**
  28589. * Creates a decal mesh.
  28590. * 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
  28591. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28592. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28593. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28594. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28595. * @param name defines the name of the mesh
  28596. * @param sourceMesh defines the mesh where the decal must be applied
  28597. * @param options defines the options used to create the mesh
  28598. * @param scene defines the hosting scene
  28599. * @returns the decal mesh
  28600. * @see http://doc.babylonjs.com/how_to/decals
  28601. */
  28602. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28603. position?: Vector3;
  28604. normal?: Vector3;
  28605. size?: Vector3;
  28606. angle?: number;
  28607. }): Mesh;
  28608. private static _ExtrudeShapeGeneric;
  28609. }
  28610. }
  28611. declare module BABYLON {
  28612. /**
  28613. * Class used to represent a specific level of detail of a mesh
  28614. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28615. */
  28616. class MeshLODLevel {
  28617. /** Defines the distance where this level should star being displayed */
  28618. distance: number;
  28619. /** Defines the mesh to use to render this level */
  28620. mesh: Nullable<Mesh>;
  28621. /**
  28622. * Creates a new LOD level
  28623. * @param distance defines the distance where this level should star being displayed
  28624. * @param mesh defines the mesh to use to render this level
  28625. */
  28626. constructor(
  28627. /** Defines the distance where this level should star being displayed */
  28628. distance: number,
  28629. /** Defines the mesh to use to render this level */
  28630. mesh: Nullable<Mesh>);
  28631. }
  28632. }
  28633. declare module BABYLON {
  28634. /**
  28635. * A simplifier interface for future simplification implementations
  28636. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28637. */
  28638. interface ISimplifier {
  28639. /**
  28640. * Simplification of a given mesh according to the given settings.
  28641. * Since this requires computation, it is assumed that the function runs async.
  28642. * @param settings The settings of the simplification, including quality and distance
  28643. * @param successCallback A callback that will be called after the mesh was simplified.
  28644. * @param errorCallback in case of an error, this callback will be called. optional.
  28645. */
  28646. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28647. }
  28648. /**
  28649. * Expected simplification settings.
  28650. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28651. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28652. */
  28653. interface ISimplificationSettings {
  28654. /**
  28655. * Gets or sets the expected quality
  28656. */
  28657. quality: number;
  28658. /**
  28659. * Gets or sets the distance when this optimized version should be used
  28660. */
  28661. distance: number;
  28662. /**
  28663. * Gets an already optimized mesh
  28664. */
  28665. optimizeMesh?: boolean;
  28666. }
  28667. /**
  28668. * Class used to specify simplification options
  28669. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28670. */
  28671. class SimplificationSettings implements ISimplificationSettings {
  28672. /** expected quality */
  28673. quality: number;
  28674. /** distance when this optimized version should be used */
  28675. distance: number;
  28676. /** already optimized mesh */
  28677. optimizeMesh?: boolean | undefined;
  28678. /**
  28679. * Creates a SimplificationSettings
  28680. * @param quality expected quality
  28681. * @param distance distance when this optimized version should be used
  28682. * @param optimizeMesh already optimized mesh
  28683. */
  28684. constructor(
  28685. /** expected quality */
  28686. quality: number,
  28687. /** distance when this optimized version should be used */
  28688. distance: number,
  28689. /** already optimized mesh */
  28690. optimizeMesh?: boolean | undefined);
  28691. }
  28692. /**
  28693. * Interface used to define a simplification task
  28694. */
  28695. interface ISimplificationTask {
  28696. /**
  28697. * Array of settings
  28698. */
  28699. settings: Array<ISimplificationSettings>;
  28700. /**
  28701. * Simplification type
  28702. */
  28703. simplificationType: SimplificationType;
  28704. /**
  28705. * Mesh to simplify
  28706. */
  28707. mesh: Mesh;
  28708. /**
  28709. * Callback called on success
  28710. */
  28711. successCallback?: () => void;
  28712. /**
  28713. * Defines if parallel processing can be used
  28714. */
  28715. parallelProcessing: boolean;
  28716. }
  28717. /**
  28718. * Queue used to order the simplification tasks
  28719. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28720. */
  28721. class SimplificationQueue {
  28722. private _simplificationArray;
  28723. /**
  28724. * Gets a boolean indicating that the process is still running
  28725. */
  28726. running: boolean;
  28727. /**
  28728. * Creates a new queue
  28729. */
  28730. constructor();
  28731. /**
  28732. * Adds a new simplification task
  28733. * @param task defines a task to add
  28734. */
  28735. addTask(task: ISimplificationTask): void;
  28736. /**
  28737. * Execute next task
  28738. */
  28739. executeNext(): void;
  28740. /**
  28741. * Execute a simplification task
  28742. * @param task defines the task to run
  28743. */
  28744. runSimplification(task: ISimplificationTask): void;
  28745. private getSimplifier;
  28746. }
  28747. /**
  28748. * The implemented types of simplification
  28749. * At the moment only Quadratic Error Decimation is implemented
  28750. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28751. */
  28752. enum SimplificationType {
  28753. /** Quadratic error decimation */
  28754. QUADRATIC = 0
  28755. }
  28756. }
  28757. declare module BABYLON {
  28758. interface Scene {
  28759. /** @hidden (Backing field) */
  28760. _simplificationQueue: SimplificationQueue;
  28761. /**
  28762. * Gets or sets the simplification queue attached to the scene
  28763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28764. */
  28765. simplificationQueue: SimplificationQueue;
  28766. }
  28767. interface Mesh {
  28768. /**
  28769. * Simplify the mesh according to the given array of settings.
  28770. * Function will return immediately and will simplify async
  28771. * @param settings a collection of simplification settings
  28772. * @param parallelProcessing should all levels calculate parallel or one after the other
  28773. * @param simplificationType the type of simplification to run
  28774. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28775. * @returns the current mesh
  28776. */
  28777. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28778. }
  28779. /**
  28780. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28781. * created in a scene
  28782. */
  28783. class SimplicationQueueSceneComponent implements ISceneComponent {
  28784. /**
  28785. * The component name helpfull to identify the component in the list of scene components.
  28786. */
  28787. readonly name: string;
  28788. /**
  28789. * The scene the component belongs to.
  28790. */
  28791. scene: Scene;
  28792. /**
  28793. * Creates a new instance of the component for the given scene
  28794. * @param scene Defines the scene to register the component in
  28795. */
  28796. constructor(scene: Scene);
  28797. /**
  28798. * Registers the component in a given scene
  28799. */
  28800. register(): void;
  28801. /**
  28802. * Rebuilds the elements related to this component in case of
  28803. * context lost for instance.
  28804. */
  28805. rebuild(): void;
  28806. /**
  28807. * Disposes the component and the associated ressources
  28808. */
  28809. dispose(): void;
  28810. private _beforeCameraUpdate;
  28811. }
  28812. }
  28813. declare module BABYLON {
  28814. /**
  28815. * Polygon
  28816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28817. */
  28818. class Polygon {
  28819. /**
  28820. * Creates a rectangle
  28821. * @param xmin bottom X coord
  28822. * @param ymin bottom Y coord
  28823. * @param xmax top X coord
  28824. * @param ymax top Y coord
  28825. * @returns points that make the resulting rectation
  28826. */
  28827. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28828. /**
  28829. * Creates a circle
  28830. * @param radius radius of circle
  28831. * @param cx scale in x
  28832. * @param cy scale in y
  28833. * @param numberOfSides number of sides that make up the circle
  28834. * @returns points that make the resulting circle
  28835. */
  28836. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28837. /**
  28838. * Creates a polygon from input string
  28839. * @param input Input polygon data
  28840. * @returns the parsed points
  28841. */
  28842. static Parse(input: string): Vector2[];
  28843. /**
  28844. * Starts building a polygon from x and y coordinates
  28845. * @param x x coordinate
  28846. * @param y y coordinate
  28847. * @returns the started path2
  28848. */
  28849. static StartingAt(x: number, y: number): Path2;
  28850. }
  28851. /**
  28852. * Builds a polygon
  28853. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28854. */
  28855. class PolygonMeshBuilder {
  28856. private _points;
  28857. private _outlinepoints;
  28858. private _holes;
  28859. private _name;
  28860. private _scene;
  28861. private _epoints;
  28862. private _eholes;
  28863. private _addToepoint;
  28864. /**
  28865. * Creates a PolygonMeshBuilder
  28866. * @param name name of the builder
  28867. * @param contours Path of the polygon
  28868. * @param scene scene to add to
  28869. */
  28870. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28871. /**
  28872. * Adds a whole within the polygon
  28873. * @param hole Array of points defining the hole
  28874. * @returns this
  28875. */
  28876. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28877. /**
  28878. * Creates the polygon
  28879. * @param updatable If the mesh should be updatable
  28880. * @param depth The depth of the mesh created
  28881. * @returns the created mesh
  28882. */
  28883. build(updatable?: boolean, depth?: number): Mesh;
  28884. /**
  28885. * Adds a side to the polygon
  28886. * @param positions points that make the polygon
  28887. * @param normals normals of the polygon
  28888. * @param uvs uvs of the polygon
  28889. * @param indices indices of the polygon
  28890. * @param bounds bounds of the polygon
  28891. * @param points points of the polygon
  28892. * @param depth depth of the polygon
  28893. * @param flip flip of the polygon
  28894. */
  28895. private addSide;
  28896. }
  28897. }
  28898. declare module BABYLON {
  28899. /**
  28900. * Base class for submeshes
  28901. */
  28902. class BaseSubMesh {
  28903. /** @hidden */
  28904. _materialDefines: Nullable<MaterialDefines>;
  28905. /** @hidden */
  28906. _materialEffect: Nullable<Effect>;
  28907. /**
  28908. * Gets associated effect
  28909. */
  28910. readonly effect: Nullable<Effect>;
  28911. /**
  28912. * Sets associated effect (effect used to render this submesh)
  28913. * @param effect defines the effect to associate with
  28914. * @param defines defines the set of defines used to compile this effect
  28915. */
  28916. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28917. }
  28918. /**
  28919. * Defines a subdivision inside a mesh
  28920. */
  28921. class SubMesh extends BaseSubMesh implements ICullable {
  28922. /** the material index to use */
  28923. materialIndex: number;
  28924. /** vertex index start */
  28925. verticesStart: number;
  28926. /** vertices count */
  28927. verticesCount: number;
  28928. /** index start */
  28929. indexStart: number;
  28930. /** indices count */
  28931. indexCount: number;
  28932. /** @hidden */
  28933. _linesIndexCount: number;
  28934. private _mesh;
  28935. private _renderingMesh;
  28936. private _boundingInfo;
  28937. private _linesIndexBuffer;
  28938. /** @hidden */
  28939. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28940. /** @hidden */
  28941. _trianglePlanes: Plane[];
  28942. /** @hidden */
  28943. _lastColliderTransformMatrix: Matrix;
  28944. /** @hidden */
  28945. _renderId: number;
  28946. /** @hidden */
  28947. _alphaIndex: number;
  28948. /** @hidden */
  28949. _distanceToCamera: number;
  28950. /** @hidden */
  28951. _id: number;
  28952. private _currentMaterial;
  28953. /**
  28954. * Add a new submesh to a mesh
  28955. * @param materialIndex defines the material index to use
  28956. * @param verticesStart defines vertex index start
  28957. * @param verticesCount defines vertices count
  28958. * @param indexStart defines index start
  28959. * @param indexCount defines indices count
  28960. * @param mesh defines the parent mesh
  28961. * @param renderingMesh defines an optional rendering mesh
  28962. * @param createBoundingBox defines if bounding box should be created for this submesh
  28963. * @returns the new submesh
  28964. */
  28965. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28966. /**
  28967. * Creates a new submesh
  28968. * @param materialIndex defines the material index to use
  28969. * @param verticesStart defines vertex index start
  28970. * @param verticesCount defines vertices count
  28971. * @param indexStart defines index start
  28972. * @param indexCount defines indices count
  28973. * @param mesh defines the parent mesh
  28974. * @param renderingMesh defines an optional rendering mesh
  28975. * @param createBoundingBox defines if bounding box should be created for this submesh
  28976. */
  28977. constructor(
  28978. /** the material index to use */
  28979. materialIndex: number,
  28980. /** vertex index start */
  28981. verticesStart: number,
  28982. /** vertices count */
  28983. verticesCount: number,
  28984. /** index start */
  28985. indexStart: number,
  28986. /** indices count */
  28987. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28988. /**
  28989. * Returns true if this submesh covers the entire parent mesh
  28990. * @ignorenaming
  28991. */
  28992. readonly IsGlobal: boolean;
  28993. /**
  28994. * Returns the submesh BoudingInfo object
  28995. * @returns current bounding info (or mesh's one if the submesh is global)
  28996. */
  28997. getBoundingInfo(): BoundingInfo;
  28998. /**
  28999. * Sets the submesh BoundingInfo
  29000. * @param boundingInfo defines the new bounding info to use
  29001. * @returns the SubMesh
  29002. */
  29003. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29004. /**
  29005. * Returns the mesh of the current submesh
  29006. * @return the parent mesh
  29007. */
  29008. getMesh(): AbstractMesh;
  29009. /**
  29010. * Returns the rendering mesh of the submesh
  29011. * @returns the rendering mesh (could be different from parent mesh)
  29012. */
  29013. getRenderingMesh(): Mesh;
  29014. /**
  29015. * Returns the submesh material
  29016. * @returns null or the current material
  29017. */
  29018. getMaterial(): Nullable<Material>;
  29019. /**
  29020. * Sets a new updated BoundingInfo object to the submesh
  29021. * @returns the SubMesh
  29022. */
  29023. refreshBoundingInfo(): SubMesh;
  29024. /** @hidden */
  29025. _checkCollision(collider: Collider): boolean;
  29026. /**
  29027. * Updates the submesh BoundingInfo
  29028. * @param world defines the world matrix to use to update the bounding info
  29029. * @returns the submesh
  29030. */
  29031. updateBoundingInfo(world: Matrix): SubMesh;
  29032. /**
  29033. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29034. * @param frustumPlanes defines the frustum planes
  29035. * @returns true if the submesh is intersecting with the frustum
  29036. */
  29037. isInFrustum(frustumPlanes: Plane[]): boolean;
  29038. /**
  29039. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29040. * @param frustumPlanes defines the frustum planes
  29041. * @returns true if the submesh is inside the frustum
  29042. */
  29043. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29044. /**
  29045. * Renders the submesh
  29046. * @param enableAlphaMode defines if alpha needs to be used
  29047. * @returns the submesh
  29048. */
  29049. render(enableAlphaMode: boolean): SubMesh;
  29050. /**
  29051. * @hidden
  29052. */
  29053. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29054. /**
  29055. * Checks if the submesh intersects with a ray
  29056. * @param ray defines the ray to test
  29057. * @returns true is the passed ray intersects the submesh bounding box
  29058. */
  29059. canIntersects(ray: Ray): boolean;
  29060. /**
  29061. * Intersects current submesh with a ray
  29062. * @param ray defines the ray to test
  29063. * @param positions defines mesh's positions array
  29064. * @param indices defines mesh's indices array
  29065. * @param fastCheck defines if only bounding info should be used
  29066. * @returns intersection info or null if no intersection
  29067. */
  29068. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29069. /** @hidden */
  29070. private _intersectLines;
  29071. /** @hidden */
  29072. private _intersectTriangles;
  29073. /** @hidden */
  29074. _rebuild(): void;
  29075. /**
  29076. * Creates a new submesh from the passed mesh
  29077. * @param newMesh defines the new hosting mesh
  29078. * @param newRenderingMesh defines an optional rendering mesh
  29079. * @returns the new submesh
  29080. */
  29081. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29082. /**
  29083. * Release associated resources
  29084. */
  29085. dispose(): void;
  29086. /**
  29087. * Creates a new submesh from indices data
  29088. * @param materialIndex the index of the main mesh material
  29089. * @param startIndex the index where to start the copy in the mesh indices array
  29090. * @param indexCount the number of indices to copy then from the startIndex
  29091. * @param mesh the main mesh to create the submesh from
  29092. * @param renderingMesh the optional rendering mesh
  29093. * @returns a new submesh
  29094. */
  29095. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29096. }
  29097. }
  29098. declare module BABYLON {
  29099. /**
  29100. * 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.
  29101. * @see https://doc.babylonjs.com/how_to/transformnode
  29102. */
  29103. class TransformNode extends Node {
  29104. /**
  29105. * Object will not rotate to face the camera
  29106. */
  29107. static BILLBOARDMODE_NONE: number;
  29108. /**
  29109. * Object will rotate to face the camera but only on the x axis
  29110. */
  29111. static BILLBOARDMODE_X: number;
  29112. /**
  29113. * Object will rotate to face the camera but only on the y axis
  29114. */
  29115. static BILLBOARDMODE_Y: number;
  29116. /**
  29117. * Object will rotate to face the camera but only on the z axis
  29118. */
  29119. static BILLBOARDMODE_Z: number;
  29120. /**
  29121. * Object will rotate to face the camera
  29122. */
  29123. static BILLBOARDMODE_ALL: number;
  29124. private _forward;
  29125. private _forwardInverted;
  29126. private _up;
  29127. private _right;
  29128. private _rightInverted;
  29129. private _position;
  29130. private _rotation;
  29131. private _rotationQuaternion;
  29132. protected _scaling: Vector3;
  29133. protected _isDirty: boolean;
  29134. private _transformToBoneReferal;
  29135. /**
  29136. * Set the billboard mode. Default is 0.
  29137. *
  29138. * | Value | Type | Description |
  29139. * | --- | --- | --- |
  29140. * | 0 | BILLBOARDMODE_NONE | |
  29141. * | 1 | BILLBOARDMODE_X | |
  29142. * | 2 | BILLBOARDMODE_Y | |
  29143. * | 4 | BILLBOARDMODE_Z | |
  29144. * | 7 | BILLBOARDMODE_ALL | |
  29145. *
  29146. */
  29147. billboardMode: number;
  29148. /**
  29149. * 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
  29150. */
  29151. scalingDeterminant: number;
  29152. /**
  29153. * Sets the distance of the object to max, often used by skybox
  29154. */
  29155. infiniteDistance: boolean;
  29156. /**
  29157. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29158. * By default the system will update normals to compensate
  29159. */
  29160. ignoreNonUniformScaling: boolean;
  29161. /** @hidden */
  29162. _poseMatrix: Matrix;
  29163. private _localWorld;
  29164. private _absolutePosition;
  29165. private _pivotMatrix;
  29166. private _pivotMatrixInverse;
  29167. protected _postMultiplyPivotMatrix: boolean;
  29168. protected _isWorldMatrixFrozen: boolean;
  29169. /** @hidden */
  29170. _indexInSceneTransformNodesArray: number;
  29171. /**
  29172. * An event triggered after the world matrix is updated
  29173. */
  29174. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29175. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29176. /**
  29177. * Gets a string identifying the name of the class
  29178. * @returns "TransformNode" string
  29179. */
  29180. getClassName(): string;
  29181. /**
  29182. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29183. */
  29184. position: Vector3;
  29185. /**
  29186. * 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)).
  29187. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29188. */
  29189. rotation: Vector3;
  29190. /**
  29191. * 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)).
  29192. */
  29193. scaling: Vector3;
  29194. /**
  29195. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29196. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29197. */
  29198. rotationQuaternion: Nullable<Quaternion>;
  29199. /**
  29200. * The forward direction of that transform in world space.
  29201. */
  29202. readonly forward: Vector3;
  29203. /**
  29204. * The up direction of that transform in world space.
  29205. */
  29206. readonly up: Vector3;
  29207. /**
  29208. * The right direction of that transform in world space.
  29209. */
  29210. readonly right: Vector3;
  29211. /**
  29212. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29213. * @param matrix the matrix to copy the pose from
  29214. * @returns this TransformNode.
  29215. */
  29216. updatePoseMatrix(matrix: Matrix): TransformNode;
  29217. /**
  29218. * Returns the mesh Pose matrix.
  29219. * @returns the pose matrix
  29220. */
  29221. getPoseMatrix(): Matrix;
  29222. /** @hidden */
  29223. _isSynchronized(): boolean;
  29224. /** @hidden */
  29225. _initCache(): void;
  29226. /**
  29227. * Flag the transform node as dirty (Forcing it to update everything)
  29228. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29229. * @returns this transform node
  29230. */
  29231. markAsDirty(property: string): TransformNode;
  29232. /**
  29233. * Returns the current mesh absolute position.
  29234. * Returns a Vector3.
  29235. */
  29236. readonly absolutePosition: Vector3;
  29237. /**
  29238. * Sets a new matrix to apply before all other transformation
  29239. * @param matrix defines the transform matrix
  29240. * @returns the current TransformNode
  29241. */
  29242. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29243. /**
  29244. * Sets a new pivot matrix to the current node
  29245. * @param matrix defines the new pivot matrix to use
  29246. * @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
  29247. * @returns the current TransformNode
  29248. */
  29249. setPivotMatrix(matrix: Readonly<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29250. /**
  29251. * Returns the mesh pivot matrix.
  29252. * Default : Identity.
  29253. * @returns the matrix
  29254. */
  29255. getPivotMatrix(): Matrix;
  29256. /**
  29257. * Prevents the World matrix to be computed any longer.
  29258. * @returns the TransformNode.
  29259. */
  29260. freezeWorldMatrix(): TransformNode;
  29261. /**
  29262. * Allows back the World matrix computation.
  29263. * @returns the TransformNode.
  29264. */
  29265. unfreezeWorldMatrix(): this;
  29266. /**
  29267. * True if the World matrix has been frozen.
  29268. */
  29269. readonly isWorldMatrixFrozen: boolean;
  29270. /**
  29271. * Retuns the mesh absolute position in the World.
  29272. * @returns a Vector3.
  29273. */
  29274. getAbsolutePosition(): Vector3;
  29275. /**
  29276. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29277. * @param absolutePosition the absolute position to set
  29278. * @returns the TransformNode.
  29279. */
  29280. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29281. /**
  29282. * Sets the mesh position in its local space.
  29283. * @param vector3 the position to set in localspace
  29284. * @returns the TransformNode.
  29285. */
  29286. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29287. /**
  29288. * Returns the mesh position in the local space from the current World matrix values.
  29289. * @returns a new Vector3.
  29290. */
  29291. getPositionExpressedInLocalSpace(): Vector3;
  29292. /**
  29293. * Translates the mesh along the passed Vector3 in its local space.
  29294. * @param vector3 the distance to translate in localspace
  29295. * @returns the TransformNode.
  29296. */
  29297. locallyTranslate(vector3: Vector3): TransformNode;
  29298. private static _lookAtVectorCache;
  29299. /**
  29300. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29301. * @param targetPoint the position (must be in same space as current mesh) to look at
  29302. * @param yawCor optional yaw (y-axis) correction in radians
  29303. * @param pitchCor optional pitch (x-axis) correction in radians
  29304. * @param rollCor optional roll (z-axis) correction in radians
  29305. * @param space the choosen space of the target
  29306. * @returns the TransformNode.
  29307. */
  29308. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29309. /**
  29310. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29311. * This Vector3 is expressed in the World space.
  29312. * @param localAxis axis to rotate
  29313. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29314. */
  29315. getDirection(localAxis: Vector3): Vector3;
  29316. /**
  29317. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29318. * localAxis is expressed in the mesh local space.
  29319. * result is computed in the Wordl space from the mesh World matrix.
  29320. * @param localAxis axis to rotate
  29321. * @param result the resulting transformnode
  29322. * @returns this TransformNode.
  29323. */
  29324. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29325. /**
  29326. * Sets a new pivot point to the current node
  29327. * @param point defines the new pivot point to use
  29328. * @param space defines if the point is in world or local space (local by default)
  29329. * @returns the current TransformNode
  29330. */
  29331. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29332. /**
  29333. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29334. * @returns the pivot point
  29335. */
  29336. getPivotPoint(): Vector3;
  29337. /**
  29338. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29339. * @param result the vector3 to store the result
  29340. * @returns this TransformNode.
  29341. */
  29342. getPivotPointToRef(result: Vector3): TransformNode;
  29343. /**
  29344. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29345. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29346. */
  29347. getAbsolutePivotPoint(): Vector3;
  29348. /**
  29349. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29350. * @param result vector3 to store the result
  29351. * @returns this TransformNode.
  29352. */
  29353. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29354. /**
  29355. * Defines the passed node as the parent of the current node.
  29356. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29357. * @param node the node ot set as the parent
  29358. * @returns this TransformNode.
  29359. */
  29360. setParent(node: Nullable<Node>): TransformNode;
  29361. private _nonUniformScaling;
  29362. /**
  29363. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29364. */
  29365. readonly nonUniformScaling: boolean;
  29366. /** @hidden */
  29367. _updateNonUniformScalingState(value: boolean): boolean;
  29368. /**
  29369. * Attach the current TransformNode to another TransformNode associated with a bone
  29370. * @param bone Bone affecting the TransformNode
  29371. * @param affectedTransformNode TransformNode associated with the bone
  29372. * @returns this object
  29373. */
  29374. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29375. /**
  29376. * Detach the transform node if its associated with a bone
  29377. * @returns this object
  29378. */
  29379. detachFromBone(): TransformNode;
  29380. private static _rotationAxisCache;
  29381. /**
  29382. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29383. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29384. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29385. * The passed axis is also normalized.
  29386. * @param axis the axis to rotate around
  29387. * @param amount the amount to rotate in radians
  29388. * @param space Space to rotate in (Default: local)
  29389. * @returns the TransformNode.
  29390. */
  29391. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29392. /**
  29393. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29394. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29395. * The passed axis is also normalized. .
  29396. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29397. * @param point the point to rotate around
  29398. * @param axis the axis to rotate around
  29399. * @param amount the amount to rotate in radians
  29400. * @returns the TransformNode
  29401. */
  29402. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29403. /**
  29404. * Translates the mesh along the axis vector for the passed distance in the given space.
  29405. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29406. * @param axis the axis to translate in
  29407. * @param distance the distance to translate
  29408. * @param space Space to rotate in (Default: local)
  29409. * @returns the TransformNode.
  29410. */
  29411. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29412. /**
  29413. * Adds a rotation step to the mesh current rotation.
  29414. * x, y, z are Euler angles expressed in radians.
  29415. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29416. * This means this rotation is made in the mesh local space only.
  29417. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29418. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29419. * ```javascript
  29420. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29421. * ```
  29422. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29423. * 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.
  29424. * @param x Rotation to add
  29425. * @param y Rotation to add
  29426. * @param z Rotation to add
  29427. * @returns the TransformNode.
  29428. */
  29429. addRotation(x: number, y: number, z: number): TransformNode;
  29430. /**
  29431. * Computes the world matrix of the node
  29432. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29433. * @returns the world matrix
  29434. */
  29435. computeWorldMatrix(force?: boolean): Matrix;
  29436. protected _afterComputeWorldMatrix(): void;
  29437. /**
  29438. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29439. * @param func callback function to add
  29440. *
  29441. * @returns the TransformNode.
  29442. */
  29443. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29444. /**
  29445. * Removes a registered callback function.
  29446. * @param func callback function to remove
  29447. * @returns the TransformNode.
  29448. */
  29449. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29450. /**
  29451. * Gets the position of the current mesh in camera space
  29452. * @param camera defines the camera to use
  29453. * @returns a position
  29454. */
  29455. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29456. /**
  29457. * Returns the distance from the mesh to the active camera
  29458. * @param camera defines the camera to use
  29459. * @returns the distance
  29460. */
  29461. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29462. /**
  29463. * Clone the current transform node
  29464. * @param name Name of the new clone
  29465. * @param newParent New parent for the clone
  29466. * @param doNotCloneChildren Do not clone children hierarchy
  29467. * @returns the new transform node
  29468. */
  29469. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29470. /**
  29471. * Serializes the objects information.
  29472. * @param currentSerializationObject defines the object to serialize in
  29473. * @returns the serialized object
  29474. */
  29475. serialize(currentSerializationObject?: any): any;
  29476. /**
  29477. * Returns a new TransformNode object parsed from the source provided.
  29478. * @param parsedTransformNode is the source.
  29479. * @param scene the scne the object belongs to
  29480. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29481. * @returns a new TransformNode object parsed from the source provided.
  29482. */
  29483. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29484. /**
  29485. * Releases resources associated with this transform node.
  29486. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29487. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29488. */
  29489. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29490. }
  29491. }
  29492. declare module BABYLON {
  29493. /**
  29494. * Specialized buffer used to store vertex data
  29495. */
  29496. class VertexBuffer {
  29497. /** @hidden */
  29498. _buffer: Buffer;
  29499. private _kind;
  29500. private _size;
  29501. private _ownsBuffer;
  29502. private _instanced;
  29503. private _instanceDivisor;
  29504. /**
  29505. * The byte type.
  29506. */
  29507. static readonly BYTE: number;
  29508. /**
  29509. * The unsigned byte type.
  29510. */
  29511. static readonly UNSIGNED_BYTE: number;
  29512. /**
  29513. * The short type.
  29514. */
  29515. static readonly SHORT: number;
  29516. /**
  29517. * The unsigned short type.
  29518. */
  29519. static readonly UNSIGNED_SHORT: number;
  29520. /**
  29521. * The integer type.
  29522. */
  29523. static readonly INT: number;
  29524. /**
  29525. * The unsigned integer type.
  29526. */
  29527. static readonly UNSIGNED_INT: number;
  29528. /**
  29529. * The float type.
  29530. */
  29531. static readonly FLOAT: number;
  29532. /**
  29533. * Gets or sets the instance divisor when in instanced mode
  29534. */
  29535. instanceDivisor: number;
  29536. /**
  29537. * Gets the byte stride.
  29538. */
  29539. readonly byteStride: number;
  29540. /**
  29541. * Gets the byte offset.
  29542. */
  29543. readonly byteOffset: number;
  29544. /**
  29545. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29546. */
  29547. readonly normalized: boolean;
  29548. /**
  29549. * Gets the data type of each component in the array.
  29550. */
  29551. readonly type: number;
  29552. /**
  29553. * Constructor
  29554. * @param engine the engine
  29555. * @param data the data to use for this vertex buffer
  29556. * @param kind the vertex buffer kind
  29557. * @param updatable whether the data is updatable
  29558. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29559. * @param stride the stride (optional)
  29560. * @param instanced whether the buffer is instanced (optional)
  29561. * @param offset the offset of the data (optional)
  29562. * @param size the number of components (optional)
  29563. * @param type the type of the component (optional)
  29564. * @param normalized whether the data contains normalized data (optional)
  29565. * @param useBytes set to true if stride and offset are in bytes (optional)
  29566. */
  29567. 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);
  29568. /** @hidden */
  29569. _rebuild(): void;
  29570. /**
  29571. * Returns the kind of the VertexBuffer (string)
  29572. * @returns a string
  29573. */
  29574. getKind(): string;
  29575. /**
  29576. * Gets a boolean indicating if the VertexBuffer is updatable?
  29577. * @returns true if the buffer is updatable
  29578. */
  29579. isUpdatable(): boolean;
  29580. /**
  29581. * Gets current buffer's data
  29582. * @returns a DataArray or null
  29583. */
  29584. getData(): Nullable<DataArray>;
  29585. /**
  29586. * Gets underlying native buffer
  29587. * @returns underlying native buffer
  29588. */
  29589. getBuffer(): Nullable<WebGLBuffer>;
  29590. /**
  29591. * Gets the stride in float32 units (i.e. byte stride / 4).
  29592. * May not be an integer if the byte stride is not divisible by 4.
  29593. * DEPRECATED. Use byteStride instead.
  29594. * @returns the stride in float32 units
  29595. */
  29596. getStrideSize(): number;
  29597. /**
  29598. * Returns the offset as a multiple of the type byte length.
  29599. * DEPRECATED. Use byteOffset instead.
  29600. * @returns the offset in bytes
  29601. */
  29602. getOffset(): number;
  29603. /**
  29604. * Returns the number of components per vertex attribute (integer)
  29605. * @returns the size in float
  29606. */
  29607. getSize(): number;
  29608. /**
  29609. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29610. * @returns true if this buffer is instanced
  29611. */
  29612. getIsInstanced(): boolean;
  29613. /**
  29614. * Returns the instancing divisor, zero for non-instanced (integer).
  29615. * @returns a number
  29616. */
  29617. getInstanceDivisor(): number;
  29618. /**
  29619. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29620. * @param data defines the data to store
  29621. */
  29622. create(data?: DataArray): void;
  29623. /**
  29624. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29625. * This function will create a new buffer if the current one is not updatable
  29626. * @param data defines the data to store
  29627. */
  29628. update(data: DataArray): void;
  29629. /**
  29630. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29631. * Returns the directly updated WebGLBuffer.
  29632. * @param data the new data
  29633. * @param offset the new offset
  29634. * @param useBytes set to true if the offset is in bytes
  29635. */
  29636. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29637. /**
  29638. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29639. */
  29640. dispose(): void;
  29641. /**
  29642. * Enumerates each value of this vertex buffer as numbers.
  29643. * @param count the number of values to enumerate
  29644. * @param callback the callback function called for each value
  29645. */
  29646. forEach(count: number, callback: (value: number, index: number) => void): void;
  29647. /**
  29648. * Positions
  29649. */
  29650. static readonly PositionKind: string;
  29651. /**
  29652. * Normals
  29653. */
  29654. static readonly NormalKind: string;
  29655. /**
  29656. * Tangents
  29657. */
  29658. static readonly TangentKind: string;
  29659. /**
  29660. * Texture coordinates
  29661. */
  29662. static readonly UVKind: string;
  29663. /**
  29664. * Texture coordinates 2
  29665. */
  29666. static readonly UV2Kind: string;
  29667. /**
  29668. * Texture coordinates 3
  29669. */
  29670. static readonly UV3Kind: string;
  29671. /**
  29672. * Texture coordinates 4
  29673. */
  29674. static readonly UV4Kind: string;
  29675. /**
  29676. * Texture coordinates 5
  29677. */
  29678. static readonly UV5Kind: string;
  29679. /**
  29680. * Texture coordinates 6
  29681. */
  29682. static readonly UV6Kind: string;
  29683. /**
  29684. * Colors
  29685. */
  29686. static readonly ColorKind: string;
  29687. /**
  29688. * Matrix indices (for bones)
  29689. */
  29690. static readonly MatricesIndicesKind: string;
  29691. /**
  29692. * Matrix weights (for bones)
  29693. */
  29694. static readonly MatricesWeightsKind: string;
  29695. /**
  29696. * Additional matrix indices (for bones)
  29697. */
  29698. static readonly MatricesIndicesExtraKind: string;
  29699. /**
  29700. * Additional matrix weights (for bones)
  29701. */
  29702. static readonly MatricesWeightsExtraKind: string;
  29703. /**
  29704. * Deduces the stride given a kind.
  29705. * @param kind The kind string to deduce
  29706. * @returns The deduced stride
  29707. */
  29708. static DeduceStride(kind: string): number;
  29709. /**
  29710. * Gets the byte length of the given type.
  29711. * @param type the type
  29712. * @returns the number of bytes
  29713. */
  29714. static GetTypeByteLength(type: number): number;
  29715. /**
  29716. * Enumerates each value of the given parameters as numbers.
  29717. * @param data the data to enumerate
  29718. * @param byteOffset the byte offset of the data
  29719. * @param byteStride the byte stride of the data
  29720. * @param componentCount the number of components per element
  29721. * @param componentType the type of the component
  29722. * @param count the total number of components
  29723. * @param normalized whether the data is normalized
  29724. * @param callback the callback function called for each value
  29725. */
  29726. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29727. private static _GetFloatValue;
  29728. }
  29729. }
  29730. declare module BABYLON {
  29731. /**
  29732. * Defines a target to use with MorphTargetManager
  29733. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29734. */
  29735. class MorphTarget implements IAnimatable {
  29736. /** defines the name of the target */
  29737. name: string;
  29738. /**
  29739. * Gets or sets the list of animations
  29740. */
  29741. animations: Animation[];
  29742. private _scene;
  29743. private _positions;
  29744. private _normals;
  29745. private _tangents;
  29746. private _influence;
  29747. /**
  29748. * Observable raised when the influence changes
  29749. */
  29750. onInfluenceChanged: Observable<boolean>;
  29751. /** @hidden */
  29752. _onDataLayoutChanged: Observable<void>;
  29753. /**
  29754. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29755. */
  29756. influence: number;
  29757. private _animationPropertiesOverride;
  29758. /**
  29759. * Gets or sets the animation properties override
  29760. */
  29761. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29762. /**
  29763. * Creates a new MorphTarget
  29764. * @param name defines the name of the target
  29765. * @param influence defines the influence to use
  29766. */
  29767. constructor(
  29768. /** defines the name of the target */
  29769. name: string, influence?: number, scene?: Nullable<Scene>);
  29770. /**
  29771. * Gets a boolean defining if the target contains position data
  29772. */
  29773. readonly hasPositions: boolean;
  29774. /**
  29775. * Gets a boolean defining if the target contains normal data
  29776. */
  29777. readonly hasNormals: boolean;
  29778. /**
  29779. * Gets a boolean defining if the target contains tangent data
  29780. */
  29781. readonly hasTangents: boolean;
  29782. /**
  29783. * Affects position data to this target
  29784. * @param data defines the position data to use
  29785. */
  29786. setPositions(data: Nullable<FloatArray>): void;
  29787. /**
  29788. * Gets the position data stored in this target
  29789. * @returns a FloatArray containing the position data (or null if not present)
  29790. */
  29791. getPositions(): Nullable<FloatArray>;
  29792. /**
  29793. * Affects normal data to this target
  29794. * @param data defines the normal data to use
  29795. */
  29796. setNormals(data: Nullable<FloatArray>): void;
  29797. /**
  29798. * Gets the normal data stored in this target
  29799. * @returns a FloatArray containing the normal data (or null if not present)
  29800. */
  29801. getNormals(): Nullable<FloatArray>;
  29802. /**
  29803. * Affects tangent data to this target
  29804. * @param data defines the tangent data to use
  29805. */
  29806. setTangents(data: Nullable<FloatArray>): void;
  29807. /**
  29808. * Gets the tangent data stored in this target
  29809. * @returns a FloatArray containing the tangent data (or null if not present)
  29810. */
  29811. getTangents(): Nullable<FloatArray>;
  29812. /**
  29813. * Serializes the current target into a Serialization object
  29814. * @returns the serialized object
  29815. */
  29816. serialize(): any;
  29817. /**
  29818. * Creates a new target from serialized data
  29819. * @param serializationObject defines the serialized data to use
  29820. * @returns a new MorphTarget
  29821. */
  29822. static Parse(serializationObject: any): MorphTarget;
  29823. /**
  29824. * Creates a MorphTarget from mesh data
  29825. * @param mesh defines the source mesh
  29826. * @param name defines the name to use for the new target
  29827. * @param influence defines the influence to attach to the target
  29828. * @returns a new MorphTarget
  29829. */
  29830. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29831. }
  29832. }
  29833. declare module BABYLON {
  29834. /**
  29835. * This class is used to deform meshes using morphing between different targets
  29836. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29837. */
  29838. class MorphTargetManager {
  29839. private _targets;
  29840. private _targetInfluenceChangedObservers;
  29841. private _targetDataLayoutChangedObservers;
  29842. private _activeTargets;
  29843. private _scene;
  29844. private _influences;
  29845. private _supportsNormals;
  29846. private _supportsTangents;
  29847. private _vertexCount;
  29848. private _uniqueId;
  29849. private _tempInfluences;
  29850. /**
  29851. * Creates a new MorphTargetManager
  29852. * @param scene defines the current scene
  29853. */
  29854. constructor(scene?: Nullable<Scene>);
  29855. /**
  29856. * Gets the unique ID of this manager
  29857. */
  29858. readonly uniqueId: number;
  29859. /**
  29860. * Gets the number of vertices handled by this manager
  29861. */
  29862. readonly vertexCount: number;
  29863. /**
  29864. * Gets a boolean indicating if this manager supports morphing of normals
  29865. */
  29866. readonly supportsNormals: boolean;
  29867. /**
  29868. * Gets a boolean indicating if this manager supports morphing of tangents
  29869. */
  29870. readonly supportsTangents: boolean;
  29871. /**
  29872. * Gets the number of targets stored in this manager
  29873. */
  29874. readonly numTargets: number;
  29875. /**
  29876. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29877. */
  29878. readonly numInfluencers: number;
  29879. /**
  29880. * Gets the list of influences (one per target)
  29881. */
  29882. readonly influences: Float32Array;
  29883. /**
  29884. * Gets the active target at specified index. An active target is a target with an influence > 0
  29885. * @param index defines the index to check
  29886. * @returns the requested target
  29887. */
  29888. getActiveTarget(index: number): MorphTarget;
  29889. /**
  29890. * Gets the target at specified index
  29891. * @param index defines the index to check
  29892. * @returns the requested target
  29893. */
  29894. getTarget(index: number): MorphTarget;
  29895. /**
  29896. * Add a new target to this manager
  29897. * @param target defines the target to add
  29898. */
  29899. addTarget(target: MorphTarget): void;
  29900. /**
  29901. * Removes a target from the manager
  29902. * @param target defines the target to remove
  29903. */
  29904. removeTarget(target: MorphTarget): void;
  29905. /**
  29906. * Serializes the current manager into a Serialization object
  29907. * @returns the serialized object
  29908. */
  29909. serialize(): any;
  29910. private _syncActiveTargets;
  29911. /**
  29912. * Syncrhonize the targets with all the meshes using this morph target manager
  29913. */
  29914. synchronize(): void;
  29915. /**
  29916. * Creates a new MorphTargetManager from serialized data
  29917. * @param serializationObject defines the serialized data
  29918. * @param scene defines the hosting scene
  29919. * @returns the new MorphTargetManager
  29920. */
  29921. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29922. }
  29923. }
  29924. declare module BABYLON {
  29925. /**
  29926. * Class used to enable access to IndexedDB
  29927. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29928. */
  29929. class Database implements IOfflineProvider {
  29930. private _callbackManifestChecked;
  29931. private _currentSceneUrl;
  29932. private _db;
  29933. private _enableSceneOffline;
  29934. private _enableTexturesOffline;
  29935. private _manifestVersionFound;
  29936. private _mustUpdateRessources;
  29937. private _hasReachedQuota;
  29938. private _isSupported;
  29939. private _idbFactory;
  29940. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29941. private static IsUASupportingBlobStorage;
  29942. /**
  29943. * Gets a boolean indicating if Database storate is enabled (off by default)
  29944. */
  29945. static IDBStorageEnabled: boolean;
  29946. /**
  29947. * Gets a boolean indicating if scene must be saved in the database
  29948. */
  29949. readonly enableSceneOffline: boolean;
  29950. /**
  29951. * Gets a boolean indicating if textures must be saved in the database
  29952. */
  29953. readonly enableTexturesOffline: boolean;
  29954. /**
  29955. * Creates a new Database
  29956. * @param urlToScene defines the url to load the scene
  29957. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29958. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29959. */
  29960. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29961. private static _ParseURL;
  29962. private static _ReturnFullUrlLocation;
  29963. private _checkManifestFile;
  29964. /**
  29965. * Open the database and make it available
  29966. * @param successCallback defines the callback to call on success
  29967. * @param errorCallback defines the callback to call on error
  29968. */
  29969. open(successCallback: () => void, errorCallback: () => void): void;
  29970. /**
  29971. * Loads an image from the database
  29972. * @param url defines the url to load from
  29973. * @param image defines the target DOM image
  29974. */
  29975. loadImage(url: string, image: HTMLImageElement): void;
  29976. private _loadImageFromDBAsync;
  29977. private _saveImageIntoDBAsync;
  29978. private _checkVersionFromDB;
  29979. private _loadVersionFromDBAsync;
  29980. private _saveVersionIntoDBAsync;
  29981. /**
  29982. * Loads a file from database
  29983. * @param url defines the URL to load from
  29984. * @param sceneLoaded defines a callback to call on success
  29985. * @param progressCallBack defines a callback to call when progress changed
  29986. * @param errorCallback defines a callback to call on error
  29987. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29988. */
  29989. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29990. private _loadFileAsync;
  29991. private _saveFileAsync;
  29992. }
  29993. }
  29994. declare module BABYLON {
  29995. /**
  29996. * Class used to enable access to offline support
  29997. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29998. */
  29999. interface IOfflineProvider {
  30000. /**
  30001. * Gets a boolean indicating if scene must be saved in the database
  30002. */
  30003. enableSceneOffline: boolean;
  30004. /**
  30005. * Gets a boolean indicating if textures must be saved in the database
  30006. */
  30007. enableTexturesOffline: boolean;
  30008. /**
  30009. * Open the offline support and make it available
  30010. * @param successCallback defines the callback to call on success
  30011. * @param errorCallback defines the callback to call on error
  30012. */
  30013. open(successCallback: () => void, errorCallback: () => void): void;
  30014. /**
  30015. * Loads an image from the offline support
  30016. * @param url defines the url to load from
  30017. * @param image defines the target DOM image
  30018. */
  30019. loadImage(url: string, image: HTMLImageElement): void;
  30020. /**
  30021. * Loads a file from offline support
  30022. * @param url defines the URL to load from
  30023. * @param sceneLoaded defines a callback to call on success
  30024. * @param progressCallBack defines a callback to call when progress changed
  30025. * @param errorCallback defines a callback to call on error
  30026. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30027. */
  30028. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30029. }
  30030. }
  30031. declare module BABYLON {
  30032. /**
  30033. * This represents the base class for particle system in Babylon.
  30034. * 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.
  30035. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30036. * @example https://doc.babylonjs.com/babylon101/particles
  30037. */
  30038. class BaseParticleSystem {
  30039. /**
  30040. * Source color is added to the destination color without alpha affecting the result
  30041. */
  30042. static BLENDMODE_ONEONE: number;
  30043. /**
  30044. * Blend current color and particle color using particle’s alpha
  30045. */
  30046. static BLENDMODE_STANDARD: number;
  30047. /**
  30048. * Add current color and particle color multiplied by particle’s alpha
  30049. */
  30050. static BLENDMODE_ADD: number;
  30051. /**
  30052. * Multiply current color with particle color
  30053. */
  30054. static BLENDMODE_MULTIPLY: number;
  30055. /**
  30056. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30057. */
  30058. static BLENDMODE_MULTIPLYADD: number;
  30059. /**
  30060. * List of animations used by the particle system.
  30061. */
  30062. animations: Animation[];
  30063. /**
  30064. * The id of the Particle system.
  30065. */
  30066. id: string;
  30067. /**
  30068. * The friendly name of the Particle system.
  30069. */
  30070. name: string;
  30071. /**
  30072. * The rendering group used by the Particle system to chose when to render.
  30073. */
  30074. renderingGroupId: number;
  30075. /**
  30076. * The emitter represents the Mesh or position we are attaching the particle system to.
  30077. */
  30078. emitter: Nullable<AbstractMesh | Vector3>;
  30079. /**
  30080. * The maximum number of particles to emit per frame
  30081. */
  30082. emitRate: number;
  30083. /**
  30084. * If you want to launch only a few particles at once, that can be done, as well.
  30085. */
  30086. manualEmitCount: number;
  30087. /**
  30088. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30089. */
  30090. updateSpeed: number;
  30091. /**
  30092. * The amount of time the particle system is running (depends of the overall update speed).
  30093. */
  30094. targetStopDuration: number;
  30095. /**
  30096. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30097. */
  30098. disposeOnStop: boolean;
  30099. /**
  30100. * Minimum power of emitting particles.
  30101. */
  30102. minEmitPower: number;
  30103. /**
  30104. * Maximum power of emitting particles.
  30105. */
  30106. maxEmitPower: number;
  30107. /**
  30108. * Minimum life time of emitting particles.
  30109. */
  30110. minLifeTime: number;
  30111. /**
  30112. * Maximum life time of emitting particles.
  30113. */
  30114. maxLifeTime: number;
  30115. /**
  30116. * Minimum Size of emitting particles.
  30117. */
  30118. minSize: number;
  30119. /**
  30120. * Maximum Size of emitting particles.
  30121. */
  30122. maxSize: number;
  30123. /**
  30124. * Minimum scale of emitting particles on X axis.
  30125. */
  30126. minScaleX: number;
  30127. /**
  30128. * Maximum scale of emitting particles on X axis.
  30129. */
  30130. maxScaleX: number;
  30131. /**
  30132. * Minimum scale of emitting particles on Y axis.
  30133. */
  30134. minScaleY: number;
  30135. /**
  30136. * Maximum scale of emitting particles on Y axis.
  30137. */
  30138. maxScaleY: number;
  30139. /**
  30140. * Gets or sets the minimal initial rotation in radians.
  30141. */
  30142. minInitialRotation: number;
  30143. /**
  30144. * Gets or sets the maximal initial rotation in radians.
  30145. */
  30146. maxInitialRotation: number;
  30147. /**
  30148. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30149. */
  30150. minAngularSpeed: number;
  30151. /**
  30152. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30153. */
  30154. maxAngularSpeed: number;
  30155. /**
  30156. * The texture used to render each particle. (this can be a spritesheet)
  30157. */
  30158. particleTexture: Nullable<Texture>;
  30159. /**
  30160. * The layer mask we are rendering the particles through.
  30161. */
  30162. layerMask: number;
  30163. /**
  30164. * This can help using your own shader to render the particle system.
  30165. * The according effect will be created
  30166. */
  30167. customShader: any;
  30168. /**
  30169. * By default particle system starts as soon as they are created. This prevents the
  30170. * automatic start to happen and let you decide when to start emitting particles.
  30171. */
  30172. preventAutoStart: boolean;
  30173. /**
  30174. * Gets or sets a texture used to add random noise to particle positions
  30175. */
  30176. noiseTexture: Nullable<ProceduralTexture>;
  30177. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30178. noiseStrength: Vector3;
  30179. /**
  30180. * Callback triggered when the particle animation is ending.
  30181. */
  30182. onAnimationEnd: Nullable<() => void>;
  30183. /**
  30184. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30185. */
  30186. blendMode: number;
  30187. /**
  30188. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30189. * to override the particles.
  30190. */
  30191. forceDepthWrite: boolean;
  30192. /** 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 */
  30193. preWarmCycles: number;
  30194. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30195. preWarmStepOffset: number;
  30196. /**
  30197. * 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)
  30198. */
  30199. spriteCellChangeSpeed: number;
  30200. /**
  30201. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30202. */
  30203. startSpriteCellID: number;
  30204. /**
  30205. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30206. */
  30207. endSpriteCellID: number;
  30208. /**
  30209. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30210. */
  30211. spriteCellWidth: number;
  30212. /**
  30213. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30214. */
  30215. spriteCellHeight: number;
  30216. /**
  30217. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30218. */
  30219. spriteRandomStartCell: boolean;
  30220. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30221. translationPivot: Vector2;
  30222. /** @hidden */
  30223. protected _isAnimationSheetEnabled: boolean;
  30224. /**
  30225. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30226. */
  30227. beginAnimationOnStart: boolean;
  30228. /**
  30229. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30230. */
  30231. beginAnimationFrom: number;
  30232. /**
  30233. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30234. */
  30235. beginAnimationTo: number;
  30236. /**
  30237. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30238. */
  30239. beginAnimationLoop: boolean;
  30240. /**
  30241. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30242. */
  30243. isAnimationSheetEnabled: boolean;
  30244. /**
  30245. * Get hosting scene
  30246. * @returns the scene
  30247. */
  30248. getScene(): Scene;
  30249. /**
  30250. * You can use gravity if you want to give an orientation to your particles.
  30251. */
  30252. gravity: Vector3;
  30253. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30254. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30255. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30256. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30257. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30258. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30259. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30260. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30261. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30262. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30263. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30264. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30265. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30266. /**
  30267. * Defines the delay in milliseconds before starting the system (0 by default)
  30268. */
  30269. startDelay: number;
  30270. /**
  30271. * Gets the current list of drag gradients.
  30272. * You must use addDragGradient and removeDragGradient to udpate this list
  30273. * @returns the list of drag gradients
  30274. */
  30275. getDragGradients(): Nullable<Array<FactorGradient>>;
  30276. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30277. limitVelocityDamping: number;
  30278. /**
  30279. * Gets the current list of limit velocity gradients.
  30280. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30281. * @returns the list of limit velocity gradients
  30282. */
  30283. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30284. /**
  30285. * Gets the current list of color gradients.
  30286. * You must use addColorGradient and removeColorGradient to udpate this list
  30287. * @returns the list of color gradients
  30288. */
  30289. getColorGradients(): Nullable<Array<ColorGradient>>;
  30290. /**
  30291. * Gets the current list of size gradients.
  30292. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30293. * @returns the list of size gradients
  30294. */
  30295. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30296. /**
  30297. * Gets the current list of color remap gradients.
  30298. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30299. * @returns the list of color remap gradients
  30300. */
  30301. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30302. /**
  30303. * Gets the current list of alpha remap gradients.
  30304. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30305. * @returns the list of alpha remap gradients
  30306. */
  30307. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30308. /**
  30309. * Gets the current list of life time gradients.
  30310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30311. * @returns the list of life time gradients
  30312. */
  30313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30314. /**
  30315. * Gets the current list of angular speed gradients.
  30316. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30317. * @returns the list of angular speed gradients
  30318. */
  30319. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30320. /**
  30321. * Gets the current list of velocity gradients.
  30322. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30323. * @returns the list of velocity gradients
  30324. */
  30325. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30326. /**
  30327. * Gets the current list of start size gradients.
  30328. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30329. * @returns the list of start size gradients
  30330. */
  30331. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30332. /**
  30333. * Gets the current list of emit rate gradients.
  30334. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30335. * @returns the list of emit rate gradients
  30336. */
  30337. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30338. /**
  30339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30340. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30341. */
  30342. direction1: Vector3;
  30343. /**
  30344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30345. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30346. */
  30347. direction2: Vector3;
  30348. /**
  30349. * 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.
  30350. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30351. */
  30352. minEmitBox: Vector3;
  30353. /**
  30354. * 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.
  30355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30356. */
  30357. maxEmitBox: Vector3;
  30358. /**
  30359. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30360. */
  30361. color1: Color4;
  30362. /**
  30363. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30364. */
  30365. color2: Color4;
  30366. /**
  30367. * Color the particle will have at the end of its lifetime
  30368. */
  30369. colorDead: Color4;
  30370. /**
  30371. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30372. */
  30373. textureMask: Color4;
  30374. /**
  30375. * The particle emitter type defines the emitter used by the particle system.
  30376. * It can be for example box, sphere, or cone...
  30377. */
  30378. particleEmitterType: IParticleEmitterType;
  30379. /** @hidden */
  30380. _isSubEmitter: boolean;
  30381. /**
  30382. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30383. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30384. */
  30385. billboardMode: number;
  30386. protected _isBillboardBased: boolean;
  30387. /**
  30388. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30389. */
  30390. isBillboardBased: boolean;
  30391. /**
  30392. * The scene the particle system belongs to.
  30393. */
  30394. protected _scene: Scene;
  30395. /**
  30396. * Local cache of defines for image processing.
  30397. */
  30398. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30399. /**
  30400. * Default configuration related to image processing available in the standard Material.
  30401. */
  30402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30403. /**
  30404. * Gets the image processing configuration used either in this material.
  30405. */
  30406. /**
  30407. * Sets the Default image processing configuration used either in the this material.
  30408. *
  30409. * If sets to null, the scene one is in use.
  30410. */
  30411. imageProcessingConfiguration: ImageProcessingConfiguration;
  30412. /**
  30413. * Attaches a new image processing configuration to the Standard Material.
  30414. * @param configuration
  30415. */
  30416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30417. /** @hidden */
  30418. protected _reset(): void;
  30419. /** @hidden */
  30420. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30421. /**
  30422. * Instantiates a particle system.
  30423. * 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.
  30424. * @param name The name of the particle system
  30425. */
  30426. constructor(name: string);
  30427. /**
  30428. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30429. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30430. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30431. * @returns the emitter
  30432. */
  30433. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30434. /**
  30435. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30436. * @param radius The radius of the hemisphere to emit from
  30437. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30438. * @returns the emitter
  30439. */
  30440. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30441. /**
  30442. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30443. * @param radius The radius of the sphere to emit from
  30444. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30445. * @returns the emitter
  30446. */
  30447. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30448. /**
  30449. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30450. * @param radius The radius of the sphere to emit from
  30451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30453. * @returns the emitter
  30454. */
  30455. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30456. /**
  30457. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30458. * @param radius The radius of the emission cylinder
  30459. * @param height The height of the emission cylinder
  30460. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30461. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30462. * @returns the emitter
  30463. */
  30464. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30465. /**
  30466. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30467. * @param radius The radius of the cylinder to emit from
  30468. * @param height The height of the emission cylinder
  30469. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30472. * @returns the emitter
  30473. */
  30474. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30475. /**
  30476. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30477. * @param radius The radius of the cone to emit from
  30478. * @param angle The base angle of the cone
  30479. * @returns the emitter
  30480. */
  30481. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30482. /**
  30483. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30486. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30487. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30488. * @returns the emitter
  30489. */
  30490. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30491. }
  30492. }
  30493. declare module BABYLON {
  30494. /**
  30495. * This represents a GPU particle system in Babylon
  30496. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30497. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30498. */
  30499. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30500. /**
  30501. * The layer mask we are rendering the particles through.
  30502. */
  30503. layerMask: number;
  30504. private _capacity;
  30505. private _activeCount;
  30506. private _currentActiveCount;
  30507. private _accumulatedCount;
  30508. private _renderEffect;
  30509. private _updateEffect;
  30510. private _buffer0;
  30511. private _buffer1;
  30512. private _spriteBuffer;
  30513. private _updateVAO;
  30514. private _renderVAO;
  30515. private _targetIndex;
  30516. private _sourceBuffer;
  30517. private _targetBuffer;
  30518. private _engine;
  30519. private _currentRenderId;
  30520. private _started;
  30521. private _stopped;
  30522. private _timeDelta;
  30523. private _randomTexture;
  30524. private _randomTexture2;
  30525. private _attributesStrideSize;
  30526. private _updateEffectOptions;
  30527. private _randomTextureSize;
  30528. private _actualFrame;
  30529. private readonly _rawTextureWidth;
  30530. /**
  30531. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30532. */
  30533. static readonly IsSupported: boolean;
  30534. /**
  30535. * An event triggered when the system is disposed.
  30536. */
  30537. onDisposeObservable: Observable<GPUParticleSystem>;
  30538. /**
  30539. * Gets the maximum number of particles active at the same time.
  30540. * @returns The max number of active particles.
  30541. */
  30542. getCapacity(): number;
  30543. /**
  30544. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30545. * to override the particles.
  30546. */
  30547. forceDepthWrite: boolean;
  30548. /**
  30549. * Gets or set the number of active particles
  30550. */
  30551. activeParticleCount: number;
  30552. private _preWarmDone;
  30553. /**
  30554. * Is this system ready to be used/rendered
  30555. * @return true if the system is ready
  30556. */
  30557. isReady(): boolean;
  30558. /**
  30559. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30560. * @returns True if it has been started, otherwise false.
  30561. */
  30562. isStarted(): boolean;
  30563. /**
  30564. * Starts the particle system and begins to emit
  30565. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30566. */
  30567. start(delay?: number): void;
  30568. /**
  30569. * Stops the particle system.
  30570. */
  30571. stop(): void;
  30572. /**
  30573. * Remove all active particles
  30574. */
  30575. reset(): void;
  30576. /**
  30577. * Returns the string "GPUParticleSystem"
  30578. * @returns a string containing the class name
  30579. */
  30580. getClassName(): string;
  30581. private _colorGradientsTexture;
  30582. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30583. /**
  30584. * Adds a new color gradient
  30585. * @param gradient defines the gradient to use (between 0 and 1)
  30586. * @param color1 defines the color to affect to the specified gradient
  30587. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30588. * @returns the current particle system
  30589. */
  30590. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30591. /**
  30592. * Remove a specific color gradient
  30593. * @param gradient defines the gradient to remove
  30594. * @returns the current particle system
  30595. */
  30596. removeColorGradient(gradient: number): GPUParticleSystem;
  30597. private _angularSpeedGradientsTexture;
  30598. private _sizeGradientsTexture;
  30599. private _velocityGradientsTexture;
  30600. private _limitVelocityGradientsTexture;
  30601. private _dragGradientsTexture;
  30602. private _addFactorGradient;
  30603. /**
  30604. * Adds a new size gradient
  30605. * @param gradient defines the gradient to use (between 0 and 1)
  30606. * @param factor defines the size factor to affect to the specified gradient
  30607. * @returns the current particle system
  30608. */
  30609. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30610. /**
  30611. * Remove a specific size gradient
  30612. * @param gradient defines the gradient to remove
  30613. * @returns the current particle system
  30614. */
  30615. removeSizeGradient(gradient: number): GPUParticleSystem;
  30616. /**
  30617. * Adds a new angular speed gradient
  30618. * @param gradient defines the gradient to use (between 0 and 1)
  30619. * @param factor defines the angular speed to affect to the specified gradient
  30620. * @returns the current particle system
  30621. */
  30622. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30623. /**
  30624. * Remove a specific angular speed gradient
  30625. * @param gradient defines the gradient to remove
  30626. * @returns the current particle system
  30627. */
  30628. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30629. /**
  30630. * Adds a new velocity gradient
  30631. * @param gradient defines the gradient to use (between 0 and 1)
  30632. * @param factor defines the velocity to affect to the specified gradient
  30633. * @returns the current particle system
  30634. */
  30635. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30636. /**
  30637. * Remove a specific velocity gradient
  30638. * @param gradient defines the gradient to remove
  30639. * @returns the current particle system
  30640. */
  30641. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30642. /**
  30643. * Adds a new limit velocity gradient
  30644. * @param gradient defines the gradient to use (between 0 and 1)
  30645. * @param factor defines the limit velocity value to affect to the specified gradient
  30646. * @returns the current particle system
  30647. */
  30648. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30649. /**
  30650. * Remove a specific limit velocity gradient
  30651. * @param gradient defines the gradient to remove
  30652. * @returns the current particle system
  30653. */
  30654. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30655. /**
  30656. * Adds a new drag gradient
  30657. * @param gradient defines the gradient to use (between 0 and 1)
  30658. * @param factor defines the drag value to affect to the specified gradient
  30659. * @returns the current particle system
  30660. */
  30661. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30662. /**
  30663. * Remove a specific drag gradient
  30664. * @param gradient defines the gradient to remove
  30665. * @returns the current particle system
  30666. */
  30667. removeDragGradient(gradient: number): GPUParticleSystem;
  30668. /**
  30669. * Not supported by GPUParticleSystem
  30670. * @param gradient defines the gradient to use (between 0 and 1)
  30671. * @param factor defines the emit rate value to affect to the specified gradient
  30672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30673. * @returns the current particle system
  30674. */
  30675. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30676. /**
  30677. * Not supported by GPUParticleSystem
  30678. * @param gradient defines the gradient to remove
  30679. * @returns the current particle system
  30680. */
  30681. removeEmitRateGradient(gradient: number): IParticleSystem;
  30682. /**
  30683. * Not supported by GPUParticleSystem
  30684. * @param gradient defines the gradient to use (between 0 and 1)
  30685. * @param factor defines the start size value to affect to the specified gradient
  30686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30687. * @returns the current particle system
  30688. */
  30689. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30690. /**
  30691. * Not supported by GPUParticleSystem
  30692. * @param gradient defines the gradient to remove
  30693. * @returns the current particle system
  30694. */
  30695. removeStartSizeGradient(gradient: number): IParticleSystem;
  30696. /**
  30697. * Not supported by GPUParticleSystem
  30698. * @param gradient defines the gradient to use (between 0 and 1)
  30699. * @param min defines the color remap minimal range
  30700. * @param max defines the color remap maximal range
  30701. * @returns the current particle system
  30702. */
  30703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30704. /**
  30705. * Not supported by GPUParticleSystem
  30706. * @param gradient defines the gradient to remove
  30707. * @returns the current particle system
  30708. */
  30709. removeColorRemapGradient(gradient: number): IParticleSystem;
  30710. /**
  30711. * Not supported by GPUParticleSystem
  30712. * @param gradient defines the gradient to use (between 0 and 1)
  30713. * @param min defines the alpha remap minimal range
  30714. * @param max defines the alpha remap maximal range
  30715. * @returns the current particle system
  30716. */
  30717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30718. /**
  30719. * Not supported by GPUParticleSystem
  30720. * @param gradient defines the gradient to remove
  30721. * @returns the current particle system
  30722. */
  30723. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30724. /**
  30725. * Not supported by GPUParticleSystem
  30726. * @param gradient defines the gradient to use (between 0 and 1)
  30727. * @param color defines the color to affect to the specified gradient
  30728. * @returns the current particle system
  30729. */
  30730. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30731. /**
  30732. * Not supported by GPUParticleSystem
  30733. * @param gradient defines the gradient to remove
  30734. * @returns the current particle system
  30735. */
  30736. removeRampGradient(gradient: number): IParticleSystem;
  30737. /**
  30738. * Not supported by GPUParticleSystem
  30739. * @returns the list of ramp gradients
  30740. */
  30741. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30742. /**
  30743. * Not supported by GPUParticleSystem
  30744. * Gets or sets a boolean indicating that ramp gradients must be used
  30745. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30746. */
  30747. useRampGradients: boolean;
  30748. /**
  30749. * Not supported by GPUParticleSystem
  30750. * @param gradient defines the gradient to use (between 0 and 1)
  30751. * @param factor defines the life time factor to affect to the specified gradient
  30752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30753. * @returns the current particle system
  30754. */
  30755. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30756. /**
  30757. * Not supported by GPUParticleSystem
  30758. * @param gradient defines the gradient to remove
  30759. * @returns the current particle system
  30760. */
  30761. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30762. /**
  30763. * Instantiates a GPU particle system.
  30764. * 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.
  30765. * @param name The name of the particle system
  30766. * @param options The options used to create the system
  30767. * @param scene The scene the particle system belongs to
  30768. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30769. */
  30770. constructor(name: string, options: Partial<{
  30771. capacity: number;
  30772. randomTextureSize: number;
  30773. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30774. protected _reset(): void;
  30775. private _createUpdateVAO;
  30776. private _createRenderVAO;
  30777. private _initialize;
  30778. /** @hidden */
  30779. _recreateUpdateEffect(): void;
  30780. /** @hidden */
  30781. _recreateRenderEffect(): void;
  30782. /**
  30783. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30784. * @param preWarm defines if we are in the pre-warmimg phase
  30785. */
  30786. animate(preWarm?: boolean): void;
  30787. private _createFactorGradientTexture;
  30788. private _createSizeGradientTexture;
  30789. private _createAngularSpeedGradientTexture;
  30790. private _createVelocityGradientTexture;
  30791. private _createLimitVelocityGradientTexture;
  30792. private _createDragGradientTexture;
  30793. private _createColorGradientTexture;
  30794. /**
  30795. * Renders the particle system in its current state
  30796. * @param preWarm defines if the system should only update the particles but not render them
  30797. * @returns the current number of particles
  30798. */
  30799. render(preWarm?: boolean): number;
  30800. /**
  30801. * Rebuilds the particle system
  30802. */
  30803. rebuild(): void;
  30804. private _releaseBuffers;
  30805. private _releaseVAOs;
  30806. /**
  30807. * Disposes the particle system and free the associated resources
  30808. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30809. */
  30810. dispose(disposeTexture?: boolean): void;
  30811. /**
  30812. * Clones the particle system.
  30813. * @param name The name of the cloned object
  30814. * @param newEmitter The new emitter to use
  30815. * @returns the cloned particle system
  30816. */
  30817. clone(name: string, newEmitter: any): GPUParticleSystem;
  30818. /**
  30819. * Serializes the particle system to a JSON object.
  30820. * @returns the JSON object
  30821. */
  30822. serialize(): any;
  30823. /**
  30824. * Parses a JSON object to create a GPU particle system.
  30825. * @param parsedParticleSystem The JSON object to parse
  30826. * @param scene The scene to create the particle system in
  30827. * @param rootUrl The root url to use to load external dependencies like texture
  30828. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30829. * @returns the parsed GPU particle system
  30830. */
  30831. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30832. }
  30833. }
  30834. declare module BABYLON {
  30835. /**
  30836. * Interface representing a particle system in Babylon.js.
  30837. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30838. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30839. */
  30840. interface IParticleSystem {
  30841. /**
  30842. * List of animations used by the particle system.
  30843. */
  30844. animations: Animation[];
  30845. /**
  30846. * The id of the Particle system.
  30847. */
  30848. id: string;
  30849. /**
  30850. * The name of the Particle system.
  30851. */
  30852. name: string;
  30853. /**
  30854. * The emitter represents the Mesh or position we are attaching the particle system to.
  30855. */
  30856. emitter: Nullable<AbstractMesh | Vector3>;
  30857. /**
  30858. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30859. */
  30860. isBillboardBased: boolean;
  30861. /**
  30862. * The rendering group used by the Particle system to chose when to render.
  30863. */
  30864. renderingGroupId: number;
  30865. /**
  30866. * The layer mask we are rendering the particles through.
  30867. */
  30868. layerMask: number;
  30869. /**
  30870. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30871. */
  30872. updateSpeed: number;
  30873. /**
  30874. * The amount of time the particle system is running (depends of the overall update speed).
  30875. */
  30876. targetStopDuration: number;
  30877. /**
  30878. * The texture used to render each particle. (this can be a spritesheet)
  30879. */
  30880. particleTexture: Nullable<Texture>;
  30881. /**
  30882. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30883. */
  30884. blendMode: number;
  30885. /**
  30886. * Minimum life time of emitting particles.
  30887. */
  30888. minLifeTime: number;
  30889. /**
  30890. * Maximum life time of emitting particles.
  30891. */
  30892. maxLifeTime: number;
  30893. /**
  30894. * Minimum Size of emitting particles.
  30895. */
  30896. minSize: number;
  30897. /**
  30898. * Maximum Size of emitting particles.
  30899. */
  30900. maxSize: number;
  30901. /**
  30902. * Minimum scale of emitting particles on X axis.
  30903. */
  30904. minScaleX: number;
  30905. /**
  30906. * Maximum scale of emitting particles on X axis.
  30907. */
  30908. maxScaleX: number;
  30909. /**
  30910. * Minimum scale of emitting particles on Y axis.
  30911. */
  30912. minScaleY: number;
  30913. /**
  30914. * Maximum scale of emitting particles on Y axis.
  30915. */
  30916. maxScaleY: number;
  30917. /**
  30918. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30919. */
  30920. color1: Color4;
  30921. /**
  30922. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30923. */
  30924. color2: Color4;
  30925. /**
  30926. * Color the particle will have at the end of its lifetime.
  30927. */
  30928. colorDead: Color4;
  30929. /**
  30930. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  30931. */
  30932. emitRate: number;
  30933. /**
  30934. * You can use gravity if you want to give an orientation to your particles.
  30935. */
  30936. gravity: Vector3;
  30937. /**
  30938. * Minimum power of emitting particles.
  30939. */
  30940. minEmitPower: number;
  30941. /**
  30942. * Maximum power of emitting particles.
  30943. */
  30944. maxEmitPower: number;
  30945. /**
  30946. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30947. */
  30948. minAngularSpeed: number;
  30949. /**
  30950. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30951. */
  30952. maxAngularSpeed: number;
  30953. /**
  30954. * Gets or sets the minimal initial rotation in radians.
  30955. */
  30956. minInitialRotation: number;
  30957. /**
  30958. * Gets or sets the maximal initial rotation in radians.
  30959. */
  30960. maxInitialRotation: number;
  30961. /**
  30962. * The particle emitter type defines the emitter used by the particle system.
  30963. * It can be for example box, sphere, or cone...
  30964. */
  30965. particleEmitterType: Nullable<IParticleEmitterType>;
  30966. /**
  30967. * Defines the delay in milliseconds before starting the system (0 by default)
  30968. */
  30969. startDelay: number;
  30970. /**
  30971. * 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
  30972. */
  30973. preWarmCycles: number;
  30974. /**
  30975. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  30976. */
  30977. preWarmStepOffset: number;
  30978. /**
  30979. * 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)
  30980. */
  30981. spriteCellChangeSpeed: number;
  30982. /**
  30983. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30984. */
  30985. startSpriteCellID: number;
  30986. /**
  30987. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30988. */
  30989. endSpriteCellID: number;
  30990. /**
  30991. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30992. */
  30993. spriteCellWidth: number;
  30994. /**
  30995. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30996. */
  30997. spriteCellHeight: number;
  30998. /**
  30999. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31000. */
  31001. spriteRandomStartCell: boolean;
  31002. /**
  31003. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31004. */
  31005. isAnimationSheetEnabled: boolean;
  31006. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31007. translationPivot: Vector2;
  31008. /**
  31009. * Gets or sets a texture used to add random noise to particle positions
  31010. */
  31011. noiseTexture: Nullable<BaseTexture>;
  31012. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31013. noiseStrength: Vector3;
  31014. /**
  31015. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31016. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31017. */
  31018. billboardMode: number;
  31019. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31020. limitVelocityDamping: number;
  31021. /**
  31022. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31023. */
  31024. beginAnimationOnStart: boolean;
  31025. /**
  31026. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31027. */
  31028. beginAnimationFrom: number;
  31029. /**
  31030. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31031. */
  31032. beginAnimationTo: number;
  31033. /**
  31034. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31035. */
  31036. beginAnimationLoop: boolean;
  31037. /**
  31038. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31039. */
  31040. disposeOnStop: boolean;
  31041. /**
  31042. * Gets the maximum number of particles active at the same time.
  31043. * @returns The max number of active particles.
  31044. */
  31045. getCapacity(): number;
  31046. /**
  31047. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31048. * @returns True if it has been started, otherwise false.
  31049. */
  31050. isStarted(): boolean;
  31051. /**
  31052. * Animates the particle system for this frame.
  31053. */
  31054. animate(): void;
  31055. /**
  31056. * Renders the particle system in its current state.
  31057. * @returns the current number of particles
  31058. */
  31059. render(): number;
  31060. /**
  31061. * Dispose the particle system and frees its associated resources.
  31062. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31063. */
  31064. dispose(disposeTexture?: boolean): void;
  31065. /**
  31066. * Clones the particle system.
  31067. * @param name The name of the cloned object
  31068. * @param newEmitter The new emitter to use
  31069. * @returns the cloned particle system
  31070. */
  31071. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31072. /**
  31073. * Serializes the particle system to a JSON object.
  31074. * @returns the JSON object
  31075. */
  31076. serialize(): any;
  31077. /**
  31078. * Rebuild the particle system
  31079. */
  31080. rebuild(): void;
  31081. /**
  31082. * Starts the particle system and begins to emit
  31083. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31084. */
  31085. start(delay?: number): void;
  31086. /**
  31087. * Stops the particle system.
  31088. */
  31089. stop(): void;
  31090. /**
  31091. * Remove all active particles
  31092. */
  31093. reset(): void;
  31094. /**
  31095. * Is this system ready to be used/rendered
  31096. * @return true if the system is ready
  31097. */
  31098. isReady(): boolean;
  31099. /**
  31100. * Adds a new color gradient
  31101. * @param gradient defines the gradient to use (between 0 and 1)
  31102. * @param color1 defines the color to affect to the specified gradient
  31103. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31104. * @returns the current particle system
  31105. */
  31106. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31107. /**
  31108. * Remove a specific color gradient
  31109. * @param gradient defines the gradient to remove
  31110. * @returns the current particle system
  31111. */
  31112. removeColorGradient(gradient: number): IParticleSystem;
  31113. /**
  31114. * Adds a new size gradient
  31115. * @param gradient defines the gradient to use (between 0 and 1)
  31116. * @param factor defines the size factor to affect to the specified gradient
  31117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31118. * @returns the current particle system
  31119. */
  31120. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31121. /**
  31122. * Remove a specific size gradient
  31123. * @param gradient defines the gradient to remove
  31124. * @returns the current particle system
  31125. */
  31126. removeSizeGradient(gradient: number): IParticleSystem;
  31127. /**
  31128. * Gets the current list of color gradients.
  31129. * You must use addColorGradient and removeColorGradient to udpate this list
  31130. * @returns the list of color gradients
  31131. */
  31132. getColorGradients(): Nullable<Array<ColorGradient>>;
  31133. /**
  31134. * Gets the current list of size gradients.
  31135. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31136. * @returns the list of size gradients
  31137. */
  31138. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31139. /**
  31140. * Gets the current list of angular speed gradients.
  31141. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31142. * @returns the list of angular speed gradients
  31143. */
  31144. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31145. /**
  31146. * Adds a new angular speed gradient
  31147. * @param gradient defines the gradient to use (between 0 and 1)
  31148. * @param factor defines the angular speed to affect to the specified gradient
  31149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31150. * @returns the current particle system
  31151. */
  31152. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31153. /**
  31154. * Remove a specific angular speed gradient
  31155. * @param gradient defines the gradient to remove
  31156. * @returns the current particle system
  31157. */
  31158. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31159. /**
  31160. * Gets the current list of velocity gradients.
  31161. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31162. * @returns the list of velocity gradients
  31163. */
  31164. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31165. /**
  31166. * Adds a new velocity gradient
  31167. * @param gradient defines the gradient to use (between 0 and 1)
  31168. * @param factor defines the velocity to affect to the specified gradient
  31169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31170. * @returns the current particle system
  31171. */
  31172. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31173. /**
  31174. * Remove a specific velocity gradient
  31175. * @param gradient defines the gradient to remove
  31176. * @returns the current particle system
  31177. */
  31178. removeVelocityGradient(gradient: number): IParticleSystem;
  31179. /**
  31180. * Gets the current list of limit velocity gradients.
  31181. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31182. * @returns the list of limit velocity gradients
  31183. */
  31184. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31185. /**
  31186. * Adds a new limit velocity gradient
  31187. * @param gradient defines the gradient to use (between 0 and 1)
  31188. * @param factor defines the limit velocity to affect to the specified gradient
  31189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31190. * @returns the current particle system
  31191. */
  31192. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31193. /**
  31194. * Remove a specific limit velocity gradient
  31195. * @param gradient defines the gradient to remove
  31196. * @returns the current particle system
  31197. */
  31198. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31199. /**
  31200. * Adds a new drag gradient
  31201. * @param gradient defines the gradient to use (between 0 and 1)
  31202. * @param factor defines the drag to affect to the specified gradient
  31203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31204. * @returns the current particle system
  31205. */
  31206. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31207. /**
  31208. * Remove a specific drag gradient
  31209. * @param gradient defines the gradient to remove
  31210. * @returns the current particle system
  31211. */
  31212. removeDragGradient(gradient: number): IParticleSystem;
  31213. /**
  31214. * Gets the current list of drag gradients.
  31215. * You must use addDragGradient and removeDragGradient to udpate this list
  31216. * @returns the list of drag gradients
  31217. */
  31218. getDragGradients(): Nullable<Array<FactorGradient>>;
  31219. /**
  31220. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31221. * @param gradient defines the gradient to use (between 0 and 1)
  31222. * @param factor defines the emit rate to affect to the specified gradient
  31223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31224. * @returns the current particle system
  31225. */
  31226. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31227. /**
  31228. * Remove a specific emit rate gradient
  31229. * @param gradient defines the gradient to remove
  31230. * @returns the current particle system
  31231. */
  31232. removeEmitRateGradient(gradient: number): IParticleSystem;
  31233. /**
  31234. * Gets the current list of emit rate gradients.
  31235. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31236. * @returns the list of emit rate gradients
  31237. */
  31238. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31239. /**
  31240. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31241. * @param gradient defines the gradient to use (between 0 and 1)
  31242. * @param factor defines the start size to affect to the specified gradient
  31243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31244. * @returns the current particle system
  31245. */
  31246. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31247. /**
  31248. * Remove a specific start size gradient
  31249. * @param gradient defines the gradient to remove
  31250. * @returns the current particle system
  31251. */
  31252. removeStartSizeGradient(gradient: number): IParticleSystem;
  31253. /**
  31254. * Gets the current list of start size gradients.
  31255. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31256. * @returns the list of start size gradients
  31257. */
  31258. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31259. /**
  31260. * Adds a new life time gradient
  31261. * @param gradient defines the gradient to use (between 0 and 1)
  31262. * @param factor defines the life time factor to affect to the specified gradient
  31263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31264. * @returns the current particle system
  31265. */
  31266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31267. /**
  31268. * Remove a specific life time gradient
  31269. * @param gradient defines the gradient to remove
  31270. * @returns the current particle system
  31271. */
  31272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31273. /**
  31274. * Gets the current list of life time gradients.
  31275. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31276. * @returns the list of life time gradients
  31277. */
  31278. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31279. /**
  31280. * Gets the current list of color gradients.
  31281. * You must use addColorGradient and removeColorGradient to udpate this list
  31282. * @returns the list of color gradients
  31283. */
  31284. getColorGradients(): Nullable<Array<ColorGradient>>;
  31285. /**
  31286. * Adds a new ramp gradient used to remap particle colors
  31287. * @param gradient defines the gradient to use (between 0 and 1)
  31288. * @param color defines the color to affect to the specified gradient
  31289. * @returns the current particle system
  31290. */
  31291. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31292. /**
  31293. * Gets the current list of ramp gradients.
  31294. * You must use addRampGradient and removeRampGradient to udpate this list
  31295. * @returns the list of ramp gradients
  31296. */
  31297. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31298. /** Gets or sets a boolean indicating that ramp gradients must be used
  31299. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31300. */
  31301. useRampGradients: boolean;
  31302. /**
  31303. * Adds a new color remap gradient
  31304. * @param gradient defines the gradient to use (between 0 and 1)
  31305. * @param min defines the color remap minimal range
  31306. * @param max defines the color remap maximal range
  31307. * @returns the current particle system
  31308. */
  31309. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31310. /**
  31311. * Gets the current list of color remap gradients.
  31312. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31313. * @returns the list of color remap gradients
  31314. */
  31315. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31316. /**
  31317. * Adds a new alpha remap gradient
  31318. * @param gradient defines the gradient to use (between 0 and 1)
  31319. * @param min defines the alpha remap minimal range
  31320. * @param max defines the alpha remap maximal range
  31321. * @returns the current particle system
  31322. */
  31323. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31324. /**
  31325. * Gets the current list of alpha remap gradients.
  31326. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31327. * @returns the list of alpha remap gradients
  31328. */
  31329. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31330. /**
  31331. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31334. * @returns the emitter
  31335. */
  31336. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31337. /**
  31338. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31339. * @param radius The radius of the hemisphere to emit from
  31340. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31341. * @returns the emitter
  31342. */
  31343. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31344. /**
  31345. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31346. * @param radius The radius of the sphere to emit from
  31347. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31348. * @returns the emitter
  31349. */
  31350. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31351. /**
  31352. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31353. * @param radius The radius of the sphere to emit from
  31354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31356. * @returns the emitter
  31357. */
  31358. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31359. /**
  31360. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31361. * @param radius The radius of the emission cylinder
  31362. * @param height The height of the emission cylinder
  31363. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31364. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31365. * @returns the emitter
  31366. */
  31367. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31368. /**
  31369. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31370. * @param radius The radius of the cylinder to emit from
  31371. * @param height The height of the emission cylinder
  31372. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31373. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31374. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31375. * @returns the emitter
  31376. */
  31377. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31378. /**
  31379. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31380. * @param radius The radius of the cone to emit from
  31381. * @param angle The base angle of the cone
  31382. * @returns the emitter
  31383. */
  31384. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31385. /**
  31386. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31389. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31390. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31391. * @returns the emitter
  31392. */
  31393. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31394. /**
  31395. * Get hosting scene
  31396. * @returns the scene
  31397. */
  31398. getScene(): Scene;
  31399. }
  31400. }
  31401. declare module BABYLON {
  31402. /**
  31403. * A particle represents one of the element emitted by a particle system.
  31404. * This is mainly define by its coordinates, direction, velocity and age.
  31405. */
  31406. class Particle {
  31407. /**
  31408. * The particle system the particle belongs to.
  31409. */
  31410. particleSystem: ParticleSystem;
  31411. private static _Count;
  31412. /**
  31413. * Unique ID of the particle
  31414. */
  31415. id: number;
  31416. /**
  31417. * The world position of the particle in the scene.
  31418. */
  31419. position: Vector3;
  31420. /**
  31421. * The world direction of the particle in the scene.
  31422. */
  31423. direction: Vector3;
  31424. /**
  31425. * The color of the particle.
  31426. */
  31427. color: Color4;
  31428. /**
  31429. * The color change of the particle per step.
  31430. */
  31431. colorStep: Color4;
  31432. /**
  31433. * Defines how long will the life of the particle be.
  31434. */
  31435. lifeTime: number;
  31436. /**
  31437. * The current age of the particle.
  31438. */
  31439. age: number;
  31440. /**
  31441. * The current size of the particle.
  31442. */
  31443. size: number;
  31444. /**
  31445. * The current scale of the particle.
  31446. */
  31447. scale: Vector2;
  31448. /**
  31449. * The current angle of the particle.
  31450. */
  31451. angle: number;
  31452. /**
  31453. * Defines how fast is the angle changing.
  31454. */
  31455. angularSpeed: number;
  31456. /**
  31457. * Defines the cell index used by the particle to be rendered from a sprite.
  31458. */
  31459. cellIndex: number;
  31460. /**
  31461. * The information required to support color remapping
  31462. */
  31463. remapData: Vector4;
  31464. /** @hidden */
  31465. _randomCellOffset?: number;
  31466. /** @hidden */
  31467. _initialDirection: Nullable<Vector3>;
  31468. /** @hidden */
  31469. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31470. /** @hidden */
  31471. _initialStartSpriteCellID: number;
  31472. /** @hidden */
  31473. _initialEndSpriteCellID: number;
  31474. /** @hidden */
  31475. _currentColorGradient: Nullable<ColorGradient>;
  31476. /** @hidden */
  31477. _currentColor1: Color4;
  31478. /** @hidden */
  31479. _currentColor2: Color4;
  31480. /** @hidden */
  31481. _currentSizeGradient: Nullable<FactorGradient>;
  31482. /** @hidden */
  31483. _currentSize1: number;
  31484. /** @hidden */
  31485. _currentSize2: number;
  31486. /** @hidden */
  31487. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31488. /** @hidden */
  31489. _currentAngularSpeed1: number;
  31490. /** @hidden */
  31491. _currentAngularSpeed2: number;
  31492. /** @hidden */
  31493. _currentVelocityGradient: Nullable<FactorGradient>;
  31494. /** @hidden */
  31495. _currentVelocity1: number;
  31496. /** @hidden */
  31497. _currentVelocity2: number;
  31498. /** @hidden */
  31499. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31500. /** @hidden */
  31501. _currentLimitVelocity1: number;
  31502. /** @hidden */
  31503. _currentLimitVelocity2: number;
  31504. /** @hidden */
  31505. _currentDragGradient: Nullable<FactorGradient>;
  31506. /** @hidden */
  31507. _currentDrag1: number;
  31508. /** @hidden */
  31509. _currentDrag2: number;
  31510. /** @hidden */
  31511. _randomNoiseCoordinates1: Vector3;
  31512. /** @hidden */
  31513. _randomNoiseCoordinates2: Vector3;
  31514. /**
  31515. * Creates a new instance Particle
  31516. * @param particleSystem the particle system the particle belongs to
  31517. */
  31518. constructor(
  31519. /**
  31520. * The particle system the particle belongs to.
  31521. */
  31522. particleSystem: ParticleSystem);
  31523. private updateCellInfoFromSystem;
  31524. /**
  31525. * Defines how the sprite cell index is updated for the particle
  31526. */
  31527. updateCellIndex(): void;
  31528. /** @hidden */
  31529. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31530. /** @hidden */
  31531. _inheritParticleInfoToSubEmitters(): void;
  31532. /** @hidden */
  31533. _reset(): void;
  31534. /**
  31535. * Copy the properties of particle to another one.
  31536. * @param other the particle to copy the information to.
  31537. */
  31538. copyTo(other: Particle): void;
  31539. }
  31540. }
  31541. declare module BABYLON {
  31542. /**
  31543. * This class is made for on one-liner static method to help creating particle system set.
  31544. */
  31545. class ParticleHelper {
  31546. /**
  31547. * Gets or sets base Assets URL
  31548. */
  31549. static BaseAssetsUrl: string;
  31550. /**
  31551. * Create a default particle system that you can tweak
  31552. * @param emitter defines the emitter to use
  31553. * @param capacity defines the system capacity (default is 500 particles)
  31554. * @param scene defines the hosting scene
  31555. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31556. * @returns the new Particle system
  31557. */
  31558. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31559. /**
  31560. * This is the main static method (one-liner) of this helper to create different particle systems
  31561. * @param type This string represents the type to the particle system to create
  31562. * @param scene The scene where the particle system should live
  31563. * @param gpu If the system will use gpu
  31564. * @returns the ParticleSystemSet created
  31565. */
  31566. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31567. /**
  31568. * Static function used to export a particle system to a ParticleSystemSet variable.
  31569. * Please note that the emitter shape is not exported
  31570. * @param systems defines the particle systems to export
  31571. * @returns the created particle system set
  31572. */
  31573. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31574. }
  31575. }
  31576. declare module BABYLON {
  31577. /**
  31578. * This represents a particle system in Babylon.
  31579. * 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.
  31580. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31581. * @example https://doc.babylonjs.com/babylon101/particles
  31582. */
  31583. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31584. /**
  31585. * Billboard mode will only apply to Y axis
  31586. */
  31587. static readonly BILLBOARDMODE_Y: number;
  31588. /**
  31589. * Billboard mode will apply to all axes
  31590. */
  31591. static readonly BILLBOARDMODE_ALL: number;
  31592. /**
  31593. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31594. */
  31595. static readonly BILLBOARDMODE_STRETCHED: number;
  31596. /**
  31597. * This function can be defined to provide custom update for active particles.
  31598. * This function will be called instead of regular update (age, position, color, etc.).
  31599. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31600. */
  31601. updateFunction: (particles: Particle[]) => void;
  31602. private _emitterWorldMatrix;
  31603. /**
  31604. * This function can be defined to specify initial direction for every new particle.
  31605. * It by default use the emitterType defined function
  31606. */
  31607. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31608. /**
  31609. * This function can be defined to specify initial position for every new particle.
  31610. * It by default use the emitterType defined function
  31611. */
  31612. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31613. /**
  31614. * @hidden
  31615. */
  31616. _inheritedVelocityOffset: Vector3;
  31617. /**
  31618. * An event triggered when the system is disposed
  31619. */
  31620. onDisposeObservable: Observable<ParticleSystem>;
  31621. private _onDisposeObserver;
  31622. /**
  31623. * Sets a callback that will be triggered when the system is disposed
  31624. */
  31625. onDispose: () => void;
  31626. private _particles;
  31627. private _epsilon;
  31628. private _capacity;
  31629. private _stockParticles;
  31630. private _newPartsExcess;
  31631. private _vertexData;
  31632. private _vertexBuffer;
  31633. private _vertexBuffers;
  31634. private _spriteBuffer;
  31635. private _indexBuffer;
  31636. private _effect;
  31637. private _customEffect;
  31638. private _cachedDefines;
  31639. private _scaledColorStep;
  31640. private _colorDiff;
  31641. private _scaledDirection;
  31642. private _scaledGravity;
  31643. private _currentRenderId;
  31644. private _alive;
  31645. private _useInstancing;
  31646. private _started;
  31647. private _stopped;
  31648. private _actualFrame;
  31649. private _scaledUpdateSpeed;
  31650. private _vertexBufferSize;
  31651. /** @hidden */
  31652. _currentEmitRateGradient: Nullable<FactorGradient>;
  31653. /** @hidden */
  31654. _currentEmitRate1: number;
  31655. /** @hidden */
  31656. _currentEmitRate2: number;
  31657. /** @hidden */
  31658. _currentStartSizeGradient: Nullable<FactorGradient>;
  31659. /** @hidden */
  31660. _currentStartSize1: number;
  31661. /** @hidden */
  31662. _currentStartSize2: number;
  31663. private readonly _rawTextureWidth;
  31664. private _rampGradientsTexture;
  31665. private _useRampGradients;
  31666. /** Gets or sets a boolean indicating that ramp gradients must be used
  31667. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31668. */
  31669. useRampGradients: boolean;
  31670. /**
  31671. * 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.
  31672. * 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: [])
  31673. */
  31674. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31675. private _subEmitters;
  31676. /**
  31677. * @hidden
  31678. * If the particle systems emitter should be disposed when the particle system is disposed
  31679. */
  31680. _disposeEmitterOnDispose: boolean;
  31681. /**
  31682. * The current active Sub-systems, this property is used by the root particle system only.
  31683. */
  31684. activeSubSystems: Array<ParticleSystem>;
  31685. private _rootParticleSystem;
  31686. /**
  31687. * Gets the current list of active particles
  31688. */
  31689. readonly particles: Particle[];
  31690. /**
  31691. * Returns the string "ParticleSystem"
  31692. * @returns a string containing the class name
  31693. */
  31694. getClassName(): string;
  31695. /**
  31696. * Instantiates a particle system.
  31697. * 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.
  31698. * @param name The name of the particle system
  31699. * @param capacity The max number of particles alive at the same time
  31700. * @param scene The scene the particle system belongs to
  31701. * @param customEffect a custom effect used to change the way particles are rendered by default
  31702. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31703. * @param epsilon Offset used to render the particles
  31704. */
  31705. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31706. private _addFactorGradient;
  31707. private _removeFactorGradient;
  31708. /**
  31709. * Adds a new life time gradient
  31710. * @param gradient defines the gradient to use (between 0 and 1)
  31711. * @param factor defines the life time factor to affect to the specified gradient
  31712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31713. * @returns the current particle system
  31714. */
  31715. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31716. /**
  31717. * Remove a specific life time gradient
  31718. * @param gradient defines the gradient to remove
  31719. * @returns the current particle system
  31720. */
  31721. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31722. /**
  31723. * Adds a new size gradient
  31724. * @param gradient defines the gradient to use (between 0 and 1)
  31725. * @param factor defines the size factor to affect to the specified gradient
  31726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31727. * @returns the current particle system
  31728. */
  31729. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31730. /**
  31731. * Remove a specific size gradient
  31732. * @param gradient defines the gradient to remove
  31733. * @returns the current particle system
  31734. */
  31735. removeSizeGradient(gradient: number): IParticleSystem;
  31736. /**
  31737. * Adds a new color remap gradient
  31738. * @param gradient defines the gradient to use (between 0 and 1)
  31739. * @param min defines the color remap minimal range
  31740. * @param max defines the color remap maximal range
  31741. * @returns the current particle system
  31742. */
  31743. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31744. /**
  31745. * Remove a specific color remap gradient
  31746. * @param gradient defines the gradient to remove
  31747. * @returns the current particle system
  31748. */
  31749. removeColorRemapGradient(gradient: number): IParticleSystem;
  31750. /**
  31751. * Adds a new alpha remap gradient
  31752. * @param gradient defines the gradient to use (between 0 and 1)
  31753. * @param min defines the alpha remap minimal range
  31754. * @param max defines the alpha remap maximal range
  31755. * @returns the current particle system
  31756. */
  31757. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31758. /**
  31759. * Remove a specific alpha remap gradient
  31760. * @param gradient defines the gradient to remove
  31761. * @returns the current particle system
  31762. */
  31763. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31764. /**
  31765. * Adds a new angular speed gradient
  31766. * @param gradient defines the gradient to use (between 0 and 1)
  31767. * @param factor defines the angular speed to affect to the specified gradient
  31768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31769. * @returns the current particle system
  31770. */
  31771. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31772. /**
  31773. * Remove a specific angular speed gradient
  31774. * @param gradient defines the gradient to remove
  31775. * @returns the current particle system
  31776. */
  31777. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31778. /**
  31779. * Adds a new velocity gradient
  31780. * @param gradient defines the gradient to use (between 0 and 1)
  31781. * @param factor defines the velocity to affect to the specified gradient
  31782. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31783. * @returns the current particle system
  31784. */
  31785. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31786. /**
  31787. * Remove a specific velocity gradient
  31788. * @param gradient defines the gradient to remove
  31789. * @returns the current particle system
  31790. */
  31791. removeVelocityGradient(gradient: number): IParticleSystem;
  31792. /**
  31793. * Adds a new limit velocity gradient
  31794. * @param gradient defines the gradient to use (between 0 and 1)
  31795. * @param factor defines the limit velocity value to affect to the specified gradient
  31796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31797. * @returns the current particle system
  31798. */
  31799. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31800. /**
  31801. * Remove a specific limit velocity gradient
  31802. * @param gradient defines the gradient to remove
  31803. * @returns the current particle system
  31804. */
  31805. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31806. /**
  31807. * Adds a new drag gradient
  31808. * @param gradient defines the gradient to use (between 0 and 1)
  31809. * @param factor defines the drag value to affect to the specified gradient
  31810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31811. * @returns the current particle system
  31812. */
  31813. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31814. /**
  31815. * Remove a specific drag gradient
  31816. * @param gradient defines the gradient to remove
  31817. * @returns the current particle system
  31818. */
  31819. removeDragGradient(gradient: number): IParticleSystem;
  31820. /**
  31821. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31822. * @param gradient defines the gradient to use (between 0 and 1)
  31823. * @param factor defines the emit rate value to affect to the specified gradient
  31824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31825. * @returns the current particle system
  31826. */
  31827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31828. /**
  31829. * Remove a specific emit rate gradient
  31830. * @param gradient defines the gradient to remove
  31831. * @returns the current particle system
  31832. */
  31833. removeEmitRateGradient(gradient: number): IParticleSystem;
  31834. /**
  31835. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31836. * @param gradient defines the gradient to use (between 0 and 1)
  31837. * @param factor defines the start size value to affect to the specified gradient
  31838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31839. * @returns the current particle system
  31840. */
  31841. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31842. /**
  31843. * Remove a specific start size gradient
  31844. * @param gradient defines the gradient to remove
  31845. * @returns the current particle system
  31846. */
  31847. removeStartSizeGradient(gradient: number): IParticleSystem;
  31848. private _createRampGradientTexture;
  31849. /**
  31850. * Gets the current list of ramp gradients.
  31851. * You must use addRampGradient and removeRampGradient to udpate this list
  31852. * @returns the list of ramp gradients
  31853. */
  31854. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31855. /**
  31856. * Adds a new ramp gradient used to remap particle colors
  31857. * @param gradient defines the gradient to use (between 0 and 1)
  31858. * @param color defines the color to affect to the specified gradient
  31859. * @returns the current particle system
  31860. */
  31861. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31862. /**
  31863. * Remove a specific ramp gradient
  31864. * @param gradient defines the gradient to remove
  31865. * @returns the current particle system
  31866. */
  31867. removeRampGradient(gradient: number): ParticleSystem;
  31868. /**
  31869. * Adds a new color gradient
  31870. * @param gradient defines the gradient to use (between 0 and 1)
  31871. * @param color1 defines the color to affect to the specified gradient
  31872. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31873. * @returns this particle system
  31874. */
  31875. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31876. /**
  31877. * Remove a specific color gradient
  31878. * @param gradient defines the gradient to remove
  31879. * @returns this particle system
  31880. */
  31881. removeColorGradient(gradient: number): IParticleSystem;
  31882. private _fetchR;
  31883. protected _reset(): void;
  31884. private _resetEffect;
  31885. private _createVertexBuffers;
  31886. private _createIndexBuffer;
  31887. /**
  31888. * Gets the maximum number of particles active at the same time.
  31889. * @returns The max number of active particles.
  31890. */
  31891. getCapacity(): number;
  31892. /**
  31893. * Gets whether there are still active particles in the system.
  31894. * @returns True if it is alive, otherwise false.
  31895. */
  31896. isAlive(): boolean;
  31897. /**
  31898. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31899. * @returns True if it has been started, otherwise false.
  31900. */
  31901. isStarted(): boolean;
  31902. private _prepareSubEmitterInternalArray;
  31903. /**
  31904. * Starts the particle system and begins to emit
  31905. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31906. */
  31907. start(delay?: number): void;
  31908. /**
  31909. * Stops the particle system.
  31910. * @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.
  31911. */
  31912. stop(stopSubEmitters?: boolean): void;
  31913. /**
  31914. * Remove all active particles
  31915. */
  31916. reset(): void;
  31917. /**
  31918. * @hidden (for internal use only)
  31919. */
  31920. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  31921. /**
  31922. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  31923. * Its lifetime will start back at 0.
  31924. */
  31925. recycleParticle: (particle: Particle) => void;
  31926. private _stopSubEmitters;
  31927. private _createParticle;
  31928. private _removeFromRoot;
  31929. private _emitFromParticle;
  31930. private _update;
  31931. /** @hidden */
  31932. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  31933. /** @hidden */
  31934. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  31935. /** @hidden */
  31936. private _getEffect;
  31937. /**
  31938. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31939. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  31940. */
  31941. animate(preWarmOnly?: boolean): void;
  31942. private _appendParticleVertices;
  31943. /**
  31944. * Rebuilds the particle system.
  31945. */
  31946. rebuild(): void;
  31947. /**
  31948. * Is this system ready to be used/rendered
  31949. * @return true if the system is ready
  31950. */
  31951. isReady(): boolean;
  31952. private _render;
  31953. /**
  31954. * Renders the particle system in its current state.
  31955. * @returns the current number of particles
  31956. */
  31957. render(): number;
  31958. /**
  31959. * Disposes the particle system and free the associated resources
  31960. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31961. */
  31962. dispose(disposeTexture?: boolean): void;
  31963. /**
  31964. * Clones the particle system.
  31965. * @param name The name of the cloned object
  31966. * @param newEmitter The new emitter to use
  31967. * @returns the cloned particle system
  31968. */
  31969. clone(name: string, newEmitter: any): ParticleSystem;
  31970. /**
  31971. * Serializes the particle system to a JSON object.
  31972. * @returns the JSON object
  31973. */
  31974. serialize(): any;
  31975. /** @hidden */
  31976. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  31977. /** @hidden */
  31978. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  31979. /**
  31980. * Parses a JSON object to create a particle system.
  31981. * @param parsedParticleSystem The JSON object to parse
  31982. * @param scene The scene to create the particle system in
  31983. * @param rootUrl The root url to use to load external dependencies like texture
  31984. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31985. * @returns the Parsed particle system
  31986. */
  31987. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  31988. }
  31989. }
  31990. declare module BABYLON {
  31991. interface Engine {
  31992. /**
  31993. * Create an effect to use with particle systems.
  31994. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  31995. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  31996. * @param uniformsNames defines a list of attribute names
  31997. * @param samplers defines an array of string used to represent textures
  31998. * @param defines defines the string containing the defines to use to compile the shaders
  31999. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32000. * @param onCompiled defines a function to call when the effect creation is successful
  32001. * @param onError defines a function to call when the effect creation has failed
  32002. * @returns the new Effect
  32003. */
  32004. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32005. }
  32006. interface Mesh {
  32007. /**
  32008. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32009. * @returns an array of IParticleSystem
  32010. */
  32011. getEmittedParticleSystems(): IParticleSystem[];
  32012. /**
  32013. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32014. * @returns an array of IParticleSystem
  32015. */
  32016. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32017. }
  32018. }
  32019. declare module BABYLON {
  32020. /**
  32021. * Represents a set of particle systems working together to create a specific effect
  32022. */
  32023. class ParticleSystemSet implements IDisposable {
  32024. private _emitterCreationOptions;
  32025. private _emitterNode;
  32026. /**
  32027. * Gets the particle system list
  32028. */
  32029. systems: IParticleSystem[];
  32030. /**
  32031. * Gets the emitter node used with this set
  32032. */
  32033. readonly emitterNode: Nullable<TransformNode>;
  32034. /**
  32035. * Creates a new emitter mesh as a sphere
  32036. * @param options defines the options used to create the sphere
  32037. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32038. * @param scene defines the hosting scene
  32039. */
  32040. setEmitterAsSphere(options: {
  32041. diameter: number;
  32042. segments: number;
  32043. color: Color3;
  32044. }, renderingGroupId: number, scene: Scene): void;
  32045. /**
  32046. * Starts all particle systems of the set
  32047. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32048. */
  32049. start(emitter?: AbstractMesh): void;
  32050. /**
  32051. * Release all associated resources
  32052. */
  32053. dispose(): void;
  32054. /**
  32055. * Serialize the set into a JSON compatible object
  32056. * @returns a JSON compatible representation of the set
  32057. */
  32058. serialize(): any;
  32059. /**
  32060. * Parse a new ParticleSystemSet from a serialized source
  32061. * @param data defines a JSON compatible representation of the set
  32062. * @param scene defines the hosting scene
  32063. * @param gpu defines if we want GPU particles or CPU particles
  32064. * @returns a new ParticleSystemSet
  32065. */
  32066. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32067. }
  32068. }
  32069. declare module BABYLON {
  32070. /**
  32071. * Represents one particle of a solid particle system.
  32072. */
  32073. class SolidParticle {
  32074. /**
  32075. * particle global index
  32076. */
  32077. idx: number;
  32078. /**
  32079. * The color of the particle
  32080. */
  32081. color: Nullable<Color4>;
  32082. /**
  32083. * The world space position of the particle.
  32084. */
  32085. position: Vector3;
  32086. /**
  32087. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32088. */
  32089. rotation: Vector3;
  32090. /**
  32091. * The world space rotation quaternion of the particle.
  32092. */
  32093. rotationQuaternion: Nullable<Quaternion>;
  32094. /**
  32095. * The scaling of the particle.
  32096. */
  32097. scaling: Vector3;
  32098. /**
  32099. * The uvs of the particle.
  32100. */
  32101. uvs: Vector4;
  32102. /**
  32103. * The current speed of the particle.
  32104. */
  32105. velocity: Vector3;
  32106. /**
  32107. * The pivot point in the particle local space.
  32108. */
  32109. pivot: Vector3;
  32110. /**
  32111. * Must the particle be translated from its pivot point in its local space ?
  32112. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32113. * Default : false
  32114. */
  32115. translateFromPivot: boolean;
  32116. /**
  32117. * Is the particle active or not ?
  32118. */
  32119. alive: boolean;
  32120. /**
  32121. * Is the particle visible or not ?
  32122. */
  32123. isVisible: boolean;
  32124. /**
  32125. * Index of this particle in the global "positions" array (Internal use)
  32126. * @hidden
  32127. */
  32128. _pos: number;
  32129. /**
  32130. * @hidden Index of this particle in the global "indices" array (Internal use)
  32131. */
  32132. _ind: number;
  32133. /**
  32134. * @hidden ModelShape of this particle (Internal use)
  32135. */
  32136. _model: ModelShape;
  32137. /**
  32138. * ModelShape id of this particle
  32139. */
  32140. shapeId: number;
  32141. /**
  32142. * Index of the particle in its shape id (Internal use)
  32143. */
  32144. idxInShape: number;
  32145. /**
  32146. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32147. */
  32148. _modelBoundingInfo: BoundingInfo;
  32149. /**
  32150. * @hidden Particle BoundingInfo object (Internal use)
  32151. */
  32152. _boundingInfo: BoundingInfo;
  32153. /**
  32154. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32155. */
  32156. _sps: SolidParticleSystem;
  32157. /**
  32158. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32159. */
  32160. _stillInvisible: boolean;
  32161. /**
  32162. * @hidden Last computed particle rotation matrix
  32163. */
  32164. _rotationMatrix: number[];
  32165. /**
  32166. * Parent particle Id, if any.
  32167. * Default null.
  32168. */
  32169. parentId: Nullable<number>;
  32170. /**
  32171. * @hidden Internal global position in the SPS.
  32172. */
  32173. _globalPosition: Vector3;
  32174. /**
  32175. * Creates a Solid Particle object.
  32176. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32177. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32178. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32179. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32180. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32181. * @param shapeId (integer) is the model shape identifier in the SPS.
  32182. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32183. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32184. */
  32185. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32186. /**
  32187. * Legacy support, changed scale to scaling
  32188. */
  32189. /**
  32190. * Legacy support, changed scale to scaling
  32191. */
  32192. scale: Vector3;
  32193. /**
  32194. * Legacy support, changed quaternion to rotationQuaternion
  32195. */
  32196. /**
  32197. * Legacy support, changed quaternion to rotationQuaternion
  32198. */
  32199. quaternion: Nullable<Quaternion>;
  32200. /**
  32201. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32202. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32203. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32204. * @returns true if it intersects
  32205. */
  32206. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32207. /**
  32208. * get the rotation matrix of the particle
  32209. * @hidden
  32210. */
  32211. getRotationMatrix(m: Matrix): void;
  32212. }
  32213. /**
  32214. * Represents the shape of the model used by one particle of a solid particle system.
  32215. * SPS internal tool, don't use it manually.
  32216. */
  32217. class ModelShape {
  32218. /**
  32219. * The shape id
  32220. * @hidden
  32221. */
  32222. shapeID: number;
  32223. /**
  32224. * flat array of model positions (internal use)
  32225. * @hidden
  32226. */
  32227. _shape: Vector3[];
  32228. /**
  32229. * flat array of model UVs (internal use)
  32230. * @hidden
  32231. */
  32232. _shapeUV: number[];
  32233. /**
  32234. * length of the shape in the model indices array (internal use)
  32235. * @hidden
  32236. */
  32237. _indicesLength: number;
  32238. /**
  32239. * Custom position function (internal use)
  32240. * @hidden
  32241. */
  32242. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32243. /**
  32244. * Custom vertex function (internal use)
  32245. * @hidden
  32246. */
  32247. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32248. /**
  32249. * 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.
  32250. * SPS internal tool, don't use it manually.
  32251. * @hidden
  32252. */
  32253. 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>);
  32254. }
  32255. /**
  32256. * Represents a Depth Sorted Particle in the solid particle system.
  32257. */
  32258. class DepthSortedParticle {
  32259. /**
  32260. * Index of the particle in the "indices" array
  32261. */
  32262. ind: number;
  32263. /**
  32264. * Length of the particle shape in the "indices" array
  32265. */
  32266. indicesLength: number;
  32267. /**
  32268. * Squared distance from the particle to the camera
  32269. */
  32270. sqDistance: number;
  32271. }
  32272. }
  32273. declare module BABYLON {
  32274. /**
  32275. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32276. *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.
  32277. * The SPS is also a particle system. It provides some methods to manage the particles.
  32278. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32279. *
  32280. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32281. */
  32282. class SolidParticleSystem implements IDisposable {
  32283. /**
  32284. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32285. * Example : var p = SPS.particles[i];
  32286. */
  32287. particles: SolidParticle[];
  32288. /**
  32289. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32290. */
  32291. nbParticles: number;
  32292. /**
  32293. * If the particles must ever face the camera (default false). Useful for planar particles.
  32294. */
  32295. billboard: boolean;
  32296. /**
  32297. * Recompute normals when adding a shape
  32298. */
  32299. recomputeNormals: boolean;
  32300. /**
  32301. * This a counter ofr your own usage. It's not set by any SPS functions.
  32302. */
  32303. counter: number;
  32304. /**
  32305. * The SPS name. This name is also given to the underlying mesh.
  32306. */
  32307. name: string;
  32308. /**
  32309. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32310. */
  32311. mesh: Mesh;
  32312. /**
  32313. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32314. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32315. */
  32316. vars: any;
  32317. /**
  32318. * This array is populated when the SPS is set as 'pickable'.
  32319. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32320. * Each element of this array is an object `{idx: int, faceId: int}`.
  32321. * `idx` is the picked particle index in the `SPS.particles` array
  32322. * `faceId` is the picked face index counted within this particle.
  32323. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32324. */
  32325. pickedParticles: {
  32326. idx: number;
  32327. faceId: number;
  32328. }[];
  32329. /**
  32330. * This array is populated when `enableDepthSort` is set to true.
  32331. * Each element of this array is an instance of the class DepthSortedParticle.
  32332. */
  32333. depthSortedParticles: DepthSortedParticle[];
  32334. /**
  32335. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32336. * @hidden
  32337. */
  32338. _bSphereOnly: boolean;
  32339. /**
  32340. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32341. * @hidden
  32342. */
  32343. _bSphereRadiusFactor: number;
  32344. private _scene;
  32345. private _positions;
  32346. private _indices;
  32347. private _normals;
  32348. private _colors;
  32349. private _uvs;
  32350. private _indices32;
  32351. private _positions32;
  32352. private _normals32;
  32353. private _fixedNormal32;
  32354. private _colors32;
  32355. private _uvs32;
  32356. private _index;
  32357. private _updatable;
  32358. private _pickable;
  32359. private _isVisibilityBoxLocked;
  32360. private _alwaysVisible;
  32361. private _depthSort;
  32362. private _shapeCounter;
  32363. private _copy;
  32364. private _color;
  32365. private _computeParticleColor;
  32366. private _computeParticleTexture;
  32367. private _computeParticleRotation;
  32368. private _computeParticleVertex;
  32369. private _computeBoundingBox;
  32370. private _depthSortParticles;
  32371. private _camera;
  32372. private _mustUnrotateFixedNormals;
  32373. private _particlesIntersect;
  32374. private _needs32Bits;
  32375. /**
  32376. * Creates a SPS (Solid Particle System) object.
  32377. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32378. * @param scene (Scene) is the scene in which the SPS is added.
  32379. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32380. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32381. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32382. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32383. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32384. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32385. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32386. */
  32387. constructor(name: string, scene: Scene, options?: {
  32388. updatable?: boolean;
  32389. isPickable?: boolean;
  32390. enableDepthSort?: boolean;
  32391. particleIntersection?: boolean;
  32392. boundingSphereOnly?: boolean;
  32393. bSphereRadiusFactor?: number;
  32394. });
  32395. /**
  32396. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32397. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32398. * @returns the created mesh
  32399. */
  32400. buildMesh(): Mesh;
  32401. /**
  32402. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32403. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32404. * Thus the particles generated from `digest()` have their property `position` set yet.
  32405. * @param mesh ( Mesh ) is the mesh to be digested
  32406. * @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
  32407. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32408. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32409. * @returns the current SPS
  32410. */
  32411. digest(mesh: Mesh, options?: {
  32412. facetNb?: number;
  32413. number?: number;
  32414. delta?: number;
  32415. }): SolidParticleSystem;
  32416. private _unrotateFixedNormals;
  32417. private _resetCopy;
  32418. private _meshBuilder;
  32419. private _posToShape;
  32420. private _uvsToShapeUV;
  32421. private _addParticle;
  32422. /**
  32423. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32424. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32425. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32426. * @param nb (positive integer) the number of particles to be created from this model
  32427. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32428. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32429. * @returns the number of shapes in the system
  32430. */
  32431. addShape(mesh: Mesh, nb: number, options?: {
  32432. positionFunction?: any;
  32433. vertexFunction?: any;
  32434. }): number;
  32435. private _rebuildParticle;
  32436. /**
  32437. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32438. * @returns the SPS.
  32439. */
  32440. rebuildMesh(): SolidParticleSystem;
  32441. /**
  32442. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32443. * This method calls `updateParticle()` for each particle of the SPS.
  32444. * For an animated SPS, it is usually called within the render loop.
  32445. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32446. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32447. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32448. * @returns the SPS.
  32449. */
  32450. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32451. /**
  32452. * Disposes the SPS.
  32453. */
  32454. dispose(): void;
  32455. /**
  32456. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32457. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32458. * @returns the SPS.
  32459. */
  32460. refreshVisibleSize(): SolidParticleSystem;
  32461. /**
  32462. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32463. * @param size the size (float) of the visibility box
  32464. * note : this doesn't lock the SPS mesh bounding box.
  32465. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32466. */
  32467. setVisibilityBox(size: number): void;
  32468. /**
  32469. * Gets whether the SPS as always visible or not
  32470. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32471. */
  32472. /**
  32473. * Sets the SPS as always visible or not
  32474. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32475. */
  32476. isAlwaysVisible: boolean;
  32477. /**
  32478. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32479. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32480. */
  32481. /**
  32482. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32483. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32484. */
  32485. isVisibilityBoxLocked: boolean;
  32486. /**
  32487. * Tells to `setParticles()` to compute the particle rotations or not.
  32488. * Default value : true. The SPS is faster when it's set to false.
  32489. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32490. */
  32491. /**
  32492. * Gets if `setParticles()` computes the particle rotations or not.
  32493. * Default value : true. The SPS is faster when it's set to false.
  32494. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32495. */
  32496. computeParticleRotation: boolean;
  32497. /**
  32498. * Tells to `setParticles()` to compute the particle colors or not.
  32499. * Default value : true. The SPS is faster when it's set to false.
  32500. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32501. */
  32502. /**
  32503. * Gets if `setParticles()` computes the particle colors or not.
  32504. * Default value : true. The SPS is faster when it's set to false.
  32505. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32506. */
  32507. computeParticleColor: boolean;
  32508. /**
  32509. * Gets if `setParticles()` computes the particle textures or not.
  32510. * Default value : true. The SPS is faster when it's set to false.
  32511. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32512. */
  32513. computeParticleTexture: boolean;
  32514. /**
  32515. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32516. * Default value : false. The SPS is faster when it's set to false.
  32517. * Note : the particle custom vertex positions aren't stored values.
  32518. */
  32519. /**
  32520. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32521. * Default value : false. The SPS is faster when it's set to false.
  32522. * Note : the particle custom vertex positions aren't stored values.
  32523. */
  32524. computeParticleVertex: boolean;
  32525. /**
  32526. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32527. */
  32528. /**
  32529. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32530. */
  32531. computeBoundingBox: boolean;
  32532. /**
  32533. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32534. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32535. * Default : `true`
  32536. */
  32537. /**
  32538. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32539. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32540. * Default : `true`
  32541. */
  32542. depthSortParticles: boolean;
  32543. /**
  32544. * This function does nothing. It may be overwritten to set all the particle first values.
  32545. * The SPS doesn't call this function, you may have to call it by your own.
  32546. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32547. */
  32548. initParticles(): void;
  32549. /**
  32550. * This function does nothing. It may be overwritten to recycle a particle.
  32551. * The SPS doesn't call this function, you may have to call it by your own.
  32552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32553. * @param particle The particle to recycle
  32554. * @returns the recycled particle
  32555. */
  32556. recycleParticle(particle: SolidParticle): SolidParticle;
  32557. /**
  32558. * Updates a particle : this function should be overwritten by the user.
  32559. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32560. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32561. * @example : just set a particle position or velocity and recycle conditions
  32562. * @param particle The particle to update
  32563. * @returns the updated particle
  32564. */
  32565. updateParticle(particle: SolidParticle): SolidParticle;
  32566. /**
  32567. * Updates a vertex of a particle : it can be overwritten by the user.
  32568. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32569. * @param particle the current particle
  32570. * @param vertex the current index of the current particle
  32571. * @param pt the index of the current vertex in the particle shape
  32572. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32573. * @example : just set a vertex particle position
  32574. * @returns the updated vertex
  32575. */
  32576. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32577. /**
  32578. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32579. * This does nothing and may be overwritten by the user.
  32580. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32581. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32582. * @param update the boolean update value actually passed to setParticles()
  32583. */
  32584. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32585. /**
  32586. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32587. * This will be passed three parameters.
  32588. * This does nothing and may be overwritten by the user.
  32589. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32590. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32591. * @param update the boolean update value actually passed to setParticles()
  32592. */
  32593. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32594. }
  32595. }
  32596. declare module BABYLON {
  32597. /**
  32598. * Type of sub emitter
  32599. */
  32600. enum SubEmitterType {
  32601. /**
  32602. * Attached to the particle over it's lifetime
  32603. */
  32604. ATTACHED = 0,
  32605. /**
  32606. * Created when the particle dies
  32607. */
  32608. END = 1
  32609. }
  32610. /**
  32611. * Sub emitter class used to emit particles from an existing particle
  32612. */
  32613. class SubEmitter {
  32614. /**
  32615. * the particle system to be used by the sub emitter
  32616. */
  32617. particleSystem: ParticleSystem;
  32618. /**
  32619. * Type of the submitter (Default: END)
  32620. */
  32621. type: SubEmitterType;
  32622. /**
  32623. * 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)
  32624. * Note: This only is supported when using an emitter of type Mesh
  32625. */
  32626. inheritDirection: boolean;
  32627. /**
  32628. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32629. */
  32630. inheritedVelocityAmount: number;
  32631. /**
  32632. * Creates a sub emitter
  32633. * @param particleSystem the particle system to be used by the sub emitter
  32634. */
  32635. constructor(
  32636. /**
  32637. * the particle system to be used by the sub emitter
  32638. */
  32639. particleSystem: ParticleSystem);
  32640. /**
  32641. * Clones the sub emitter
  32642. * @returns the cloned sub emitter
  32643. */
  32644. clone(): SubEmitter;
  32645. /**
  32646. * Serialize current object to a JSON object
  32647. * @returns the serialized object
  32648. */
  32649. serialize(): any;
  32650. /**
  32651. * Creates a new SubEmitter from a serialized JSON version
  32652. * @param serializationObject defines the JSON object to read from
  32653. * @param scene defines the hosting scene
  32654. * @param rootUrl defines the rootUrl for data loading
  32655. * @returns a new SubEmitter
  32656. */
  32657. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32658. /** Release associated resources */
  32659. dispose(): void;
  32660. }
  32661. }
  32662. declare module BABYLON {
  32663. /**
  32664. * Interface used to describe a physics joint
  32665. */
  32666. interface PhysicsImpostorJoint {
  32667. /** Defines the main impostor to which the joint is linked */
  32668. mainImpostor: PhysicsImpostor;
  32669. /** Defines the impostor that is connected to the main impostor using this joint */
  32670. connectedImpostor: PhysicsImpostor;
  32671. /** Defines the joint itself */
  32672. joint: PhysicsJoint;
  32673. }
  32674. /** @hidden */
  32675. interface IPhysicsEnginePlugin {
  32676. world: any;
  32677. name: string;
  32678. setGravity(gravity: Vector3): void;
  32679. setTimeStep(timeStep: number): void;
  32680. getTimeStep(): number;
  32681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32685. removePhysicsBody(impostor: PhysicsImpostor): void;
  32686. generateJoint(joint: PhysicsImpostorJoint): void;
  32687. removeJoint(joint: PhysicsImpostorJoint): void;
  32688. isSupported(): boolean;
  32689. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32690. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32691. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32692. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32693. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32694. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32695. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32696. getBodyMass(impostor: PhysicsImpostor): number;
  32697. getBodyFriction(impostor: PhysicsImpostor): number;
  32698. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32699. getBodyRestitution(impostor: PhysicsImpostor): number;
  32700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32701. sleepBody(impostor: PhysicsImpostor): void;
  32702. wakeUpBody(impostor: PhysicsImpostor): void;
  32703. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32704. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32705. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32706. getRadius(impostor: PhysicsImpostor): number;
  32707. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32708. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32709. dispose(): void;
  32710. }
  32711. /**
  32712. * Interface used to define a physics engine
  32713. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32714. */
  32715. interface IPhysicsEngine {
  32716. /**
  32717. * Gets the gravity vector used by the simulation
  32718. */
  32719. gravity: Vector3;
  32720. /**
  32721. * Sets the gravity vector used by the simulation
  32722. * @param gravity defines the gravity vector to use
  32723. */
  32724. setGravity(gravity: Vector3): void;
  32725. /**
  32726. * Set the time step of the physics engine.
  32727. * Default is 1/60.
  32728. * To slow it down, enter 1/600 for example.
  32729. * To speed it up, 1/30
  32730. * @param newTimeStep the new timestep to apply to this world.
  32731. */
  32732. setTimeStep(newTimeStep: number): void;
  32733. /**
  32734. * Get the time step of the physics engine.
  32735. * @returns the current time step
  32736. */
  32737. getTimeStep(): number;
  32738. /**
  32739. * Release all resources
  32740. */
  32741. dispose(): void;
  32742. /**
  32743. * Gets the name of the current physics plugin
  32744. * @returns the name of the plugin
  32745. */
  32746. getPhysicsPluginName(): string;
  32747. /**
  32748. * Adding a new impostor for the impostor tracking.
  32749. * This will be done by the impostor itself.
  32750. * @param impostor the impostor to add
  32751. */
  32752. addImpostor(impostor: PhysicsImpostor): void;
  32753. /**
  32754. * Remove an impostor from the engine.
  32755. * This impostor and its mesh will not longer be updated by the physics engine.
  32756. * @param impostor the impostor to remove
  32757. */
  32758. removeImpostor(impostor: PhysicsImpostor): void;
  32759. /**
  32760. * Add a joint to the physics engine
  32761. * @param mainImpostor defines the main impostor to which the joint is added.
  32762. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32763. * @param joint defines the joint that will connect both impostors.
  32764. */
  32765. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32766. /**
  32767. * Removes a joint from the simulation
  32768. * @param mainImpostor defines the impostor used with the joint
  32769. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32770. * @param joint defines the joint to remove
  32771. */
  32772. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32773. /**
  32774. * Gets the current plugin used to run the simulation
  32775. * @returns current plugin
  32776. */
  32777. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32778. /**
  32779. * Gets the list of physic impostors
  32780. * @returns an array of PhysicsImpostor
  32781. */
  32782. getImpostors(): Array<PhysicsImpostor>;
  32783. /**
  32784. * Gets the impostor for a physics enabled object
  32785. * @param object defines the object impersonated by the impostor
  32786. * @returns the PhysicsImpostor or null if not found
  32787. */
  32788. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32789. /**
  32790. * Gets the impostor for a physics body object
  32791. * @param body defines physics body used by the impostor
  32792. * @returns the PhysicsImpostor or null if not found
  32793. */
  32794. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32795. /**
  32796. * Called by the scene. No need to call it.
  32797. * @param delta defines the timespam between frames
  32798. */
  32799. _step(delta: number): void;
  32800. }
  32801. }
  32802. declare module BABYLON {
  32803. /**
  32804. * Class used to control physics engine
  32805. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32806. */
  32807. class PhysicsEngine implements IPhysicsEngine {
  32808. private _physicsPlugin;
  32809. /**
  32810. * Global value used to control the smallest number supported by the simulation
  32811. */
  32812. static Epsilon: number;
  32813. private _impostors;
  32814. private _joints;
  32815. /**
  32816. * Gets the gravity vector used by the simulation
  32817. */
  32818. gravity: Vector3;
  32819. /**
  32820. * Creates a new Physics Engine
  32821. * @param gravity defines the gravity vector used by the simulation
  32822. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32823. */
  32824. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32825. /**
  32826. * Sets the gravity vector used by the simulation
  32827. * @param gravity defines the gravity vector to use
  32828. */
  32829. setGravity(gravity: Vector3): void;
  32830. /**
  32831. * Set the time step of the physics engine.
  32832. * Default is 1/60.
  32833. * To slow it down, enter 1/600 for example.
  32834. * To speed it up, 1/30
  32835. * @param newTimeStep defines the new timestep to apply to this world.
  32836. */
  32837. setTimeStep(newTimeStep?: number): void;
  32838. /**
  32839. * Get the time step of the physics engine.
  32840. * @returns the current time step
  32841. */
  32842. getTimeStep(): number;
  32843. /**
  32844. * Release all resources
  32845. */
  32846. dispose(): void;
  32847. /**
  32848. * Gets the name of the current physics plugin
  32849. * @returns the name of the plugin
  32850. */
  32851. getPhysicsPluginName(): string;
  32852. /**
  32853. * Adding a new impostor for the impostor tracking.
  32854. * This will be done by the impostor itself.
  32855. * @param impostor the impostor to add
  32856. */
  32857. addImpostor(impostor: PhysicsImpostor): void;
  32858. /**
  32859. * Remove an impostor from the engine.
  32860. * This impostor and its mesh will not longer be updated by the physics engine.
  32861. * @param impostor the impostor to remove
  32862. */
  32863. removeImpostor(impostor: PhysicsImpostor): void;
  32864. /**
  32865. * Add a joint to the physics engine
  32866. * @param mainImpostor defines the main impostor to which the joint is added.
  32867. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32868. * @param joint defines the joint that will connect both impostors.
  32869. */
  32870. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32871. /**
  32872. * Removes a joint from the simulation
  32873. * @param mainImpostor defines the impostor used with the joint
  32874. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32875. * @param joint defines the joint to remove
  32876. */
  32877. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32878. /**
  32879. * Called by the scene. No need to call it.
  32880. * @param delta defines the timespam between frames
  32881. */
  32882. _step(delta: number): void;
  32883. /**
  32884. * Gets the current plugin used to run the simulation
  32885. * @returns current plugin
  32886. */
  32887. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32888. /**
  32889. * Gets the list of physic impostors
  32890. * @returns an array of PhysicsImpostor
  32891. */
  32892. getImpostors(): Array<PhysicsImpostor>;
  32893. /**
  32894. * Gets the impostor for a physics enabled object
  32895. * @param object defines the object impersonated by the impostor
  32896. * @returns the PhysicsImpostor or null if not found
  32897. */
  32898. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32899. /**
  32900. * Gets the impostor for a physics body object
  32901. * @param body defines physics body used by the impostor
  32902. * @returns the PhysicsImpostor or null if not found
  32903. */
  32904. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32905. }
  32906. }
  32907. declare module BABYLON {
  32908. interface Scene {
  32909. /** @hidden (Backing field) */
  32910. _physicsEngine: Nullable<IPhysicsEngine>;
  32911. /**
  32912. * Gets the current physics engine
  32913. * @returns a IPhysicsEngine or null if none attached
  32914. */
  32915. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  32916. /**
  32917. * Enables physics to the current scene
  32918. * @param gravity defines the scene's gravity for the physics engine
  32919. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  32920. * @return a boolean indicating if the physics engine was initialized
  32921. */
  32922. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  32923. /**
  32924. * Disables and disposes the physics engine associated with the scene
  32925. */
  32926. disablePhysicsEngine(): void;
  32927. /**
  32928. * Gets a boolean indicating if there is an active physics engine
  32929. * @returns a boolean indicating if there is an active physics engine
  32930. */
  32931. isPhysicsEnabled(): boolean;
  32932. /**
  32933. * Deletes a physics compound impostor
  32934. * @param compound defines the compound to delete
  32935. */
  32936. deleteCompoundImpostor(compound: any): void;
  32937. /**
  32938. * An event triggered when physic simulation is about to be run
  32939. */
  32940. onBeforePhysicsObservable: Observable<Scene>;
  32941. /**
  32942. * An event triggered when physic simulation has been done
  32943. */
  32944. onAfterPhysicsObservable: Observable<Scene>;
  32945. }
  32946. interface AbstractMesh {
  32947. /** @hidden */
  32948. _physicsImpostor: Nullable<PhysicsImpostor>;
  32949. /**
  32950. * Gets or sets impostor used for physic simulation
  32951. * @see http://doc.babylonjs.com/features/physics_engine
  32952. */
  32953. physicsImpostor: Nullable<PhysicsImpostor>;
  32954. /**
  32955. * Gets the current physics impostor
  32956. * @see http://doc.babylonjs.com/features/physics_engine
  32957. * @returns a physics impostor or null
  32958. */
  32959. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  32960. /** Apply a physic impulse to the mesh
  32961. * @param force defines the force to apply
  32962. * @param contactPoint defines where to apply the force
  32963. * @returns the current mesh
  32964. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32965. */
  32966. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  32967. /**
  32968. * Creates a physic joint between two meshes
  32969. * @param otherMesh defines the other mesh to use
  32970. * @param pivot1 defines the pivot to use on this mesh
  32971. * @param pivot2 defines the pivot to use on the other mesh
  32972. * @param options defines additional options (can be plugin dependent)
  32973. * @returns the current mesh
  32974. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  32975. */
  32976. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  32977. /** @hidden */
  32978. _disposePhysicsObserver: Nullable<Observer<Node>>;
  32979. }
  32980. /**
  32981. * Defines the physics engine scene component responsible to manage a physics engine
  32982. */
  32983. class PhysicsEngineSceneComponent implements ISceneComponent {
  32984. /**
  32985. * The component name helpful to identify the component in the list of scene components.
  32986. */
  32987. readonly name: string;
  32988. /**
  32989. * The scene the component belongs to.
  32990. */
  32991. scene: Scene;
  32992. /**
  32993. * Creates a new instance of the component for the given scene
  32994. * @param scene Defines the scene to register the component in
  32995. */
  32996. constructor(scene: Scene);
  32997. /**
  32998. * Registers the component in a given scene
  32999. */
  33000. register(): void;
  33001. /**
  33002. * Rebuilds the elements related to this component in case of
  33003. * context lost for instance.
  33004. */
  33005. rebuild(): void;
  33006. /**
  33007. * Disposes the component and the associated ressources
  33008. */
  33009. dispose(): void;
  33010. }
  33011. }
  33012. declare module BABYLON {
  33013. /**
  33014. * A helper for physics simulations
  33015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33016. */
  33017. class PhysicsHelper {
  33018. private _scene;
  33019. private _physicsEngine;
  33020. /**
  33021. * Initializes the Physics helper
  33022. * @param scene Babylon.js scene
  33023. */
  33024. constructor(scene: Scene);
  33025. /**
  33026. * Applies a radial explosion impulse
  33027. * @param origin the origin of the explosion
  33028. * @param radius the explosion radius
  33029. * @param strength the explosion strength
  33030. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33031. * @returns A physics radial explosion event, or null
  33032. */
  33033. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33034. /**
  33035. * Applies a radial explosion force
  33036. * @param origin the origin of the explosion
  33037. * @param radius the explosion radius
  33038. * @param strength the explosion strength
  33039. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33040. * @returns A physics radial explosion event, or null
  33041. */
  33042. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33043. /**
  33044. * Creates a gravitational field
  33045. * @param origin the origin of the explosion
  33046. * @param radius the explosion radius
  33047. * @param strength the explosion strength
  33048. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33049. * @returns A physics gravitational field event, or null
  33050. */
  33051. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33052. /**
  33053. * Creates a physics updraft event
  33054. * @param origin the origin of the updraft
  33055. * @param radius the radius of the updraft
  33056. * @param strength the strength of the updraft
  33057. * @param height the height of the updraft
  33058. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33059. * @returns A physics updraft event, or null
  33060. */
  33061. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33062. /**
  33063. * Creates a physics vortex event
  33064. * @param origin the of the vortex
  33065. * @param radius the radius of the vortex
  33066. * @param strength the strength of the vortex
  33067. * @param height the height of the vortex
  33068. * @returns a Physics vortex event, or null
  33069. * A physics vortex event or null
  33070. */
  33071. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33072. }
  33073. /**
  33074. * Represents a physics radial explosion event
  33075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33076. */
  33077. class PhysicsRadialExplosionEvent {
  33078. private _scene;
  33079. private _sphere;
  33080. private _sphereOptions;
  33081. private _rays;
  33082. private _dataFetched;
  33083. /**
  33084. * Initializes a radial explosioin event
  33085. * @param scene BabylonJS scene
  33086. */
  33087. constructor(scene: Scene);
  33088. /**
  33089. * Returns the data related to the radial explosion event (sphere & rays).
  33090. * @returns The radial explosion event data
  33091. */
  33092. getData(): PhysicsRadialExplosionEventData;
  33093. /**
  33094. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33095. * @param impostor A physics imposter
  33096. * @param origin the origin of the explosion
  33097. * @param radius the explosion radius
  33098. * @param strength the explosion strength
  33099. * @param falloff possible options: Constant & Linear
  33100. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33101. */
  33102. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33103. /**
  33104. * Disposes the sphere.
  33105. * @param force Specifies if the sphere should be disposed by force
  33106. */
  33107. dispose(force?: boolean): void;
  33108. /*** Helpers ***/
  33109. private _prepareSphere;
  33110. private _intersectsWithSphere;
  33111. }
  33112. /**
  33113. * Represents a gravitational field event
  33114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33115. */
  33116. class PhysicsGravitationalFieldEvent {
  33117. private _physicsHelper;
  33118. private _scene;
  33119. private _origin;
  33120. private _radius;
  33121. private _strength;
  33122. private _falloff;
  33123. private _tickCallback;
  33124. private _sphere;
  33125. private _dataFetched;
  33126. /**
  33127. * Initializes the physics gravitational field event
  33128. * @param physicsHelper A physics helper
  33129. * @param scene BabylonJS scene
  33130. * @param origin The origin position of the gravitational field event
  33131. * @param radius The radius of the gravitational field event
  33132. * @param strength The strength of the gravitational field event
  33133. * @param falloff The falloff for the gravitational field event
  33134. */
  33135. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33136. /**
  33137. * Returns the data related to the gravitational field event (sphere).
  33138. * @returns A gravitational field event
  33139. */
  33140. getData(): PhysicsGravitationalFieldEventData;
  33141. /**
  33142. * Enables the gravitational field.
  33143. */
  33144. enable(): void;
  33145. /**
  33146. * Disables the gravitational field.
  33147. */
  33148. disable(): void;
  33149. /**
  33150. * Disposes the sphere.
  33151. * @param force The force to dispose from the gravitational field event
  33152. */
  33153. dispose(force?: boolean): void;
  33154. private _tick;
  33155. }
  33156. /**
  33157. * Represents a physics updraft event
  33158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33159. */
  33160. class PhysicsUpdraftEvent {
  33161. private _scene;
  33162. private _origin;
  33163. private _radius;
  33164. private _strength;
  33165. private _height;
  33166. private _updraftMode;
  33167. private _physicsEngine;
  33168. private _originTop;
  33169. private _originDirection;
  33170. private _tickCallback;
  33171. private _cylinder;
  33172. private _cylinderPosition;
  33173. private _dataFetched;
  33174. /**
  33175. * Initializes the physics updraft event
  33176. * @param _scene BabylonJS scene
  33177. * @param _origin The origin position of the updraft
  33178. * @param _radius The radius of the updraft
  33179. * @param _strength The strength of the updraft
  33180. * @param _height The height of the updraft
  33181. * @param _updraftMode The mode of the updraft
  33182. */
  33183. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33184. /**
  33185. * Returns the data related to the updraft event (cylinder).
  33186. * @returns A physics updraft event
  33187. */
  33188. getData(): PhysicsUpdraftEventData;
  33189. /**
  33190. * Enables the updraft.
  33191. */
  33192. enable(): void;
  33193. /**
  33194. * Disables the cortex.
  33195. */
  33196. disable(): void;
  33197. /**
  33198. * Disposes the sphere.
  33199. * @param force Specifies if the updraft should be disposed by force
  33200. */
  33201. dispose(force?: boolean): void;
  33202. private getImpostorForceAndContactPoint;
  33203. private _tick;
  33204. /*** Helpers ***/
  33205. private _prepareCylinder;
  33206. private _intersectsWithCylinder;
  33207. }
  33208. /**
  33209. * Represents a physics vortex event
  33210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33211. */
  33212. class PhysicsVortexEvent {
  33213. private _scene;
  33214. private _origin;
  33215. private _radius;
  33216. private _strength;
  33217. private _height;
  33218. private _physicsEngine;
  33219. private _originTop;
  33220. private _centripetalForceThreshold;
  33221. private _updraftMultiplier;
  33222. private _tickCallback;
  33223. private _cylinder;
  33224. private _cylinderPosition;
  33225. private _dataFetched;
  33226. /**
  33227. * Initializes the physics vortex event
  33228. * @param _scene The BabylonJS scene
  33229. * @param _origin The origin position of the vortex
  33230. * @param _radius The radius of the vortex
  33231. * @param _strength The strength of the vortex
  33232. * @param _height The height of the vortex
  33233. */
  33234. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33235. /**
  33236. * Returns the data related to the vortex event (cylinder).
  33237. * @returns The physics vortex event data
  33238. */
  33239. getData(): PhysicsVortexEventData;
  33240. /**
  33241. * Enables the vortex.
  33242. */
  33243. enable(): void;
  33244. /**
  33245. * Disables the cortex.
  33246. */
  33247. disable(): void;
  33248. /**
  33249. * Disposes the sphere.
  33250. * @param force
  33251. */
  33252. dispose(force?: boolean): void;
  33253. private getImpostorForceAndContactPoint;
  33254. private _tick;
  33255. /*** Helpers ***/
  33256. private _prepareCylinder;
  33257. private _intersectsWithCylinder;
  33258. }
  33259. /**
  33260. * The strenght of the force in correspondence to the distance of the affected object
  33261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33262. */
  33263. enum PhysicsRadialImpulseFalloff {
  33264. /** Defines that impulse is constant in strength across it's whole radius */
  33265. Constant = 0,
  33266. /** DEfines that impulse gets weaker if it's further from the origin */
  33267. Linear = 1
  33268. }
  33269. /**
  33270. * The strength of the force in correspondence to the distance of the affected object
  33271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33272. */
  33273. enum PhysicsUpdraftMode {
  33274. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33275. Center = 0,
  33276. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33277. Perpendicular = 1
  33278. }
  33279. /**
  33280. * Interface for a physics force and contact point
  33281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33282. */
  33283. interface PhysicsForceAndContactPoint {
  33284. /**
  33285. * The force applied at the contact point
  33286. */
  33287. force: Vector3;
  33288. /**
  33289. * The contact point
  33290. */
  33291. contactPoint: Vector3;
  33292. }
  33293. /**
  33294. * Interface for radial explosion event data
  33295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33296. */
  33297. interface PhysicsRadialExplosionEventData {
  33298. /**
  33299. * A sphere used for the radial explosion event
  33300. */
  33301. sphere: Mesh;
  33302. /**
  33303. * An array of rays for the radial explosion event
  33304. */
  33305. rays: Array<Ray>;
  33306. }
  33307. /**
  33308. * Interface for gravitational field event data
  33309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33310. */
  33311. interface PhysicsGravitationalFieldEventData {
  33312. /**
  33313. * A sphere mesh used for the gravitational field event
  33314. */
  33315. sphere: Mesh;
  33316. }
  33317. /**
  33318. * Interface for updraft event data
  33319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33320. */
  33321. interface PhysicsUpdraftEventData {
  33322. /**
  33323. * A cylinder used for the updraft event
  33324. */
  33325. cylinder: Mesh;
  33326. }
  33327. /**
  33328. * Interface for vortex event data
  33329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33330. */
  33331. interface PhysicsVortexEventData {
  33332. /**
  33333. * A cylinder used for the vortex event
  33334. */
  33335. cylinder: Mesh;
  33336. }
  33337. }
  33338. declare module BABYLON {
  33339. /**
  33340. * The interface for the physics imposter parameters
  33341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33342. */
  33343. interface PhysicsImpostorParameters {
  33344. /**
  33345. * The mass of the physics imposter
  33346. */
  33347. mass: number;
  33348. /**
  33349. * The friction of the physics imposter
  33350. */
  33351. friction?: number;
  33352. /**
  33353. * The coefficient of restitution of the physics imposter
  33354. */
  33355. restitution?: number;
  33356. /**
  33357. * The native options of the physics imposter
  33358. */
  33359. nativeOptions?: any;
  33360. /**
  33361. * Specifies if the parent should be ignored
  33362. */
  33363. ignoreParent?: boolean;
  33364. /**
  33365. * Specifies if bi-directional transformations should be disabled
  33366. */
  33367. disableBidirectionalTransformation?: boolean;
  33368. }
  33369. /**
  33370. * Interface for a physics-enabled object
  33371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33372. */
  33373. interface IPhysicsEnabledObject {
  33374. /**
  33375. * The position of the physics-enabled object
  33376. */
  33377. position: Vector3;
  33378. /**
  33379. * The rotation of the physics-enabled object
  33380. */
  33381. rotationQuaternion: Nullable<Quaternion>;
  33382. /**
  33383. * The scale of the physics-enabled object
  33384. */
  33385. scaling: Vector3;
  33386. /**
  33387. * The rotation of the physics-enabled object
  33388. */
  33389. rotation?: Vector3;
  33390. /**
  33391. * The parent of the physics-enabled object
  33392. */
  33393. parent?: any;
  33394. /**
  33395. * The bounding info of the physics-enabled object
  33396. * @returns The bounding info of the physics-enabled object
  33397. */
  33398. getBoundingInfo(): BoundingInfo;
  33399. /**
  33400. * Computes the world matrix
  33401. * @param force Specifies if the world matrix should be computed by force
  33402. * @returns A world matrix
  33403. */
  33404. computeWorldMatrix(force: boolean): Matrix;
  33405. /**
  33406. * Gets the world matrix
  33407. * @returns A world matrix
  33408. */
  33409. getWorldMatrix?(): Matrix;
  33410. /**
  33411. * Gets the child meshes
  33412. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33413. * @returns An array of abstract meshes
  33414. */
  33415. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33416. /**
  33417. * Gets the vertex data
  33418. * @param kind The type of vertex data
  33419. * @returns A nullable array of numbers, or a float32 array
  33420. */
  33421. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33422. /**
  33423. * Gets the indices from the mesh
  33424. * @returns A nullable array of index arrays
  33425. */
  33426. getIndices?(): Nullable<IndicesArray>;
  33427. /**
  33428. * Gets the scene from the mesh
  33429. * @returns the indices array or null
  33430. */
  33431. getScene?(): Scene;
  33432. /**
  33433. * Gets the absolute position from the mesh
  33434. * @returns the absolute position
  33435. */
  33436. getAbsolutePosition(): Vector3;
  33437. /**
  33438. * Gets the absolute pivot point from the mesh
  33439. * @returns the absolute pivot point
  33440. */
  33441. getAbsolutePivotPoint(): Vector3;
  33442. /**
  33443. * Rotates the mesh
  33444. * @param axis The axis of rotation
  33445. * @param amount The amount of rotation
  33446. * @param space The space of the rotation
  33447. * @returns The rotation transform node
  33448. */
  33449. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33450. /**
  33451. * Translates the mesh
  33452. * @param axis The axis of translation
  33453. * @param distance The distance of translation
  33454. * @param space The space of the translation
  33455. * @returns The transform node
  33456. */
  33457. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33458. /**
  33459. * Sets the absolute position of the mesh
  33460. * @param absolutePosition The absolute position of the mesh
  33461. * @returns The transform node
  33462. */
  33463. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33464. /**
  33465. * Gets the class name of the mesh
  33466. * @returns The class name
  33467. */
  33468. getClassName(): string;
  33469. }
  33470. /**
  33471. * Represents a physics imposter
  33472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33473. */
  33474. class PhysicsImpostor {
  33475. /**
  33476. * The physics-enabled object used as the physics imposter
  33477. */
  33478. object: IPhysicsEnabledObject;
  33479. /**
  33480. * The type of the physics imposter
  33481. */
  33482. type: number;
  33483. private _options;
  33484. private _scene?;
  33485. /**
  33486. * The default object size of the imposter
  33487. */
  33488. static DEFAULT_OBJECT_SIZE: Vector3;
  33489. /**
  33490. * The identity quaternion of the imposter
  33491. */
  33492. static IDENTITY_QUATERNION: Quaternion;
  33493. private _physicsEngine;
  33494. private _physicsBody;
  33495. private _bodyUpdateRequired;
  33496. private _onBeforePhysicsStepCallbacks;
  33497. private _onAfterPhysicsStepCallbacks;
  33498. private _onPhysicsCollideCallbacks;
  33499. private _deltaPosition;
  33500. private _deltaRotation;
  33501. private _deltaRotationConjugated;
  33502. private _parent;
  33503. private _isDisposed;
  33504. private static _tmpVecs;
  33505. private static _tmpQuat;
  33506. /**
  33507. * Specifies if the physics imposter is disposed
  33508. */
  33509. readonly isDisposed: boolean;
  33510. /**
  33511. * Gets the mass of the physics imposter
  33512. */
  33513. mass: number;
  33514. /**
  33515. * Gets the coefficient of friction
  33516. */
  33517. /**
  33518. * Sets the coefficient of friction
  33519. */
  33520. friction: number;
  33521. /**
  33522. * Gets the coefficient of restitution
  33523. */
  33524. /**
  33525. * Sets the coefficient of restitution
  33526. */
  33527. restitution: number;
  33528. /**
  33529. * The unique id of the physics imposter
  33530. * set by the physics engine when adding this impostor to the array
  33531. */
  33532. uniqueId: number;
  33533. private _joints;
  33534. /**
  33535. * Initializes the physics imposter
  33536. * @param object The physics-enabled object used as the physics imposter
  33537. * @param type The type of the physics imposter
  33538. * @param _options The options for the physics imposter
  33539. * @param _scene The Babylon scene
  33540. */
  33541. constructor(
  33542. /**
  33543. * The physics-enabled object used as the physics imposter
  33544. */
  33545. object: IPhysicsEnabledObject,
  33546. /**
  33547. * The type of the physics imposter
  33548. */
  33549. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33550. /**
  33551. * This function will completly initialize this impostor.
  33552. * It will create a new body - but only if this mesh has no parent.
  33553. * If it has, this impostor will not be used other than to define the impostor
  33554. * of the child mesh.
  33555. * @hidden
  33556. */
  33557. _init(): void;
  33558. private _getPhysicsParent;
  33559. /**
  33560. * Should a new body be generated.
  33561. * @returns boolean specifying if body initialization is required
  33562. */
  33563. isBodyInitRequired(): boolean;
  33564. /**
  33565. * Sets the updated scaling
  33566. * @param updated Specifies if the scaling is updated
  33567. */
  33568. setScalingUpdated(updated: boolean): void;
  33569. /**
  33570. * Force a regeneration of this or the parent's impostor's body.
  33571. * Use under cautious - This will remove all joints already implemented.
  33572. */
  33573. forceUpdate(): void;
  33574. /**
  33575. * Gets the body that holds this impostor. Either its own, or its parent.
  33576. */
  33577. /**
  33578. * Set the physics body. Used mainly by the physics engine/plugin
  33579. */
  33580. physicsBody: any;
  33581. /**
  33582. * Get the parent of the physics imposter
  33583. * @returns Physics imposter or null
  33584. */
  33585. /**
  33586. * Sets the parent of the physics imposter
  33587. */
  33588. parent: Nullable<PhysicsImpostor>;
  33589. /**
  33590. * Resets the update flags
  33591. */
  33592. resetUpdateFlags(): void;
  33593. /**
  33594. * Gets the object extend size
  33595. * @returns the object extend size
  33596. */
  33597. getObjectExtendSize(): Vector3;
  33598. /**
  33599. * Gets the object center
  33600. * @returns The object center
  33601. */
  33602. getObjectCenter(): Vector3;
  33603. /**
  33604. * Get a specific parametes from the options parameter
  33605. * @param paramName The object parameter name
  33606. * @returns The object parameter
  33607. */
  33608. getParam(paramName: string): any;
  33609. /**
  33610. * Sets a specific parameter in the options given to the physics plugin
  33611. * @param paramName The parameter name
  33612. * @param value The value of the parameter
  33613. */
  33614. setParam(paramName: string, value: number): void;
  33615. /**
  33616. * Specifically change the body's mass option. Won't recreate the physics body object
  33617. * @param mass The mass of the physics imposter
  33618. */
  33619. setMass(mass: number): void;
  33620. /**
  33621. * Gets the linear velocity
  33622. * @returns linear velocity or null
  33623. */
  33624. getLinearVelocity(): Nullable<Vector3>;
  33625. /**
  33626. * Sets the linear velocity
  33627. * @param velocity linear velocity or null
  33628. */
  33629. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33630. /**
  33631. * Gets the angular velocity
  33632. * @returns angular velocity or null
  33633. */
  33634. getAngularVelocity(): Nullable<Vector3>;
  33635. /**
  33636. * Sets the angular velocity
  33637. * @param velocity The velocity or null
  33638. */
  33639. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33640. /**
  33641. * Execute a function with the physics plugin native code
  33642. * Provide a function the will have two variables - the world object and the physics body object
  33643. * @param func The function to execute with the physics plugin native code
  33644. */
  33645. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33646. /**
  33647. * Register a function that will be executed before the physics world is stepping forward
  33648. * @param func The function to execute before the physics world is stepped forward
  33649. */
  33650. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33651. /**
  33652. * Unregister a function that will be executed before the physics world is stepping forward
  33653. * @param func The function to execute before the physics world is stepped forward
  33654. */
  33655. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33656. /**
  33657. * Register a function that will be executed after the physics step
  33658. * @param func The function to execute after physics step
  33659. */
  33660. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33661. /**
  33662. * Unregisters a function that will be executed after the physics step
  33663. * @param func The function to execute after physics step
  33664. */
  33665. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33666. /**
  33667. * register a function that will be executed when this impostor collides against a different body
  33668. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33669. * @param func Callback that is executed on collision
  33670. */
  33671. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33672. /**
  33673. * Unregisters the physics imposter on contact
  33674. * @param collideAgainst The physics object to collide against
  33675. * @param func Callback to execute on collision
  33676. */
  33677. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33678. private _tmpQuat;
  33679. private _tmpQuat2;
  33680. /**
  33681. * Get the parent rotation
  33682. * @returns The parent rotation
  33683. */
  33684. getParentsRotation(): Quaternion;
  33685. /**
  33686. * this function is executed by the physics engine.
  33687. */
  33688. beforeStep: () => void;
  33689. /**
  33690. * this function is executed by the physics engine
  33691. */
  33692. afterStep: () => void;
  33693. /**
  33694. * Legacy collision detection event support
  33695. */
  33696. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33697. /**
  33698. * event and body object due to cannon's event-based architecture.
  33699. */
  33700. onCollide: (e: {
  33701. body: any;
  33702. }) => void;
  33703. /**
  33704. * Apply a force
  33705. * @param force The force to apply
  33706. * @param contactPoint The contact point for the force
  33707. * @returns The physics imposter
  33708. */
  33709. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33710. /**
  33711. * Apply an impulse
  33712. * @param force The impulse force
  33713. * @param contactPoint The contact point for the impulse force
  33714. * @returns The physics imposter
  33715. */
  33716. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33717. /**
  33718. * A help function to create a joint
  33719. * @param otherImpostor A physics imposter used to create a joint
  33720. * @param jointType The type of joint
  33721. * @param jointData The data for the joint
  33722. * @returns The physics imposter
  33723. */
  33724. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33725. /**
  33726. * Add a joint to this impostor with a different impostor
  33727. * @param otherImpostor A physics imposter used to add a joint
  33728. * @param joint The joint to add
  33729. * @returns The physics imposter
  33730. */
  33731. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33732. /**
  33733. * Will keep this body still, in a sleep mode.
  33734. * @returns the physics imposter
  33735. */
  33736. sleep(): PhysicsImpostor;
  33737. /**
  33738. * Wake the body up.
  33739. * @returns The physics imposter
  33740. */
  33741. wakeUp(): PhysicsImpostor;
  33742. /**
  33743. * Clones the physics imposter
  33744. * @param newObject The physics imposter clones to this physics-enabled object
  33745. * @returns A nullable physics imposter
  33746. */
  33747. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33748. /**
  33749. * Disposes the physics imposter
  33750. */
  33751. dispose(): void;
  33752. /**
  33753. * Sets the delta position
  33754. * @param position The delta position amount
  33755. */
  33756. setDeltaPosition(position: Vector3): void;
  33757. /**
  33758. * Sets the delta rotation
  33759. * @param rotation The delta rotation amount
  33760. */
  33761. setDeltaRotation(rotation: Quaternion): void;
  33762. /**
  33763. * Gets the box size of the physics imposter and stores the result in the input parameter
  33764. * @param result Stores the box size
  33765. * @returns The physics imposter
  33766. */
  33767. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33768. /**
  33769. * Gets the radius of the physics imposter
  33770. * @returns Radius of the physics imposter
  33771. */
  33772. getRadius(): number;
  33773. /**
  33774. * Sync a bone with this impostor
  33775. * @param bone The bone to sync to the impostor.
  33776. * @param boneMesh The mesh that the bone is influencing.
  33777. * @param jointPivot The pivot of the joint / bone in local space.
  33778. * @param distToJoint Optional distance from the impostor to the joint.
  33779. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33780. */
  33781. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33782. /**
  33783. * Sync impostor to a bone
  33784. * @param bone The bone that the impostor will be synced to.
  33785. * @param boneMesh The mesh that the bone is influencing.
  33786. * @param jointPivot The pivot of the joint / bone in local space.
  33787. * @param distToJoint Optional distance from the impostor to the joint.
  33788. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33789. * @param boneAxis Optional vector3 axis the bone is aligned with
  33790. */
  33791. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33792. /**
  33793. * No-Imposter type
  33794. */
  33795. static NoImpostor: number;
  33796. /**
  33797. * Sphere-Imposter type
  33798. */
  33799. static SphereImpostor: number;
  33800. /**
  33801. * Box-Imposter type
  33802. */
  33803. static BoxImpostor: number;
  33804. /**
  33805. * Plane-Imposter type
  33806. */
  33807. static PlaneImpostor: number;
  33808. /**
  33809. * Mesh-imposter type
  33810. */
  33811. static MeshImpostor: number;
  33812. /**
  33813. * Cylinder-Imposter type
  33814. */
  33815. static CylinderImpostor: number;
  33816. /**
  33817. * Particle-Imposter type
  33818. */
  33819. static ParticleImpostor: number;
  33820. /**
  33821. * Heightmap-Imposter type
  33822. */
  33823. static HeightmapImpostor: number;
  33824. }
  33825. }
  33826. declare module BABYLON {
  33827. /**
  33828. * Interface for Physics-Joint data
  33829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33830. */
  33831. interface PhysicsJointData {
  33832. /**
  33833. * The main pivot of the joint
  33834. */
  33835. mainPivot?: Vector3;
  33836. /**
  33837. * The connected pivot of the joint
  33838. */
  33839. connectedPivot?: Vector3;
  33840. /**
  33841. * The main axis of the joint
  33842. */
  33843. mainAxis?: Vector3;
  33844. /**
  33845. * The connected axis of the joint
  33846. */
  33847. connectedAxis?: Vector3;
  33848. /**
  33849. * The collision of the joint
  33850. */
  33851. collision?: boolean;
  33852. /**
  33853. * Native Oimo/Cannon/Energy data
  33854. */
  33855. nativeParams?: any;
  33856. }
  33857. /**
  33858. * This is a holder class for the physics joint created by the physics plugin
  33859. * It holds a set of functions to control the underlying joint
  33860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33861. */
  33862. class PhysicsJoint {
  33863. /**
  33864. * The type of the physics joint
  33865. */
  33866. type: number;
  33867. /**
  33868. * The data for the physics joint
  33869. */
  33870. jointData: PhysicsJointData;
  33871. private _physicsJoint;
  33872. protected _physicsPlugin: IPhysicsEnginePlugin;
  33873. /**
  33874. * Initializes the physics joint
  33875. * @param type The type of the physics joint
  33876. * @param jointData The data for the physics joint
  33877. */
  33878. constructor(
  33879. /**
  33880. * The type of the physics joint
  33881. */
  33882. type: number,
  33883. /**
  33884. * The data for the physics joint
  33885. */
  33886. jointData: PhysicsJointData);
  33887. /**
  33888. * Gets the physics joint
  33889. */
  33890. /**
  33891. * Sets the physics joint
  33892. */
  33893. physicsJoint: any;
  33894. /**
  33895. * Sets the physics plugin
  33896. */
  33897. physicsPlugin: IPhysicsEnginePlugin;
  33898. /**
  33899. * Execute a function that is physics-plugin specific.
  33900. * @param {Function} func the function that will be executed.
  33901. * It accepts two parameters: the physics world and the physics joint
  33902. */
  33903. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33904. /**
  33905. * Distance-Joint type
  33906. */
  33907. static DistanceJoint: number;
  33908. /**
  33909. * Hinge-Joint type
  33910. */
  33911. static HingeJoint: number;
  33912. /**
  33913. * Ball-and-Socket joint type
  33914. */
  33915. static BallAndSocketJoint: number;
  33916. /**
  33917. * Wheel-Joint type
  33918. */
  33919. static WheelJoint: number;
  33920. /**
  33921. * Slider-Joint type
  33922. */
  33923. static SliderJoint: number;
  33924. /**
  33925. * Prismatic-Joint type
  33926. */
  33927. static PrismaticJoint: number;
  33928. /**
  33929. * Universal-Joint type
  33930. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33931. */
  33932. static UniversalJoint: number;
  33933. /**
  33934. * Hinge-Joint 2 type
  33935. */
  33936. static Hinge2Joint: number;
  33937. /**
  33938. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33939. */
  33940. static PointToPointJoint: number;
  33941. /**
  33942. * Spring-Joint type
  33943. */
  33944. static SpringJoint: number;
  33945. /**
  33946. * Lock-Joint type
  33947. */
  33948. static LockJoint: number;
  33949. }
  33950. /**
  33951. * A class representing a physics distance joint
  33952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33953. */
  33954. class DistanceJoint extends PhysicsJoint {
  33955. /**
  33956. *
  33957. * @param jointData The data for the Distance-Joint
  33958. */
  33959. constructor(jointData: DistanceJointData);
  33960. /**
  33961. * Update the predefined distance.
  33962. * @param maxDistance The maximum preferred distance
  33963. * @param minDistance The minimum preferred distance
  33964. */
  33965. updateDistance(maxDistance: number, minDistance?: number): void;
  33966. }
  33967. /**
  33968. * Represents a Motor-Enabled Joint
  33969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33970. */
  33971. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33972. /**
  33973. * Initializes the Motor-Enabled Joint
  33974. * @param type The type of the joint
  33975. * @param jointData The physica joint data for the joint
  33976. */
  33977. constructor(type: number, jointData: PhysicsJointData);
  33978. /**
  33979. * Set the motor values.
  33980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33981. * @param force the force to apply
  33982. * @param maxForce max force for this motor.
  33983. */
  33984. setMotor(force?: number, maxForce?: number): void;
  33985. /**
  33986. * Set the motor's limits.
  33987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33988. * @param upperLimit The upper limit of the motor
  33989. * @param lowerLimit The lower limit of the motor
  33990. */
  33991. setLimit(upperLimit: number, lowerLimit?: number): void;
  33992. }
  33993. /**
  33994. * This class represents a single physics Hinge-Joint
  33995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33996. */
  33997. class HingeJoint extends MotorEnabledJoint {
  33998. /**
  33999. * Initializes the Hinge-Joint
  34000. * @param jointData The joint data for the Hinge-Joint
  34001. */
  34002. constructor(jointData: PhysicsJointData);
  34003. /**
  34004. * Set the motor values.
  34005. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34006. * @param {number} force the force to apply
  34007. * @param {number} maxForce max force for this motor.
  34008. */
  34009. setMotor(force?: number, maxForce?: number): void;
  34010. /**
  34011. * Set the motor's limits.
  34012. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34013. * @param upperLimit The upper limit of the motor
  34014. * @param lowerLimit The lower limit of the motor
  34015. */
  34016. setLimit(upperLimit: number, lowerLimit?: number): void;
  34017. }
  34018. /**
  34019. * This class represents a dual hinge physics joint (same as wheel joint)
  34020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34021. */
  34022. class Hinge2Joint extends MotorEnabledJoint {
  34023. /**
  34024. * Initializes the Hinge2-Joint
  34025. * @param jointData The joint data for the Hinge2-Joint
  34026. */
  34027. constructor(jointData: PhysicsJointData);
  34028. /**
  34029. * Set the motor values.
  34030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34031. * @param {number} force the force to apply
  34032. * @param {number} maxForce max force for this motor.
  34033. * @param {motorIndex} the motor's index, 0 or 1.
  34034. */
  34035. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34036. /**
  34037. * Set the motor limits.
  34038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34039. * @param {number} upperLimit the upper limit
  34040. * @param {number} lowerLimit lower limit
  34041. * @param {motorIndex} the motor's index, 0 or 1.
  34042. */
  34043. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34044. }
  34045. /**
  34046. * Interface for a motor enabled joint
  34047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34048. */
  34049. interface IMotorEnabledJoint {
  34050. /**
  34051. * Physics joint
  34052. */
  34053. physicsJoint: any;
  34054. /**
  34055. * Sets the motor of the motor-enabled joint
  34056. * @param force The force of the motor
  34057. * @param maxForce The maximum force of the motor
  34058. * @param motorIndex The index of the motor
  34059. */
  34060. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34061. /**
  34062. * Sets the limit of the motor
  34063. * @param upperLimit The upper limit of the motor
  34064. * @param lowerLimit The lower limit of the motor
  34065. * @param motorIndex The index of the motor
  34066. */
  34067. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34068. }
  34069. /**
  34070. * Joint data for a Distance-Joint
  34071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34072. */
  34073. interface DistanceJointData extends PhysicsJointData {
  34074. /**
  34075. * Max distance the 2 joint objects can be apart
  34076. */
  34077. maxDistance: number;
  34078. }
  34079. /**
  34080. * Joint data from a spring joint
  34081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34082. */
  34083. interface SpringJointData extends PhysicsJointData {
  34084. /**
  34085. * Length of the spring
  34086. */
  34087. length: number;
  34088. /**
  34089. * Stiffness of the spring
  34090. */
  34091. stiffness: number;
  34092. /**
  34093. * Damping of the spring
  34094. */
  34095. damping: number;
  34096. /** this callback will be called when applying the force to the impostors. */
  34097. forceApplicationCallback: () => void;
  34098. }
  34099. }
  34100. declare module BABYLON {
  34101. interface Scene {
  34102. /**
  34103. * The list of reflection probes added to the scene
  34104. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34105. */
  34106. reflectionProbes: Array<ReflectionProbe>;
  34107. }
  34108. /**
  34109. * Class used to generate realtime reflection / refraction cube textures
  34110. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34111. */
  34112. class ReflectionProbe {
  34113. /** defines the name of the probe */
  34114. name: string;
  34115. private _scene;
  34116. private _renderTargetTexture;
  34117. private _projectionMatrix;
  34118. private _viewMatrix;
  34119. private _target;
  34120. private _add;
  34121. private _attachedMesh;
  34122. private _invertYAxis;
  34123. /** Gets or sets probe position (center of the cube map) */
  34124. position: Vector3;
  34125. /**
  34126. * Creates a new reflection probe
  34127. * @param name defines the name of the probe
  34128. * @param size defines the texture resolution (for each face)
  34129. * @param scene defines the hosting scene
  34130. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34131. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34132. */
  34133. constructor(
  34134. /** defines the name of the probe */
  34135. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34136. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34137. samples: number;
  34138. /** Gets or sets the refresh rate to use (on every frame by default) */
  34139. refreshRate: number;
  34140. /**
  34141. * Gets the hosting scene
  34142. * @returns a Scene
  34143. */
  34144. getScene(): Scene;
  34145. /** Gets the internal CubeTexture used to render to */
  34146. readonly cubeTexture: RenderTargetTexture;
  34147. /** Gets the list of meshes to render */
  34148. readonly renderList: Nullable<AbstractMesh[]>;
  34149. /**
  34150. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34151. * @param mesh defines the mesh to attach to
  34152. */
  34153. attachToMesh(mesh: AbstractMesh): void;
  34154. /**
  34155. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34156. * @param renderingGroupId The rendering group id corresponding to its index
  34157. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34158. */
  34159. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34160. /**
  34161. * Clean all associated resources
  34162. */
  34163. dispose(): void;
  34164. }
  34165. }
  34166. declare module BABYLON {
  34167. /**
  34168. * Postprocess used to generate anaglyphic rendering
  34169. */
  34170. class AnaglyphPostProcess extends PostProcess {
  34171. private _passedProcess;
  34172. /**
  34173. * Creates a new AnaglyphPostProcess
  34174. * @param name defines postprocess name
  34175. * @param options defines creation options or target ratio scale
  34176. * @param rigCameras defines cameras using this postprocess
  34177. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34178. * @param engine defines hosting engine
  34179. * @param reusable defines if the postprocess will be reused multiple times per frame
  34180. */
  34181. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34182. }
  34183. }
  34184. declare module BABYLON {
  34185. /**
  34186. * Post process used to render in black and white
  34187. */
  34188. class BlackAndWhitePostProcess extends PostProcess {
  34189. /**
  34190. * Linear about to convert he result to black and white (default: 1)
  34191. */
  34192. degree: number;
  34193. /**
  34194. * Creates a black and white post process
  34195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34196. * @param name The name of the effect.
  34197. * @param options The required width/height ratio to downsize to before computing the render pass.
  34198. * @param camera The camera to apply the render pass to.
  34199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34200. * @param engine The engine which the post process will be applied. (default: current engine)
  34201. * @param reusable If the post process can be reused on the same frame. (default: false)
  34202. */
  34203. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34204. }
  34205. }
  34206. declare module BABYLON {
  34207. /**
  34208. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34209. */
  34210. class BloomEffect extends PostProcessRenderEffect {
  34211. private bloomScale;
  34212. /**
  34213. * @hidden Internal
  34214. */
  34215. _effects: Array<PostProcess>;
  34216. /**
  34217. * @hidden Internal
  34218. */
  34219. _downscale: ExtractHighlightsPostProcess;
  34220. private _blurX;
  34221. private _blurY;
  34222. private _merge;
  34223. /**
  34224. * The luminance threshold to find bright areas of the image to bloom.
  34225. */
  34226. threshold: number;
  34227. /**
  34228. * The strength of the bloom.
  34229. */
  34230. weight: number;
  34231. /**
  34232. * Specifies the size of the bloom blur kernel, relative to the final output size
  34233. */
  34234. kernel: number;
  34235. /**
  34236. * Creates a new instance of @see BloomEffect
  34237. * @param scene The scene the effect belongs to.
  34238. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34239. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34240. * @param bloomWeight The the strength of bloom.
  34241. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34242. * @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)
  34243. */
  34244. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34245. /**
  34246. * Disposes each of the internal effects for a given camera.
  34247. * @param camera The camera to dispose the effect on.
  34248. */
  34249. disposeEffects(camera: Camera): void;
  34250. /**
  34251. * @hidden Internal
  34252. */
  34253. _updateEffects(): void;
  34254. /**
  34255. * Internal
  34256. * @returns if all the contained post processes are ready.
  34257. * @hidden
  34258. */
  34259. _isReady(): boolean;
  34260. }
  34261. }
  34262. declare module BABYLON {
  34263. /**
  34264. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34265. */
  34266. class BloomMergePostProcess extends PostProcess {
  34267. /** Weight of the bloom to be added to the original input. */
  34268. weight: number;
  34269. /**
  34270. * Creates a new instance of @see BloomMergePostProcess
  34271. * @param name The name of the effect.
  34272. * @param originalFromInput Post process which's input will be used for the merge.
  34273. * @param blurred Blurred highlights post process which's output will be used.
  34274. * @param weight Weight of the bloom to be added to the original input.
  34275. * @param options The required width/height ratio to downsize to before computing the render pass.
  34276. * @param camera The camera to apply the render pass to.
  34277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34278. * @param engine The engine which the post process will be applied. (default: current engine)
  34279. * @param reusable If the post process can be reused on the same frame. (default: false)
  34280. * @param textureType Type of textures used when performing the post process. (default: 0)
  34281. * @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)
  34282. */
  34283. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34284. /** Weight of the bloom to be added to the original input. */
  34285. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34286. }
  34287. }
  34288. declare module BABYLON {
  34289. /**
  34290. * The Blur Post Process which blurs an image based on a kernel and direction.
  34291. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34292. */
  34293. class BlurPostProcess extends PostProcess {
  34294. /** The direction in which to blur the image. */
  34295. direction: Vector2;
  34296. private blockCompilation;
  34297. protected _kernel: number;
  34298. protected _idealKernel: number;
  34299. protected _packedFloat: boolean;
  34300. private _staticDefines;
  34301. /**
  34302. * Sets the length in pixels of the blur sample region
  34303. */
  34304. /**
  34305. * Gets the length in pixels of the blur sample region
  34306. */
  34307. kernel: number;
  34308. /**
  34309. * Sets wether or not the blur needs to unpack/repack floats
  34310. */
  34311. /**
  34312. * Gets wether or not the blur is unpacking/repacking floats
  34313. */
  34314. packedFloat: boolean;
  34315. /**
  34316. * Creates a new instance BlurPostProcess
  34317. * @param name The name of the effect.
  34318. * @param direction The direction in which to blur the image.
  34319. * @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.
  34320. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34321. * @param camera The camera to apply the render pass to.
  34322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34323. * @param engine The engine which the post process will be applied. (default: current engine)
  34324. * @param reusable If the post process can be reused on the same frame. (default: false)
  34325. * @param textureType Type of textures used when performing the post process. (default: 0)
  34326. * @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)
  34327. */
  34328. constructor(name: string,
  34329. /** The direction in which to blur the image. */
  34330. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34331. /**
  34332. * Updates the effect with the current post process compile time values and recompiles the shader.
  34333. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34334. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34335. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34336. * @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
  34337. * @param onCompiled Called when the shader has been compiled.
  34338. * @param onError Called if there is an error when compiling a shader.
  34339. */
  34340. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34341. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34342. /**
  34343. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34344. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34345. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34346. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34347. * The gaps between physical kernels are compensated for in the weighting of the samples
  34348. * @param idealKernel Ideal blur kernel.
  34349. * @return Nearest best kernel.
  34350. */
  34351. protected _nearestBestKernel(idealKernel: number): number;
  34352. /**
  34353. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34354. * @param x The point on the Gaussian distribution to sample.
  34355. * @return the value of the Gaussian function at x.
  34356. */
  34357. protected _gaussianWeight(x: number): number;
  34358. /**
  34359. * Generates a string that can be used as a floating point number in GLSL.
  34360. * @param x Value to print.
  34361. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34362. * @return GLSL float string.
  34363. */
  34364. protected _glslFloat(x: number, decimalFigures?: number): string;
  34365. }
  34366. }
  34367. declare module BABYLON {
  34368. /**
  34369. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34370. */
  34371. class ChromaticAberrationPostProcess extends PostProcess {
  34372. /**
  34373. * The amount of seperation of rgb channels (default: 30)
  34374. */
  34375. aberrationAmount: number;
  34376. /**
  34377. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34378. */
  34379. radialIntensity: number;
  34380. /**
  34381. * 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))
  34382. */
  34383. direction: Vector2;
  34384. /**
  34385. * 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))
  34386. */
  34387. centerPosition: Vector2;
  34388. /**
  34389. * Creates a new instance ChromaticAberrationPostProcess
  34390. * @param name The name of the effect.
  34391. * @param screenWidth The width of the screen to apply the effect on.
  34392. * @param screenHeight The height of the screen to apply the effect on.
  34393. * @param options The required width/height ratio to downsize to before computing the render pass.
  34394. * @param camera The camera to apply the render pass to.
  34395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34396. * @param engine The engine which the post process will be applied. (default: current engine)
  34397. * @param reusable If the post process can be reused on the same frame. (default: false)
  34398. * @param textureType Type of textures used when performing the post process. (default: 0)
  34399. * @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)
  34400. */
  34401. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34402. }
  34403. }
  34404. declare module BABYLON {
  34405. /**
  34406. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34407. */
  34408. class CircleOfConfusionPostProcess extends PostProcess {
  34409. /**
  34410. * 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.
  34411. */
  34412. lensSize: number;
  34413. /**
  34414. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34415. */
  34416. fStop: number;
  34417. /**
  34418. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34419. */
  34420. focusDistance: number;
  34421. /**
  34422. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34423. */
  34424. focalLength: number;
  34425. private _depthTexture;
  34426. /**
  34427. * Creates a new instance CircleOfConfusionPostProcess
  34428. * @param name The name of the effect.
  34429. * @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.
  34430. * @param options The required width/height ratio to downsize to before computing the render pass.
  34431. * @param camera The camera to apply the render pass to.
  34432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34433. * @param engine The engine which the post process will be applied. (default: current engine)
  34434. * @param reusable If the post process can be reused on the same frame. (default: false)
  34435. * @param textureType Type of textures used when performing the post process. (default: 0)
  34436. * @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)
  34437. */
  34438. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34439. /**
  34440. * 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.
  34441. */
  34442. depthTexture: RenderTargetTexture;
  34443. }
  34444. }
  34445. declare module BABYLON {
  34446. /**
  34447. *
  34448. * This post-process allows the modification of rendered colors by using
  34449. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34450. *
  34451. * The object needs to be provided an url to a texture containing the color
  34452. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34453. * Use an image editing software to tweak the LUT to match your needs.
  34454. *
  34455. * For an example of a color LUT, see here:
  34456. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34457. * For explanations on color grading, see here:
  34458. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34459. *
  34460. */
  34461. class ColorCorrectionPostProcess extends PostProcess {
  34462. private _colorTableTexture;
  34463. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34464. }
  34465. }
  34466. declare module BABYLON {
  34467. /**
  34468. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34469. * input texture to perform effects such as edge detection or sharpening
  34470. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34471. */
  34472. class ConvolutionPostProcess extends PostProcess {
  34473. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34474. kernel: number[];
  34475. /**
  34476. * Creates a new instance ConvolutionPostProcess
  34477. * @param name The name of the effect.
  34478. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34479. * @param options The required width/height ratio to downsize to before computing the render pass.
  34480. * @param camera The camera to apply the render pass to.
  34481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34482. * @param engine The engine which the post process will be applied. (default: current engine)
  34483. * @param reusable If the post process can be reused on the same frame. (default: false)
  34484. * @param textureType Type of textures used when performing the post process. (default: 0)
  34485. */
  34486. constructor(name: string,
  34487. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34488. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34489. /**
  34490. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34491. */
  34492. static EdgeDetect0Kernel: number[];
  34493. /**
  34494. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34495. */
  34496. static EdgeDetect1Kernel: number[];
  34497. /**
  34498. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34499. */
  34500. static EdgeDetect2Kernel: number[];
  34501. /**
  34502. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34503. */
  34504. static SharpenKernel: number[];
  34505. /**
  34506. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34507. */
  34508. static EmbossKernel: number[];
  34509. /**
  34510. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34511. */
  34512. static GaussianKernel: number[];
  34513. }
  34514. }
  34515. declare module BABYLON {
  34516. /**
  34517. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34518. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34519. * based on samples that have a large difference in distance than the center pixel.
  34520. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34521. */
  34522. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34523. direction: Vector2;
  34524. /**
  34525. * Creates a new instance CircleOfConfusionPostProcess
  34526. * @param name The name of the effect.
  34527. * @param scene The scene the effect belongs to.
  34528. * @param direction The direction the blur should be applied.
  34529. * @param kernel The size of the kernel used to blur.
  34530. * @param options The required width/height ratio to downsize to before computing the render pass.
  34531. * @param camera The camera to apply the render pass to.
  34532. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34533. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34535. * @param engine The engine which the post process will be applied. (default: current engine)
  34536. * @param reusable If the post process can be reused on the same frame. (default: false)
  34537. * @param textureType Type of textures used when performing the post process. (default: 0)
  34538. * @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)
  34539. */
  34540. 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);
  34541. }
  34542. }
  34543. declare module BABYLON {
  34544. /**
  34545. * Specifies the level of max blur that should be applied when using the depth of field effect
  34546. */
  34547. enum DepthOfFieldEffectBlurLevel {
  34548. /**
  34549. * Subtle blur
  34550. */
  34551. Low = 0,
  34552. /**
  34553. * Medium blur
  34554. */
  34555. Medium = 1,
  34556. /**
  34557. * Large blur
  34558. */
  34559. High = 2
  34560. }
  34561. /**
  34562. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34563. */
  34564. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34565. private _circleOfConfusion;
  34566. /**
  34567. * @hidden Internal, blurs from high to low
  34568. */
  34569. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34570. private _depthOfFieldBlurY;
  34571. private _dofMerge;
  34572. /**
  34573. * @hidden Internal post processes in depth of field effect
  34574. */
  34575. _effects: Array<PostProcess>;
  34576. /**
  34577. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34578. */
  34579. focalLength: number;
  34580. /**
  34581. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34582. */
  34583. fStop: number;
  34584. /**
  34585. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34586. */
  34587. focusDistance: number;
  34588. /**
  34589. * 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.
  34590. */
  34591. lensSize: number;
  34592. /**
  34593. * Creates a new instance DepthOfFieldEffect
  34594. * @param scene The scene the effect belongs to.
  34595. * @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.
  34596. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34597. * @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)
  34598. */
  34599. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34600. /**
  34601. * 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.
  34602. */
  34603. depthTexture: RenderTargetTexture;
  34604. /**
  34605. * Disposes each of the internal effects for a given camera.
  34606. * @param camera The camera to dispose the effect on.
  34607. */
  34608. disposeEffects(camera: Camera): void;
  34609. /**
  34610. * @hidden Internal
  34611. */
  34612. _updateEffects(): void;
  34613. /**
  34614. * Internal
  34615. * @returns if all the contained post processes are ready.
  34616. * @hidden
  34617. */
  34618. _isReady(): boolean;
  34619. }
  34620. }
  34621. declare module BABYLON {
  34622. /**
  34623. * Options to be set when merging outputs from the default pipeline.
  34624. */
  34625. class DepthOfFieldMergePostProcessOptions {
  34626. /**
  34627. * The original image to merge on top of
  34628. */
  34629. originalFromInput: PostProcess;
  34630. /**
  34631. * Parameters to perform the merge of the depth of field effect
  34632. */
  34633. depthOfField?: {
  34634. circleOfConfusion: PostProcess;
  34635. blurSteps: Array<PostProcess>;
  34636. };
  34637. /**
  34638. * Parameters to perform the merge of bloom effect
  34639. */
  34640. bloom?: {
  34641. blurred: PostProcess;
  34642. weight: number;
  34643. };
  34644. }
  34645. /**
  34646. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34647. */
  34648. class DepthOfFieldMergePostProcess extends PostProcess {
  34649. private blurSteps;
  34650. /**
  34651. * Creates a new instance of DepthOfFieldMergePostProcess
  34652. * @param name The name of the effect.
  34653. * @param originalFromInput Post process which's input will be used for the merge.
  34654. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34655. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34656. * @param options The required width/height ratio to downsize to before computing the render pass.
  34657. * @param camera The camera to apply the render pass to.
  34658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34659. * @param engine The engine which the post process will be applied. (default: current engine)
  34660. * @param reusable If the post process can be reused on the same frame. (default: false)
  34661. * @param textureType Type of textures used when performing the post process. (default: 0)
  34662. * @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)
  34663. */
  34664. 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);
  34665. /**
  34666. * Updates the effect with the current post process compile time values and recompiles the shader.
  34667. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34668. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34669. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34670. * @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
  34671. * @param onCompiled Called when the shader has been compiled.
  34672. * @param onError Called if there is an error when compiling a shader.
  34673. */
  34674. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34675. }
  34676. }
  34677. declare module BABYLON {
  34678. /**
  34679. * DisplayPassPostProcess which produces an output the same as it's input
  34680. */
  34681. class DisplayPassPostProcess extends PostProcess {
  34682. /**
  34683. * Creates the DisplayPassPostProcess
  34684. * @param name The name of the effect.
  34685. * @param options The required width/height ratio to downsize to before computing the render pass.
  34686. * @param camera The camera to apply the render pass to.
  34687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34688. * @param engine The engine which the post process will be applied. (default: current engine)
  34689. * @param reusable If the post process can be reused on the same frame. (default: false)
  34690. */
  34691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34692. }
  34693. }
  34694. declare module BABYLON {
  34695. /**
  34696. * 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.
  34697. */
  34698. class ExtractHighlightsPostProcess extends PostProcess {
  34699. /**
  34700. * The luminance threshold, pixels below this value will be set to black.
  34701. */
  34702. threshold: number;
  34703. /** @hidden */
  34704. _exposure: number;
  34705. /**
  34706. * Post process which has the input texture to be used when performing highlight extraction
  34707. * @hidden
  34708. */
  34709. _inputPostProcess: Nullable<PostProcess>;
  34710. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34711. }
  34712. }
  34713. declare module BABYLON {
  34714. /**
  34715. * Applies a kernel filter to the image
  34716. */
  34717. class FilterPostProcess extends PostProcess {
  34718. /** The matrix to be applied to the image */
  34719. kernelMatrix: Matrix;
  34720. /**
  34721. *
  34722. * @param name The name of the effect.
  34723. * @param kernelMatrix The matrix to be applied to the image
  34724. * @param options The required width/height ratio to downsize to before computing the render pass.
  34725. * @param camera The camera to apply the render pass to.
  34726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34727. * @param engine The engine which the post process will be applied. (default: current engine)
  34728. * @param reusable If the post process can be reused on the same frame. (default: false)
  34729. */
  34730. constructor(name: string,
  34731. /** The matrix to be applied to the image */
  34732. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34733. }
  34734. }
  34735. declare module BABYLON {
  34736. /**
  34737. * Fxaa post process
  34738. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34739. */
  34740. class FxaaPostProcess extends PostProcess {
  34741. /** @hidden */
  34742. texelWidth: number;
  34743. /** @hidden */
  34744. texelHeight: number;
  34745. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34746. private _getDefines;
  34747. }
  34748. }
  34749. declare module BABYLON {
  34750. /**
  34751. * The GrainPostProcess adds noise to the image at mid luminance levels
  34752. */
  34753. class GrainPostProcess extends PostProcess {
  34754. /**
  34755. * The intensity of the grain added (default: 30)
  34756. */
  34757. intensity: number;
  34758. /**
  34759. * If the grain should be randomized on every frame
  34760. */
  34761. animated: boolean;
  34762. /**
  34763. * Creates a new instance of @see GrainPostProcess
  34764. * @param name The name of the effect.
  34765. * @param options The required width/height ratio to downsize to before computing the render pass.
  34766. * @param camera The camera to apply the render pass to.
  34767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34768. * @param engine The engine which the post process will be applied. (default: current engine)
  34769. * @param reusable If the post process can be reused on the same frame. (default: false)
  34770. * @param textureType Type of textures used when performing the post process. (default: 0)
  34771. * @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)
  34772. */
  34773. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34774. }
  34775. }
  34776. declare module BABYLON {
  34777. /**
  34778. * Extracts highlights from the image
  34779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34780. */
  34781. class HighlightsPostProcess extends PostProcess {
  34782. /**
  34783. * Extracts highlights from the image
  34784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34785. * @param name The name of the effect.
  34786. * @param options The required width/height ratio to downsize to before computing the render pass.
  34787. * @param camera The camera to apply the render pass to.
  34788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34789. * @param engine The engine which the post process will be applied. (default: current engine)
  34790. * @param reusable If the post process can be reused on the same frame. (default: false)
  34791. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34792. */
  34793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34794. }
  34795. }
  34796. declare module BABYLON {
  34797. /**
  34798. * ImageProcessingPostProcess
  34799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34800. */
  34801. class ImageProcessingPostProcess extends PostProcess {
  34802. /**
  34803. * Default configuration related to image processing available in the PBR Material.
  34804. */
  34805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34806. /**
  34807. * Gets the image processing configuration used either in this material.
  34808. */
  34809. /**
  34810. * Sets the Default image processing configuration used either in the this material.
  34811. *
  34812. * If sets to null, the scene one is in use.
  34813. */
  34814. imageProcessingConfiguration: ImageProcessingConfiguration;
  34815. /**
  34816. * Keep track of the image processing observer to allow dispose and replace.
  34817. */
  34818. private _imageProcessingObserver;
  34819. /**
  34820. * Attaches a new image processing configuration to the PBR Material.
  34821. * @param configuration
  34822. */
  34823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34824. /**
  34825. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34826. */
  34827. /**
  34828. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34829. */
  34830. colorCurves: Nullable<ColorCurves>;
  34831. /**
  34832. * Gets wether the color curves effect is enabled.
  34833. */
  34834. /**
  34835. * Sets wether the color curves effect is enabled.
  34836. */
  34837. colorCurvesEnabled: boolean;
  34838. /**
  34839. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34840. */
  34841. /**
  34842. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34843. */
  34844. colorGradingTexture: Nullable<BaseTexture>;
  34845. /**
  34846. * Gets wether the color grading effect is enabled.
  34847. */
  34848. /**
  34849. * Gets wether the color grading effect is enabled.
  34850. */
  34851. colorGradingEnabled: boolean;
  34852. /**
  34853. * Gets exposure used in the effect.
  34854. */
  34855. /**
  34856. * Sets exposure used in the effect.
  34857. */
  34858. exposure: number;
  34859. /**
  34860. * Gets wether tonemapping is enabled or not.
  34861. */
  34862. /**
  34863. * Sets wether tonemapping is enabled or not
  34864. */
  34865. toneMappingEnabled: boolean;
  34866. /**
  34867. * Gets contrast used in the effect.
  34868. */
  34869. /**
  34870. * Sets contrast used in the effect.
  34871. */
  34872. contrast: number;
  34873. /**
  34874. * Gets Vignette stretch size.
  34875. */
  34876. /**
  34877. * Sets Vignette stretch size.
  34878. */
  34879. vignetteStretch: number;
  34880. /**
  34881. * Gets Vignette centre X Offset.
  34882. */
  34883. /**
  34884. * Sets Vignette centre X Offset.
  34885. */
  34886. vignetteCentreX: number;
  34887. /**
  34888. * Gets Vignette centre Y Offset.
  34889. */
  34890. /**
  34891. * Sets Vignette centre Y Offset.
  34892. */
  34893. vignetteCentreY: number;
  34894. /**
  34895. * Gets Vignette weight or intensity of the vignette effect.
  34896. */
  34897. /**
  34898. * Sets Vignette weight or intensity of the vignette effect.
  34899. */
  34900. vignetteWeight: number;
  34901. /**
  34902. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34903. * if vignetteEnabled is set to true.
  34904. */
  34905. /**
  34906. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34907. * if vignetteEnabled is set to true.
  34908. */
  34909. vignetteColor: Color4;
  34910. /**
  34911. * Gets Camera field of view used by the Vignette effect.
  34912. */
  34913. /**
  34914. * Sets Camera field of view used by the Vignette effect.
  34915. */
  34916. vignetteCameraFov: number;
  34917. /**
  34918. * Gets the vignette blend mode allowing different kind of effect.
  34919. */
  34920. /**
  34921. * Sets the vignette blend mode allowing different kind of effect.
  34922. */
  34923. vignetteBlendMode: number;
  34924. /**
  34925. * Gets wether the vignette effect is enabled.
  34926. */
  34927. /**
  34928. * Sets wether the vignette effect is enabled.
  34929. */
  34930. vignetteEnabled: boolean;
  34931. private _fromLinearSpace;
  34932. /**
  34933. * Gets wether the input of the processing is in Gamma or Linear Space.
  34934. */
  34935. /**
  34936. * Sets wether the input of the processing is in Gamma or Linear Space.
  34937. */
  34938. fromLinearSpace: boolean;
  34939. /**
  34940. * Defines cache preventing GC.
  34941. */
  34942. private _defines;
  34943. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34944. /**
  34945. * "ImageProcessingPostProcess"
  34946. * @returns "ImageProcessingPostProcess"
  34947. */
  34948. getClassName(): string;
  34949. protected _updateParameters(): void;
  34950. dispose(camera?: Camera): void;
  34951. }
  34952. }
  34953. declare module BABYLON {
  34954. /**
  34955. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  34956. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  34957. * As an example, all you have to do is to create the post-process:
  34958. * var mb = new BABYLON.MotionBlurPostProcess(
  34959. * 'mb', // The name of the effect.
  34960. * scene, // The scene containing the objects to blur according to their velocity.
  34961. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  34962. * camera // The camera to apply the render pass to.
  34963. * );
  34964. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  34965. */
  34966. class MotionBlurPostProcess extends PostProcess {
  34967. /**
  34968. * Defines how much the image is blurred by the movement. Default value is equal to 1
  34969. */
  34970. motionStrength: number;
  34971. /**
  34972. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  34973. */
  34974. /**
  34975. * Sets the number of iterations to be used for motion blur quality
  34976. */
  34977. motionBlurSamples: number;
  34978. private _motionBlurSamples;
  34979. private _geometryBufferRenderer;
  34980. /**
  34981. * Creates a new instance MotionBlurPostProcess
  34982. * @param name The name of the effect.
  34983. * @param scene The scene containing the objects to blur according to their velocity.
  34984. * @param options The required width/height ratio to downsize to before computing the render pass.
  34985. * @param camera The camera to apply the render pass to.
  34986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34987. * @param engine The engine which the post process will be applied. (default: current engine)
  34988. * @param reusable If the post process can be reused on the same frame. (default: false)
  34989. * @param textureType Type of textures used when performing the post process. (default: 0)
  34990. * @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)
  34991. */
  34992. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34993. /**
  34994. * Disposes the post process.
  34995. * @param camera The camera to dispose the post process on.
  34996. */
  34997. dispose(camera?: Camera): void;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /**
  35002. * PassPostProcess which produces an output the same as it's input
  35003. */
  35004. class PassPostProcess extends PostProcess {
  35005. /**
  35006. * Creates the PassPostProcess
  35007. * @param name The name of the effect.
  35008. * @param options The required width/height ratio to downsize to before computing the render pass.
  35009. * @param camera The camera to apply the render pass to.
  35010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35011. * @param engine The engine which the post process will be applied. (default: current engine)
  35012. * @param reusable If the post process can be reused on the same frame. (default: false)
  35013. * @param textureType The type of texture to be used when performing the post processing.
  35014. * @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)
  35015. */
  35016. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35017. }
  35018. }
  35019. declare module BABYLON {
  35020. /**
  35021. * Size options for a post process
  35022. */
  35023. type PostProcessOptions = {
  35024. width: number;
  35025. height: number;
  35026. };
  35027. /**
  35028. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35029. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35030. */
  35031. class PostProcess {
  35032. /** Name of the PostProcess. */
  35033. name: string;
  35034. /**
  35035. * Width of the texture to apply the post process on
  35036. */
  35037. width: number;
  35038. /**
  35039. * Height of the texture to apply the post process on
  35040. */
  35041. height: number;
  35042. /**
  35043. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35044. * @hidden
  35045. */
  35046. _outputTexture: Nullable<InternalTexture>;
  35047. /**
  35048. * Sampling mode used by the shader
  35049. * See https://doc.babylonjs.com/classes/3.1/texture
  35050. */
  35051. renderTargetSamplingMode: number;
  35052. /**
  35053. * Clear color to use when screen clearing
  35054. */
  35055. clearColor: Color4;
  35056. /**
  35057. * If the buffer needs to be cleared before applying the post process. (default: true)
  35058. * Should be set to false if shader will overwrite all previous pixels.
  35059. */
  35060. autoClear: boolean;
  35061. /**
  35062. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35063. */
  35064. alphaMode: number;
  35065. /**
  35066. * Sets the setAlphaBlendConstants of the babylon engine
  35067. */
  35068. alphaConstants: Color4;
  35069. /**
  35070. * Animations to be used for the post processing
  35071. */
  35072. animations: Animation[];
  35073. /**
  35074. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35075. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35076. */
  35077. enablePixelPerfectMode: boolean;
  35078. /**
  35079. * Force the postprocess to be applied without taking in account viewport
  35080. */
  35081. forceFullscreenViewport: boolean;
  35082. /**
  35083. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35084. *
  35085. * | Value | Type | Description |
  35086. * | ----- | ----------------------------------- | ----------- |
  35087. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35088. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35089. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35090. *
  35091. */
  35092. scaleMode: number;
  35093. /**
  35094. * Force textures to be a power of two (default: false)
  35095. */
  35096. alwaysForcePOT: boolean;
  35097. private _samples;
  35098. /**
  35099. * Number of sample textures (default: 1)
  35100. */
  35101. samples: number;
  35102. /**
  35103. * Modify the scale of the post process to be the same as the viewport (default: false)
  35104. */
  35105. adaptScaleToCurrentViewport: boolean;
  35106. private _camera;
  35107. private _scene;
  35108. private _engine;
  35109. private _options;
  35110. private _reusable;
  35111. private _textureType;
  35112. /**
  35113. * Smart array of input and output textures for the post process.
  35114. * @hidden
  35115. */
  35116. _textures: SmartArray<InternalTexture>;
  35117. /**
  35118. * The index in _textures that corresponds to the output texture.
  35119. * @hidden
  35120. */
  35121. _currentRenderTextureInd: number;
  35122. private _effect;
  35123. private _samplers;
  35124. private _fragmentUrl;
  35125. private _vertexUrl;
  35126. private _parameters;
  35127. private _scaleRatio;
  35128. protected _indexParameters: any;
  35129. private _shareOutputWithPostProcess;
  35130. private _texelSize;
  35131. private _forcedOutputTexture;
  35132. /**
  35133. * An event triggered when the postprocess is activated.
  35134. */
  35135. onActivateObservable: Observable<Camera>;
  35136. private _onActivateObserver;
  35137. /**
  35138. * A function that is added to the onActivateObservable
  35139. */
  35140. onActivate: Nullable<(camera: Camera) => void>;
  35141. /**
  35142. * An event triggered when the postprocess changes its size.
  35143. */
  35144. onSizeChangedObservable: Observable<PostProcess>;
  35145. private _onSizeChangedObserver;
  35146. /**
  35147. * A function that is added to the onSizeChangedObservable
  35148. */
  35149. onSizeChanged: (postProcess: PostProcess) => void;
  35150. /**
  35151. * An event triggered when the postprocess applies its effect.
  35152. */
  35153. onApplyObservable: Observable<Effect>;
  35154. private _onApplyObserver;
  35155. /**
  35156. * A function that is added to the onApplyObservable
  35157. */
  35158. onApply: (effect: Effect) => void;
  35159. /**
  35160. * An event triggered before rendering the postprocess
  35161. */
  35162. onBeforeRenderObservable: Observable<Effect>;
  35163. private _onBeforeRenderObserver;
  35164. /**
  35165. * A function that is added to the onBeforeRenderObservable
  35166. */
  35167. onBeforeRender: (effect: Effect) => void;
  35168. /**
  35169. * An event triggered after rendering the postprocess
  35170. */
  35171. onAfterRenderObservable: Observable<Effect>;
  35172. private _onAfterRenderObserver;
  35173. /**
  35174. * A function that is added to the onAfterRenderObservable
  35175. */
  35176. onAfterRender: (efect: Effect) => void;
  35177. /**
  35178. * 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
  35179. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35180. */
  35181. inputTexture: InternalTexture;
  35182. /**
  35183. * Gets the camera which post process is applied to.
  35184. * @returns The camera the post process is applied to.
  35185. */
  35186. getCamera(): Camera;
  35187. /**
  35188. * Gets the texel size of the postprocess.
  35189. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35190. */
  35191. readonly texelSize: Vector2;
  35192. /**
  35193. * Creates a new instance PostProcess
  35194. * @param name The name of the PostProcess.
  35195. * @param fragmentUrl The url of the fragment shader to be used.
  35196. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35197. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35198. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35199. * @param camera The camera to apply the render pass to.
  35200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35201. * @param engine The engine which the post process will be applied. (default: current engine)
  35202. * @param reusable If the post process can be reused on the same frame. (default: false)
  35203. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35204. * @param textureType Type of textures used when performing the post process. (default: 0)
  35205. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35206. * @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
  35207. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35208. */
  35209. constructor(
  35210. /** Name of the PostProcess. */
  35211. 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);
  35212. /**
  35213. * Gets the engine which this post process belongs to.
  35214. * @returns The engine the post process was enabled with.
  35215. */
  35216. getEngine(): Engine;
  35217. /**
  35218. * The effect that is created when initializing the post process.
  35219. * @returns The created effect corrisponding the the postprocess.
  35220. */
  35221. getEffect(): Effect;
  35222. /**
  35223. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35224. * @param postProcess The post process to share the output with.
  35225. * @returns This post process.
  35226. */
  35227. shareOutputWith(postProcess: PostProcess): PostProcess;
  35228. /**
  35229. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35230. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35231. */
  35232. useOwnOutput(): void;
  35233. /**
  35234. * Updates the effect with the current post process compile time values and recompiles the shader.
  35235. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35236. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35237. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35238. * @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
  35239. * @param onCompiled Called when the shader has been compiled.
  35240. * @param onError Called if there is an error when compiling a shader.
  35241. */
  35242. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35243. /**
  35244. * The post process is reusable if it can be used multiple times within one frame.
  35245. * @returns If the post process is reusable
  35246. */
  35247. isReusable(): boolean;
  35248. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35249. markTextureDirty(): void;
  35250. /**
  35251. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35252. * 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.
  35253. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35254. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35255. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35256. * @returns The target texture that was bound to be written to.
  35257. */
  35258. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35259. /**
  35260. * If the post process is supported.
  35261. */
  35262. readonly isSupported: boolean;
  35263. /**
  35264. * The aspect ratio of the output texture.
  35265. */
  35266. readonly aspectRatio: number;
  35267. /**
  35268. * Get a value indicating if the post-process is ready to be used
  35269. * @returns true if the post-process is ready (shader is compiled)
  35270. */
  35271. isReady(): boolean;
  35272. /**
  35273. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35274. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35275. */
  35276. apply(): Nullable<Effect>;
  35277. private _disposeTextures;
  35278. /**
  35279. * Disposes the post process.
  35280. * @param camera The camera to dispose the post process on.
  35281. */
  35282. dispose(camera?: Camera): void;
  35283. }
  35284. }
  35285. declare module BABYLON {
  35286. /**
  35287. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35288. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35289. */
  35290. class PostProcessManager {
  35291. private _scene;
  35292. private _indexBuffer;
  35293. private _vertexBuffers;
  35294. /**
  35295. * Creates a new instance PostProcess
  35296. * @param scene The scene that the post process is associated with.
  35297. */
  35298. constructor(scene: Scene);
  35299. private _prepareBuffers;
  35300. private _buildIndexBuffer;
  35301. /**
  35302. * Rebuilds the vertex buffers of the manager.
  35303. * @hidden
  35304. */
  35305. _rebuild(): void;
  35306. /**
  35307. * Prepares a frame to be run through a post process.
  35308. * @param sourceTexture The input texture to the post procesess. (default: null)
  35309. * @param postProcesses An array of post processes to be run. (default: null)
  35310. * @returns True if the post processes were able to be run.
  35311. * @hidden
  35312. */
  35313. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35314. /**
  35315. * Manually render a set of post processes to a texture.
  35316. * @param postProcesses An array of post processes to be run.
  35317. * @param targetTexture The target texture to render to.
  35318. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35319. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35320. * @param lodLevel defines which lod of the texture to render to
  35321. */
  35322. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35323. /**
  35324. * Finalize the result of the output of the postprocesses.
  35325. * @param doNotPresent If true the result will not be displayed to the screen.
  35326. * @param targetTexture The target texture to render to.
  35327. * @param faceIndex The index of the face to bind the target texture to.
  35328. * @param postProcesses The array of post processes to render.
  35329. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35330. * @hidden
  35331. */
  35332. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35333. /**
  35334. * Disposes of the post process manager.
  35335. */
  35336. dispose(): void;
  35337. }
  35338. }
  35339. declare module BABYLON {
  35340. /**
  35341. * Post process which applies a refractin texture
  35342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35343. */
  35344. class RefractionPostProcess extends PostProcess {
  35345. /** the base color of the refraction (used to taint the rendering) */
  35346. color: Color3;
  35347. /** simulated refraction depth */
  35348. depth: number;
  35349. /** the coefficient of the base color (0 to remove base color tainting) */
  35350. colorLevel: number;
  35351. private _refTexture;
  35352. private _ownRefractionTexture;
  35353. /**
  35354. * Gets or sets the refraction texture
  35355. * Please note that you are responsible for disposing the texture if you set it manually
  35356. */
  35357. refractionTexture: Texture;
  35358. /**
  35359. * Initializes the RefractionPostProcess
  35360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35361. * @param name The name of the effect.
  35362. * @param refractionTextureUrl Url of the refraction texture to use
  35363. * @param color the base color of the refraction (used to taint the rendering)
  35364. * @param depth simulated refraction depth
  35365. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35366. * @param camera The camera to apply the render pass to.
  35367. * @param options The required width/height ratio to downsize to before computing the render pass.
  35368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35369. * @param engine The engine which the post process will be applied. (default: current engine)
  35370. * @param reusable If the post process can be reused on the same frame. (default: false)
  35371. */
  35372. constructor(name: string, refractionTextureUrl: string,
  35373. /** the base color of the refraction (used to taint the rendering) */
  35374. color: Color3,
  35375. /** simulated refraction depth */
  35376. depth: number,
  35377. /** the coefficient of the base color (0 to remove base color tainting) */
  35378. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35379. /**
  35380. * Disposes of the post process
  35381. * @param camera Camera to dispose post process on
  35382. */
  35383. dispose(camera: Camera): void;
  35384. }
  35385. }
  35386. declare module BABYLON {
  35387. /**
  35388. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35389. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35390. */
  35391. class SharpenPostProcess extends PostProcess {
  35392. /**
  35393. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35394. */
  35395. colorAmount: number;
  35396. /**
  35397. * How much sharpness should be applied (default: 0.3)
  35398. */
  35399. edgeAmount: number;
  35400. /**
  35401. * Creates a new instance ConvolutionPostProcess
  35402. * @param name The name of the effect.
  35403. * @param options The required width/height ratio to downsize to before computing the render pass.
  35404. * @param camera The camera to apply the render pass to.
  35405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35406. * @param engine The engine which the post process will be applied. (default: current engine)
  35407. * @param reusable If the post process can be reused on the same frame. (default: false)
  35408. * @param textureType Type of textures used when performing the post process. (default: 0)
  35409. * @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)
  35410. */
  35411. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35412. }
  35413. }
  35414. declare module BABYLON {
  35415. /**
  35416. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35417. */
  35418. class StereoscopicInterlacePostProcess extends PostProcess {
  35419. private _stepSize;
  35420. private _passedProcess;
  35421. /**
  35422. * Initializes a StereoscopicInterlacePostProcess
  35423. * @param name The name of the effect.
  35424. * @param rigCameras The rig cameras to be appled to the post process
  35425. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35427. * @param engine The engine which the post process will be applied. (default: current engine)
  35428. * @param reusable If the post process can be reused on the same frame. (default: false)
  35429. */
  35430. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35431. }
  35432. }
  35433. declare module BABYLON {
  35434. /** Defines operator used for tonemapping */
  35435. enum TonemappingOperator {
  35436. /** Hable */
  35437. Hable = 0,
  35438. /** Reinhard */
  35439. Reinhard = 1,
  35440. /** HejiDawson */
  35441. HejiDawson = 2,
  35442. /** Photographic */
  35443. Photographic = 3
  35444. }
  35445. /**
  35446. * Defines a post process to apply tone mapping
  35447. */
  35448. class TonemapPostProcess extends PostProcess {
  35449. private _operator;
  35450. /** Defines the required exposure adjustement */
  35451. exposureAdjustment: number;
  35452. /**
  35453. * Creates a new TonemapPostProcess
  35454. * @param name defines the name of the postprocess
  35455. * @param _operator defines the operator to use
  35456. * @param exposureAdjustment defines the required exposure adjustement
  35457. * @param camera defines the camera to use (can be null)
  35458. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35459. * @param engine defines the hosting engine (can be ignore if camera is set)
  35460. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35461. */
  35462. constructor(name: string, _operator: TonemappingOperator,
  35463. /** Defines the required exposure adjustement */
  35464. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35465. }
  35466. }
  35467. declare module BABYLON {
  35468. /**
  35469. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35470. */
  35471. class VolumetricLightScatteringPostProcess extends PostProcess {
  35472. private _volumetricLightScatteringPass;
  35473. private _volumetricLightScatteringRTT;
  35474. private _viewPort;
  35475. private _screenCoordinates;
  35476. private _cachedDefines;
  35477. /**
  35478. * If not undefined, the mesh position is computed from the attached node position
  35479. */
  35480. attachedNode: {
  35481. position: Vector3;
  35482. };
  35483. /**
  35484. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35485. */
  35486. customMeshPosition: Vector3;
  35487. /**
  35488. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35489. */
  35490. useCustomMeshPosition: boolean;
  35491. /**
  35492. * If the post-process should inverse the light scattering direction
  35493. */
  35494. invert: boolean;
  35495. /**
  35496. * The internal mesh used by the post-process
  35497. */
  35498. mesh: Mesh;
  35499. /**
  35500. * @hidden
  35501. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35502. */
  35503. useDiffuseColor: boolean;
  35504. /**
  35505. * Array containing the excluded meshes not rendered in the internal pass
  35506. */
  35507. excludedMeshes: AbstractMesh[];
  35508. /**
  35509. * Controls the overall intensity of the post-process
  35510. */
  35511. exposure: number;
  35512. /**
  35513. * Dissipates each sample's contribution in range [0, 1]
  35514. */
  35515. decay: number;
  35516. /**
  35517. * Controls the overall intensity of each sample
  35518. */
  35519. weight: number;
  35520. /**
  35521. * Controls the density of each sample
  35522. */
  35523. density: number;
  35524. /**
  35525. * @constructor
  35526. * @param name The post-process name
  35527. * @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)
  35528. * @param camera The camera that the post-process will be attached to
  35529. * @param mesh The mesh used to create the light scattering
  35530. * @param samples The post-process quality, default 100
  35531. * @param samplingModeThe post-process filtering mode
  35532. * @param engine The babylon engine
  35533. * @param reusable If the post-process is reusable
  35534. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35535. */
  35536. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35537. /**
  35538. * Returns the string "VolumetricLightScatteringPostProcess"
  35539. * @returns "VolumetricLightScatteringPostProcess"
  35540. */
  35541. getClassName(): string;
  35542. private _isReady;
  35543. /**
  35544. * Sets the new light position for light scattering effect
  35545. * @param position The new custom light position
  35546. */
  35547. setCustomMeshPosition(position: Vector3): void;
  35548. /**
  35549. * Returns the light position for light scattering effect
  35550. * @return Vector3 The custom light position
  35551. */
  35552. getCustomMeshPosition(): Vector3;
  35553. /**
  35554. * Disposes the internal assets and detaches the post-process from the camera
  35555. */
  35556. dispose(camera: Camera): void;
  35557. /**
  35558. * Returns the render target texture used by the post-process
  35559. * @return the render target texture used by the post-process
  35560. */
  35561. getPass(): RenderTargetTexture;
  35562. private _meshExcluded;
  35563. private _createPass;
  35564. private _updateMeshScreenCoordinates;
  35565. /**
  35566. * Creates a default mesh for the Volumeric Light Scattering post-process
  35567. * @param name The mesh name
  35568. * @param scene The scene where to create the mesh
  35569. * @return the default mesh
  35570. */
  35571. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35572. }
  35573. }
  35574. declare module BABYLON {
  35575. /**
  35576. * VRDistortionCorrectionPostProcess used for mobile VR
  35577. */
  35578. class VRDistortionCorrectionPostProcess extends PostProcess {
  35579. private _isRightEye;
  35580. private _distortionFactors;
  35581. private _postProcessScaleFactor;
  35582. private _lensCenterOffset;
  35583. private _scaleIn;
  35584. private _scaleFactor;
  35585. private _lensCenter;
  35586. /**
  35587. * Initializes the VRDistortionCorrectionPostProcess
  35588. * @param name The name of the effect.
  35589. * @param camera The camera to apply the render pass to.
  35590. * @param isRightEye If this is for the right eye distortion
  35591. * @param vrMetrics All the required metrics for the VR camera
  35592. */
  35593. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35594. }
  35595. }
  35596. declare module BABYLON {
  35597. interface Scene {
  35598. /** @hidden (Backing field) */
  35599. _boundingBoxRenderer: BoundingBoxRenderer;
  35600. /** @hidden (Backing field) */
  35601. _forceShowBoundingBoxes: boolean;
  35602. /**
  35603. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35604. */
  35605. forceShowBoundingBoxes: boolean;
  35606. /**
  35607. * Gets the bounding box renderer associated with the scene
  35608. * @returns a BoundingBoxRenderer
  35609. */
  35610. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35611. }
  35612. interface AbstractMesh {
  35613. /** @hidden (Backing field) */
  35614. _showBoundingBox: boolean;
  35615. /**
  35616. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35617. */
  35618. showBoundingBox: boolean;
  35619. }
  35620. /**
  35621. * Component responsible of rendering the bounding box of the meshes in a scene.
  35622. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35623. */
  35624. class BoundingBoxRenderer implements ISceneComponent {
  35625. /**
  35626. * The component name helpfull to identify the component in the list of scene components.
  35627. */
  35628. readonly name: string;
  35629. /**
  35630. * The scene the component belongs to.
  35631. */
  35632. scene: Scene;
  35633. /**
  35634. * Color of the bounding box lines placed in front of an object
  35635. */
  35636. frontColor: Color3;
  35637. /**
  35638. * Color of the bounding box lines placed behind an object
  35639. */
  35640. backColor: Color3;
  35641. /**
  35642. * Defines if the renderer should show the back lines or not
  35643. */
  35644. showBackLines: boolean;
  35645. /**
  35646. * @hidden
  35647. */
  35648. renderList: SmartArray<BoundingBox>;
  35649. private _colorShader;
  35650. private _vertexBuffers;
  35651. private _indexBuffer;
  35652. /**
  35653. * Instantiates a new bounding box renderer in a scene.
  35654. * @param scene the scene the renderer renders in
  35655. */
  35656. constructor(scene: Scene);
  35657. /**
  35658. * Registers the component in a given scene
  35659. */
  35660. register(): void;
  35661. private _evaluateSubMesh;
  35662. private _activeMesh;
  35663. private _prepareRessources;
  35664. private _createIndexBuffer;
  35665. /**
  35666. * Rebuilds the elements related to this component in case of
  35667. * context lost for instance.
  35668. */
  35669. rebuild(): void;
  35670. /**
  35671. * @hidden
  35672. */
  35673. reset(): void;
  35674. /**
  35675. * Render the bounding boxes of a specific rendering group
  35676. * @param renderingGroupId defines the rendering group to render
  35677. */
  35678. render(renderingGroupId: number): void;
  35679. /**
  35680. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35681. * @param mesh Define the mesh to render the occlusion bounding box for
  35682. */
  35683. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35684. /**
  35685. * Dispose and release the resources attached to this renderer.
  35686. */
  35687. dispose(): void;
  35688. }
  35689. }
  35690. declare module BABYLON {
  35691. /**
  35692. * This represents a depth renderer in Babylon.
  35693. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35694. */
  35695. class DepthRenderer {
  35696. private _scene;
  35697. private _depthMap;
  35698. private _effect;
  35699. private _cachedDefines;
  35700. private _camera;
  35701. /**
  35702. * Specifiess that the depth renderer will only be used within
  35703. * the camera it is created for.
  35704. * This can help forcing its rendering during the camera processing.
  35705. */
  35706. useOnlyInActiveCamera: boolean;
  35707. /**
  35708. * Instantiates a depth renderer
  35709. * @param scene The scene the renderer belongs to
  35710. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35711. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35712. */
  35713. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35714. /**
  35715. * Creates the depth rendering effect and checks if the effect is ready.
  35716. * @param subMesh The submesh to be used to render the depth map of
  35717. * @param useInstances If multiple world instances should be used
  35718. * @returns if the depth renderer is ready to render the depth map
  35719. */
  35720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35721. /**
  35722. * Gets the texture which the depth map will be written to.
  35723. * @returns The depth map texture
  35724. */
  35725. getDepthMap(): RenderTargetTexture;
  35726. /**
  35727. * Disposes of the depth renderer.
  35728. */
  35729. dispose(): void;
  35730. }
  35731. }
  35732. declare module BABYLON {
  35733. interface Scene {
  35734. /** @hidden (Backing field) */
  35735. _depthRenderer: {
  35736. [id: string]: DepthRenderer;
  35737. };
  35738. /**
  35739. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35740. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35741. * @returns the created depth renderer
  35742. */
  35743. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35744. /**
  35745. * Disables a depth renderer for a given camera
  35746. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35747. */
  35748. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35749. }
  35750. /**
  35751. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35752. * in several rendering techniques.
  35753. */
  35754. class DepthRendererSceneComponent implements ISceneComponent {
  35755. /**
  35756. * The component name helpfull to identify the component in the list of scene components.
  35757. */
  35758. readonly name: string;
  35759. /**
  35760. * The scene the component belongs to.
  35761. */
  35762. scene: Scene;
  35763. /**
  35764. * Creates a new instance of the component for the given scene
  35765. * @param scene Defines the scene to register the component in
  35766. */
  35767. constructor(scene: Scene);
  35768. /**
  35769. * Registers the component in a given scene
  35770. */
  35771. register(): void;
  35772. /**
  35773. * Rebuilds the elements related to this component in case of
  35774. * context lost for instance.
  35775. */
  35776. rebuild(): void;
  35777. /**
  35778. * Disposes the component and the associated ressources
  35779. */
  35780. dispose(): void;
  35781. private _gatherRenderTargets;
  35782. private _gatherActiveCameraRenderTargets;
  35783. }
  35784. }
  35785. declare module BABYLON {
  35786. interface AbstractMesh {
  35787. /**
  35788. * Disables the mesh edge rendering mode
  35789. * @returns the currentAbstractMesh
  35790. */
  35791. disableEdgesRendering(): AbstractMesh;
  35792. /**
  35793. * Enables the edge rendering mode on the mesh.
  35794. * This mode makes the mesh edges visible
  35795. * @param epsilon defines the maximal distance between two angles to detect a face
  35796. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35797. * @returns the currentAbstractMesh
  35798. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35799. */
  35800. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35801. /**
  35802. * Gets the edgesRenderer associated with the mesh
  35803. */
  35804. edgesRenderer: Nullable<EdgesRenderer>;
  35805. }
  35806. interface LinesMesh {
  35807. /**
  35808. * Enables the edge rendering mode on the mesh.
  35809. * This mode makes the mesh edges visible
  35810. * @param epsilon defines the maximal distance between two angles to detect a face
  35811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35812. * @returns the currentAbstractMesh
  35813. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35814. */
  35815. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35816. }
  35817. interface InstancedLinesMesh {
  35818. /**
  35819. * Enables the edge rendering mode on the mesh.
  35820. * This mode makes the mesh edges visible
  35821. * @param epsilon defines the maximal distance between two angles to detect a face
  35822. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35823. * @returns the current InstancedLinesMesh
  35824. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35825. */
  35826. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  35827. }
  35828. /**
  35829. * Defines the minimum contract an Edges renderer should follow.
  35830. */
  35831. interface IEdgesRenderer extends IDisposable {
  35832. /**
  35833. * Gets or sets a boolean indicating if the edgesRenderer is active
  35834. */
  35835. isEnabled: boolean;
  35836. /**
  35837. * Renders the edges of the attached mesh,
  35838. */
  35839. render(): void;
  35840. /**
  35841. * Checks wether or not the edges renderer is ready to render.
  35842. * @return true if ready, otherwise false.
  35843. */
  35844. isReady(): boolean;
  35845. }
  35846. /**
  35847. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35848. */
  35849. class EdgesRenderer implements IEdgesRenderer {
  35850. /**
  35851. * Define the size of the edges with an orthographic camera
  35852. */
  35853. edgesWidthScalerForOrthographic: number;
  35854. /**
  35855. * Define the size of the edges with a perspective camera
  35856. */
  35857. edgesWidthScalerForPerspective: number;
  35858. protected _source: AbstractMesh;
  35859. protected _linesPositions: number[];
  35860. protected _linesNormals: number[];
  35861. protected _linesIndices: number[];
  35862. protected _epsilon: number;
  35863. protected _indicesCount: number;
  35864. protected _lineShader: ShaderMaterial;
  35865. protected _ib: WebGLBuffer;
  35866. protected _buffers: {
  35867. [key: string]: Nullable<VertexBuffer>;
  35868. };
  35869. protected _checkVerticesInsteadOfIndices: boolean;
  35870. private _meshRebuildObserver;
  35871. private _meshDisposeObserver;
  35872. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35873. isEnabled: boolean;
  35874. /**
  35875. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35876. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35877. * @param source Mesh used to create edges
  35878. * @param epsilon sum of angles in adjacency to check for edge
  35879. * @param checkVerticesInsteadOfIndices
  35880. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35881. */
  35882. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35883. protected _prepareRessources(): void;
  35884. /** @hidden */
  35885. _rebuild(): void;
  35886. /**
  35887. * Releases the required resources for the edges renderer
  35888. */
  35889. dispose(): void;
  35890. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35891. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35892. /**
  35893. * Checks if the pair of p0 and p1 is en edge
  35894. * @param faceIndex
  35895. * @param edge
  35896. * @param faceNormals
  35897. * @param p0
  35898. * @param p1
  35899. * @private
  35900. */
  35901. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35902. /**
  35903. * push line into the position, normal and index buffer
  35904. * @protected
  35905. */
  35906. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  35907. /**
  35908. * Generates lines edges from adjacencjes
  35909. * @private
  35910. */
  35911. _generateEdgesLines(): void;
  35912. /**
  35913. * Checks wether or not the edges renderer is ready to render.
  35914. * @return true if ready, otherwise false.
  35915. */
  35916. isReady(): boolean;
  35917. /**
  35918. * Renders the edges of the attached mesh,
  35919. */
  35920. render(): void;
  35921. }
  35922. }
  35923. declare module BABYLON {
  35924. /**
  35925. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35926. */
  35927. class GeometryBufferRenderer {
  35928. /**
  35929. * Constant used to retrieve the position texture index in the G-Buffer textures array
  35930. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  35931. */
  35932. static readonly POSITION_TEXTURE_TYPE: number;
  35933. /**
  35934. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  35935. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  35936. */
  35937. static readonly VELOCITY_TEXTURE_TYPE: number;
  35938. /**
  35939. * Dictionary used to store the previous transformation matrices of each rendered mesh
  35940. * in order to compute objects velocities when enableVelocity is set to "true"
  35941. * @hidden
  35942. */
  35943. _previousTransformationMatrices: {
  35944. [index: number]: Matrix;
  35945. };
  35946. private _scene;
  35947. private _multiRenderTarget;
  35948. private _ratio;
  35949. private _enablePosition;
  35950. private _enableVelocity;
  35951. private _positionIndex;
  35952. private _velocityIndex;
  35953. protected _effect: Effect;
  35954. protected _cachedDefines: string;
  35955. /**
  35956. * Set the render list (meshes to be rendered) used in the G buffer.
  35957. */
  35958. renderList: Mesh[];
  35959. /**
  35960. * Gets wether or not G buffer are supported by the running hardware.
  35961. * This requires draw buffer supports
  35962. */
  35963. readonly isSupported: boolean;
  35964. /**
  35965. * Returns the index of the given texture type in the G-Buffer textures array
  35966. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  35967. * @returns the index of the given texture type in the G-Buffer textures array
  35968. */
  35969. getTextureIndex(textureType: number): number;
  35970. /**
  35971. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  35972. */
  35973. /**
  35974. * Sets whether or not objects positions are enabled for the G buffer.
  35975. */
  35976. enablePosition: boolean;
  35977. /**
  35978. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  35979. */
  35980. /**
  35981. * Sets wether or not objects velocities are enabled for the G buffer.
  35982. */
  35983. enableVelocity: boolean;
  35984. /**
  35985. * Gets the scene associated with the buffer.
  35986. */
  35987. readonly scene: Scene;
  35988. /**
  35989. * Gets the ratio used by the buffer during its creation.
  35990. * How big is the buffer related to the main canvas.
  35991. */
  35992. readonly ratio: number;
  35993. /**
  35994. * Creates a new G Buffer for the scene
  35995. * @param scene The scene the buffer belongs to
  35996. * @param ratio How big is the buffer related to the main canvas.
  35997. */
  35998. constructor(scene: Scene, ratio?: number);
  35999. /**
  36000. * Checks wether everything is ready to render a submesh to the G buffer.
  36001. * @param subMesh the submesh to check readiness for
  36002. * @param useInstances is the mesh drawn using instance or not
  36003. * @returns true if ready otherwise false
  36004. */
  36005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36006. /**
  36007. * Gets the current underlying G Buffer.
  36008. * @returns the buffer
  36009. */
  36010. getGBuffer(): MultiRenderTarget;
  36011. /**
  36012. * Gets the number of samples used to render the buffer (anti aliasing).
  36013. */
  36014. /**
  36015. * Sets the number of samples used to render the buffer (anti aliasing).
  36016. */
  36017. samples: number;
  36018. /**
  36019. * Disposes the renderer and frees up associated resources.
  36020. */
  36021. dispose(): void;
  36022. protected _createRenderTargets(): void;
  36023. }
  36024. }
  36025. declare module BABYLON {
  36026. interface Scene {
  36027. /** @hidden (Backing field) */
  36028. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36029. /**
  36030. * Gets or Sets the current geometry buffer associated to the scene.
  36031. */
  36032. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36033. /**
  36034. * Enables a GeometryBufferRender and associates it with the scene
  36035. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36036. * @returns the GeometryBufferRenderer
  36037. */
  36038. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36039. /**
  36040. * Disables the GeometryBufferRender associated with the scene
  36041. */
  36042. disableGeometryBufferRenderer(): void;
  36043. }
  36044. /**
  36045. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36046. * in several rendering techniques.
  36047. */
  36048. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36049. /**
  36050. * The component name helpful to identify the component in the list of scene components.
  36051. */
  36052. readonly name: string;
  36053. /**
  36054. * The scene the component belongs to.
  36055. */
  36056. scene: Scene;
  36057. /**
  36058. * Creates a new instance of the component for the given scene
  36059. * @param scene Defines the scene to register the component in
  36060. */
  36061. constructor(scene: Scene);
  36062. /**
  36063. * Registers the component in a given scene
  36064. */
  36065. register(): void;
  36066. /**
  36067. * Rebuilds the elements related to this component in case of
  36068. * context lost for instance.
  36069. */
  36070. rebuild(): void;
  36071. /**
  36072. * Disposes the component and the associated ressources
  36073. */
  36074. dispose(): void;
  36075. private _gatherRenderTargets;
  36076. }
  36077. }
  36078. declare module BABYLON {
  36079. /**
  36080. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36081. */
  36082. class LineEdgesRenderer extends EdgesRenderer {
  36083. /**
  36084. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36085. * @param source LineMesh used to generate edges
  36086. * @param epsilon not important (specified angle for edge detection)
  36087. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36088. */
  36089. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36090. /**
  36091. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36092. */
  36093. _generateEdgesLines(): void;
  36094. }
  36095. }
  36096. declare module BABYLON {
  36097. interface Scene {
  36098. /** @hidden */
  36099. _outlineRenderer: OutlineRenderer;
  36100. /**
  36101. * Gets the outline renderer associated with the scene
  36102. * @returns a OutlineRenderer
  36103. */
  36104. getOutlineRenderer(): OutlineRenderer;
  36105. }
  36106. interface AbstractMesh {
  36107. /** @hidden (Backing field) */
  36108. _renderOutline: boolean;
  36109. /**
  36110. * Gets or sets a boolean indicating if the outline must be rendered as well
  36111. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36112. */
  36113. renderOutline: boolean;
  36114. /** @hidden (Backing field) */
  36115. _renderOverlay: boolean;
  36116. /**
  36117. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36118. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36119. */
  36120. renderOverlay: boolean;
  36121. }
  36122. /**
  36123. * This class is responsible to draw bothe outline/overlay of meshes.
  36124. * It should not be used directly but through the available method on mesh.
  36125. */
  36126. class OutlineRenderer implements ISceneComponent {
  36127. /**
  36128. * The name of the component. Each component must have a unique name.
  36129. */
  36130. name: string;
  36131. /**
  36132. * The scene the component belongs to.
  36133. */
  36134. scene: Scene;
  36135. /**
  36136. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36137. */
  36138. zOffset: number;
  36139. private _engine;
  36140. private _effect;
  36141. private _cachedDefines;
  36142. private _savedDepthWrite;
  36143. /**
  36144. * Instantiates a new outline renderer. (There could be only one per scene).
  36145. * @param scene Defines the scene it belongs to
  36146. */
  36147. constructor(scene: Scene);
  36148. /**
  36149. * Register the component to one instance of a scene.
  36150. */
  36151. register(): void;
  36152. /**
  36153. * Rebuilds the elements related to this component in case of
  36154. * context lost for instance.
  36155. */
  36156. rebuild(): void;
  36157. /**
  36158. * Disposes the component and the associated ressources.
  36159. */
  36160. dispose(): void;
  36161. /**
  36162. * Renders the outline in the canvas.
  36163. * @param subMesh Defines the sumesh to render
  36164. * @param batch Defines the batch of meshes in case of instances
  36165. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36166. */
  36167. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36168. /**
  36169. * Returns whether or not the outline renderer is ready for a given submesh.
  36170. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36171. * @param subMesh Defines the submesh to check readyness for
  36172. * @param useInstances Defines wheter wee are trying to render instances or not
  36173. * @returns true if ready otherwise false
  36174. */
  36175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36176. private _beforeRenderingMesh;
  36177. private _afterRenderingMesh;
  36178. }
  36179. }
  36180. declare module BABYLON {
  36181. /**
  36182. * This represents the object necessary to create a rendering group.
  36183. * This is exclusively used and created by the rendering manager.
  36184. * To modify the behavior, you use the available helpers in your scene or meshes.
  36185. * @hidden
  36186. */
  36187. class RenderingGroup {
  36188. index: number;
  36189. private _scene;
  36190. private _opaqueSubMeshes;
  36191. private _transparentSubMeshes;
  36192. private _alphaTestSubMeshes;
  36193. private _depthOnlySubMeshes;
  36194. private _particleSystems;
  36195. private _spriteManagers;
  36196. private _opaqueSortCompareFn;
  36197. private _alphaTestSortCompareFn;
  36198. private _transparentSortCompareFn;
  36199. private _renderOpaque;
  36200. private _renderAlphaTest;
  36201. private _renderTransparent;
  36202. private _edgesRenderers;
  36203. onBeforeTransparentRendering: () => void;
  36204. /**
  36205. * Set the opaque sort comparison function.
  36206. * If null the sub meshes will be render in the order they were created
  36207. */
  36208. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36209. /**
  36210. * Set the alpha test sort comparison function.
  36211. * If null the sub meshes will be render in the order they were created
  36212. */
  36213. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36214. /**
  36215. * Set the transparent sort comparison function.
  36216. * If null the sub meshes will be render in the order they were created
  36217. */
  36218. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36219. /**
  36220. * Creates a new rendering group.
  36221. * @param index The rendering group index
  36222. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36223. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36224. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36225. */
  36226. 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>);
  36227. /**
  36228. * Render all the sub meshes contained in the group.
  36229. * @param customRenderFunction Used to override the default render behaviour of the group.
  36230. * @returns true if rendered some submeshes.
  36231. */
  36232. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36233. /**
  36234. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36235. * @param subMeshes The submeshes to render
  36236. */
  36237. private renderOpaqueSorted;
  36238. /**
  36239. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36240. * @param subMeshes The submeshes to render
  36241. */
  36242. private renderAlphaTestSorted;
  36243. /**
  36244. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36245. * @param subMeshes The submeshes to render
  36246. */
  36247. private renderTransparentSorted;
  36248. /**
  36249. * Renders the submeshes in a specified order.
  36250. * @param subMeshes The submeshes to sort before render
  36251. * @param sortCompareFn The comparison function use to sort
  36252. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36253. * @param transparent Specifies to activate blending if true
  36254. */
  36255. private static renderSorted;
  36256. /**
  36257. * Renders the submeshes in the order they were dispatched (no sort applied).
  36258. * @param subMeshes The submeshes to render
  36259. */
  36260. private static renderUnsorted;
  36261. /**
  36262. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36263. * are rendered back to front if in the same alpha index.
  36264. *
  36265. * @param a The first submesh
  36266. * @param b The second submesh
  36267. * @returns The result of the comparison
  36268. */
  36269. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36270. /**
  36271. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36272. * are rendered back to front.
  36273. *
  36274. * @param a The first submesh
  36275. * @param b The second submesh
  36276. * @returns The result of the comparison
  36277. */
  36278. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36279. /**
  36280. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36281. * are rendered front to back (prevent overdraw).
  36282. *
  36283. * @param a The first submesh
  36284. * @param b The second submesh
  36285. * @returns The result of the comparison
  36286. */
  36287. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36288. /**
  36289. * Resets the different lists of submeshes to prepare a new frame.
  36290. */
  36291. prepare(): void;
  36292. dispose(): void;
  36293. /**
  36294. * Inserts the submesh in its correct queue depending on its material.
  36295. * @param subMesh The submesh to dispatch
  36296. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36297. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36298. */
  36299. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36300. dispatchSprites(spriteManager: ISpriteManager): void;
  36301. dispatchParticles(particleSystem: IParticleSystem): void;
  36302. private _renderParticles;
  36303. private _renderSprites;
  36304. }
  36305. }
  36306. declare module BABYLON {
  36307. /**
  36308. * Interface describing the different options available in the rendering manager
  36309. * regarding Auto Clear between groups.
  36310. */
  36311. interface IRenderingManagerAutoClearSetup {
  36312. /**
  36313. * Defines whether or not autoclear is enable.
  36314. */
  36315. autoClear: boolean;
  36316. /**
  36317. * Defines whether or not to autoclear the depth buffer.
  36318. */
  36319. depth: boolean;
  36320. /**
  36321. * Defines whether or not to autoclear the stencil buffer.
  36322. */
  36323. stencil: boolean;
  36324. }
  36325. /**
  36326. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36327. * It is enable to manage the different groups as well as the different necessary sort functions.
  36328. * This should not be used directly aside of the few static configurations
  36329. */
  36330. class RenderingManager {
  36331. /**
  36332. * The max id used for rendering groups (not included)
  36333. */
  36334. static MAX_RENDERINGGROUPS: number;
  36335. /**
  36336. * The min id used for rendering groups (included)
  36337. */
  36338. static MIN_RENDERINGGROUPS: number;
  36339. /**
  36340. * Used to globally prevent autoclearing scenes.
  36341. */
  36342. static AUTOCLEAR: boolean;
  36343. /**
  36344. * @hidden
  36345. */
  36346. _useSceneAutoClearSetup: boolean;
  36347. private _scene;
  36348. private _renderingGroups;
  36349. private _depthStencilBufferAlreadyCleaned;
  36350. private _autoClearDepthStencil;
  36351. private _customOpaqueSortCompareFn;
  36352. private _customAlphaTestSortCompareFn;
  36353. private _customTransparentSortCompareFn;
  36354. private _renderingGroupInfo;
  36355. /**
  36356. * Instantiates a new rendering group for a particular scene
  36357. * @param scene Defines the scene the groups belongs to
  36358. */
  36359. constructor(scene: Scene);
  36360. private _clearDepthStencilBuffer;
  36361. /**
  36362. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36363. * @hidden
  36364. */
  36365. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36366. /**
  36367. * Resets the different information of the group to prepare a new frame
  36368. * @hidden
  36369. */
  36370. reset(): void;
  36371. /**
  36372. * Dispose and release the group and its associated resources.
  36373. * @hidden
  36374. */
  36375. dispose(): void;
  36376. /**
  36377. * Clear the info related to rendering groups preventing retention points during dispose.
  36378. */
  36379. freeRenderingGroups(): void;
  36380. private _prepareRenderingGroup;
  36381. /**
  36382. * Add a sprite manager to the rendering manager in order to render it this frame.
  36383. * @param spriteManager Define the sprite manager to render
  36384. */
  36385. dispatchSprites(spriteManager: ISpriteManager): void;
  36386. /**
  36387. * Add a particle system to the rendering manager in order to render it this frame.
  36388. * @param particleSystem Define the particle system to render
  36389. */
  36390. dispatchParticles(particleSystem: IParticleSystem): void;
  36391. /**
  36392. * Add a submesh to the manager in order to render it this frame
  36393. * @param subMesh The submesh to dispatch
  36394. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36395. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36396. */
  36397. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36398. /**
  36399. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36400. * This allowed control for front to back rendering or reversly depending of the special needs.
  36401. *
  36402. * @param renderingGroupId The rendering group id corresponding to its index
  36403. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36404. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36405. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36406. */
  36407. 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;
  36408. /**
  36409. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36410. *
  36411. * @param renderingGroupId The rendering group id corresponding to its index
  36412. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36413. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36414. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36415. */
  36416. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36417. /**
  36418. * Gets the current auto clear configuration for one rendering group of the rendering
  36419. * manager.
  36420. * @param index the rendering group index to get the information for
  36421. * @returns The auto clear setup for the requested rendering group
  36422. */
  36423. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36424. }
  36425. }
  36426. declare module BABYLON {
  36427. /**
  36428. * Renders a layer on top of an existing scene
  36429. */
  36430. class UtilityLayerRenderer implements IDisposable {
  36431. /** the original scene that will be rendered on top of */
  36432. originalScene: Scene;
  36433. private _pointerCaptures;
  36434. private _lastPointerEvents;
  36435. private static _DefaultUtilityLayer;
  36436. private static _DefaultKeepDepthUtilityLayer;
  36437. /**
  36438. * 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)
  36439. */
  36440. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36441. /**
  36442. * 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)
  36443. */
  36444. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36445. /**
  36446. * The scene that is rendered on top of the original scene
  36447. */
  36448. utilityLayerScene: Scene;
  36449. /**
  36450. * If the utility layer should automatically be rendered on top of existing scene
  36451. */
  36452. shouldRender: boolean;
  36453. /**
  36454. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36455. */
  36456. onlyCheckPointerDownEvents: boolean;
  36457. /**
  36458. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36459. */
  36460. processAllEvents: boolean;
  36461. /**
  36462. * Observable raised when the pointer move from the utility layer scene to the main scene
  36463. */
  36464. onPointerOutObservable: Observable<number>;
  36465. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36466. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36467. private _afterRenderObserver;
  36468. private _sceneDisposeObserver;
  36469. private _originalPointerObserver;
  36470. /**
  36471. * Instantiates a UtilityLayerRenderer
  36472. * @param originalScene the original scene that will be rendered on top of
  36473. */
  36474. constructor(
  36475. /** the original scene that will be rendered on top of */
  36476. originalScene: Scene);
  36477. private _notifyObservers;
  36478. /**
  36479. * Renders the utility layers scene on top of the original scene
  36480. */
  36481. render(): void;
  36482. /**
  36483. * Disposes of the renderer
  36484. */
  36485. dispose(): void;
  36486. private _updateCamera;
  36487. }
  36488. }
  36489. declare module BABYLON {
  36490. /**
  36491. * Class used to represent a sprite
  36492. * @see http://doc.babylonjs.com/babylon101/sprites
  36493. */
  36494. class Sprite {
  36495. /** defines the name */
  36496. name: string;
  36497. /** Gets or sets the current world position */
  36498. position: Vector3;
  36499. /** Gets or sets the main color */
  36500. color: Color4;
  36501. /** Gets or sets the width */
  36502. width: number;
  36503. /** Gets or sets the height */
  36504. height: number;
  36505. /** Gets or sets rotation angle */
  36506. angle: number;
  36507. /** Gets or sets the cell index in the sprite sheet */
  36508. cellIndex: number;
  36509. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36510. invertU: number;
  36511. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36512. invertV: number;
  36513. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36514. disposeWhenFinishedAnimating: boolean;
  36515. /** Gets the list of attached animations */
  36516. animations: Animation[];
  36517. /** Gets or sets a boolean indicating if the sprite can be picked */
  36518. isPickable: boolean;
  36519. /**
  36520. * Gets or sets the associated action manager
  36521. */
  36522. actionManager: Nullable<ActionManager>;
  36523. private _animationStarted;
  36524. private _loopAnimation;
  36525. private _fromIndex;
  36526. private _toIndex;
  36527. private _delay;
  36528. private _direction;
  36529. private _manager;
  36530. private _time;
  36531. private _onAnimationEnd;
  36532. /**
  36533. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36534. */
  36535. isVisible: boolean;
  36536. /**
  36537. * Gets or sets the sprite size
  36538. */
  36539. size: number;
  36540. /**
  36541. * Creates a new Sprite
  36542. * @param name defines the name
  36543. * @param manager defines the manager
  36544. */
  36545. constructor(
  36546. /** defines the name */
  36547. name: string, manager: ISpriteManager);
  36548. /**
  36549. * Starts an animation
  36550. * @param from defines the initial key
  36551. * @param to defines the end key
  36552. * @param loop defines if the animation must loop
  36553. * @param delay defines the start delay (in ms)
  36554. * @param onAnimationEnd defines a callback to call when animation ends
  36555. */
  36556. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36557. /** Stops current animation (if any) */
  36558. stopAnimation(): void;
  36559. /** @hidden */
  36560. _animate(deltaTime: number): void;
  36561. /** Release associated resources */
  36562. dispose(): void;
  36563. }
  36564. }
  36565. declare module BABYLON {
  36566. /**
  36567. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36568. */
  36569. interface ISpriteManager extends IDisposable {
  36570. /**
  36571. * Restricts the camera to viewing objects with the same layerMask.
  36572. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36573. */
  36574. layerMask: number;
  36575. /**
  36576. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36577. */
  36578. isPickable: boolean;
  36579. /**
  36580. * Specifies the rendering group id for this mesh (0 by default)
  36581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36582. */
  36583. renderingGroupId: number;
  36584. /**
  36585. * Defines the list of sprites managed by the manager.
  36586. */
  36587. sprites: Array<Sprite>;
  36588. /**
  36589. * Tests the intersection of a sprite with a specific ray.
  36590. * @param ray The ray we are sending to test the collision
  36591. * @param camera The camera space we are sending rays in
  36592. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36593. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36594. * @returns picking info or null.
  36595. */
  36596. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36597. /**
  36598. * Renders the list of sprites on screen.
  36599. */
  36600. render(): void;
  36601. }
  36602. /**
  36603. * Class used to manage multiple sprites on the same spritesheet
  36604. * @see http://doc.babylonjs.com/babylon101/sprites
  36605. */
  36606. class SpriteManager implements ISpriteManager {
  36607. /** defines the manager's name */
  36608. name: string;
  36609. /** Gets the list of sprites */
  36610. sprites: Sprite[];
  36611. /** Gets or sets the rendering group id (0 by default) */
  36612. renderingGroupId: number;
  36613. /** Gets or sets camera layer mask */
  36614. layerMask: number;
  36615. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36616. fogEnabled: boolean;
  36617. /** Gets or sets a boolean indicating if the sprites are pickable */
  36618. isPickable: boolean;
  36619. /** Defines the default width of a cell in the spritesheet */
  36620. cellWidth: number;
  36621. /** Defines the default height of a cell in the spritesheet */
  36622. cellHeight: number;
  36623. /**
  36624. * An event triggered when the manager is disposed.
  36625. */
  36626. onDisposeObservable: Observable<SpriteManager>;
  36627. private _onDisposeObserver;
  36628. /**
  36629. * Callback called when the manager is disposed
  36630. */
  36631. onDispose: () => void;
  36632. private _capacity;
  36633. private _spriteTexture;
  36634. private _epsilon;
  36635. private _scene;
  36636. private _vertexData;
  36637. private _buffer;
  36638. private _vertexBuffers;
  36639. private _indexBuffer;
  36640. private _effectBase;
  36641. private _effectFog;
  36642. /**
  36643. * Gets or sets the spritesheet texture
  36644. */
  36645. texture: Texture;
  36646. /**
  36647. * Creates a new sprite manager
  36648. * @param name defines the manager's name
  36649. * @param imgUrl defines the sprite sheet url
  36650. * @param capacity defines the maximum allowed number of sprites
  36651. * @param cellSize defines the size of a sprite cell
  36652. * @param scene defines the hosting scene
  36653. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36654. * @param samplingMode defines the smapling mode to use with spritesheet
  36655. */
  36656. constructor(
  36657. /** defines the manager's name */
  36658. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36659. private _appendSpriteVertex;
  36660. /**
  36661. * Intersects the sprites with a ray
  36662. * @param ray defines the ray to intersect with
  36663. * @param camera defines the current active camera
  36664. * @param predicate defines a predicate used to select candidate sprites
  36665. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36666. * @returns null if no hit or a PickingInfo
  36667. */
  36668. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36669. /**
  36670. * Render all child sprites
  36671. */
  36672. render(): void;
  36673. /**
  36674. * Release associated resources
  36675. */
  36676. dispose(): void;
  36677. }
  36678. }
  36679. declare module BABYLON {
  36680. interface Scene {
  36681. /** @hidden */
  36682. _pointerOverSprite: Nullable<Sprite>;
  36683. /** @hidden */
  36684. _pickedDownSprite: Nullable<Sprite>;
  36685. /** @hidden */
  36686. _tempSpritePickingRay: Nullable<Ray>;
  36687. /**
  36688. * All of the sprite managers added to this scene
  36689. * @see http://doc.babylonjs.com/babylon101/sprites
  36690. */
  36691. spriteManagers: Array<ISpriteManager>;
  36692. /**
  36693. * An event triggered when sprites rendering is about to start
  36694. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36695. */
  36696. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36697. /**
  36698. * An event triggered when sprites rendering is done
  36699. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36700. */
  36701. onAfterSpritesRenderingObservable: Observable<Scene>;
  36702. /** @hidden */
  36703. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36704. /** Launch a ray to try to pick a sprite in the scene
  36705. * @param x position on screen
  36706. * @param y position on screen
  36707. * @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
  36708. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36709. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36710. * @returns a PickingInfo
  36711. */
  36712. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36713. /** Use the given ray to pick a sprite in the scene
  36714. * @param ray The ray (in world space) to use to pick meshes
  36715. * @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
  36716. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36717. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36718. * @returns a PickingInfo
  36719. */
  36720. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36721. /**
  36722. * Force the sprite under the pointer
  36723. * @param sprite defines the sprite to use
  36724. */
  36725. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36726. /**
  36727. * Gets the sprite under the pointer
  36728. * @returns a Sprite or null if no sprite is under the pointer
  36729. */
  36730. getPointerOverSprite(): Nullable<Sprite>;
  36731. }
  36732. /**
  36733. * Defines the sprite scene component responsible to manage sprites
  36734. * in a given scene.
  36735. */
  36736. class SpriteSceneComponent implements ISceneComponent {
  36737. /**
  36738. * The component name helpfull to identify the component in the list of scene components.
  36739. */
  36740. readonly name: string;
  36741. /**
  36742. * The scene the component belongs to.
  36743. */
  36744. scene: Scene;
  36745. /** @hidden */
  36746. private _spritePredicate;
  36747. /**
  36748. * Creates a new instance of the component for the given scene
  36749. * @param scene Defines the scene to register the component in
  36750. */
  36751. constructor(scene: Scene);
  36752. /**
  36753. * Registers the component in a given scene
  36754. */
  36755. register(): void;
  36756. /**
  36757. * Rebuilds the elements related to this component in case of
  36758. * context lost for instance.
  36759. */
  36760. rebuild(): void;
  36761. /**
  36762. * Disposes the component and the associated ressources.
  36763. */
  36764. dispose(): void;
  36765. private _pickSpriteButKeepRay;
  36766. private _pointerMove;
  36767. private _pointerDown;
  36768. private _pointerUp;
  36769. }
  36770. }
  36771. declare module BABYLON {
  36772. /**
  36773. * @hidden
  36774. **/
  36775. class _AlphaState {
  36776. private _isAlphaBlendDirty;
  36777. private _isBlendFunctionParametersDirty;
  36778. private _isBlendEquationParametersDirty;
  36779. private _isBlendConstantsDirty;
  36780. private _alphaBlend;
  36781. private _blendFunctionParameters;
  36782. private _blendEquationParameters;
  36783. private _blendConstants;
  36784. /**
  36785. * Initializes the state.
  36786. */
  36787. constructor();
  36788. readonly isDirty: boolean;
  36789. alphaBlend: boolean;
  36790. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36791. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36792. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36793. reset(): void;
  36794. apply(gl: WebGLRenderingContext): void;
  36795. }
  36796. }
  36797. declare module BABYLON {
  36798. /**
  36799. * @hidden
  36800. **/
  36801. class _DepthCullingState {
  36802. private _isDepthTestDirty;
  36803. private _isDepthMaskDirty;
  36804. private _isDepthFuncDirty;
  36805. private _isCullFaceDirty;
  36806. private _isCullDirty;
  36807. private _isZOffsetDirty;
  36808. private _isFrontFaceDirty;
  36809. private _depthTest;
  36810. private _depthMask;
  36811. private _depthFunc;
  36812. private _cull;
  36813. private _cullFace;
  36814. private _zOffset;
  36815. private _frontFace;
  36816. /**
  36817. * Initializes the state.
  36818. */
  36819. constructor();
  36820. readonly isDirty: boolean;
  36821. zOffset: number;
  36822. cullFace: Nullable<number>;
  36823. cull: Nullable<boolean>;
  36824. depthFunc: Nullable<number>;
  36825. depthMask: boolean;
  36826. depthTest: boolean;
  36827. frontFace: Nullable<number>;
  36828. reset(): void;
  36829. apply(gl: WebGLRenderingContext): void;
  36830. }
  36831. }
  36832. declare module BABYLON {
  36833. /**
  36834. * @hidden
  36835. **/
  36836. class _StencilState {
  36837. private _isStencilTestDirty;
  36838. private _isStencilMaskDirty;
  36839. private _isStencilFuncDirty;
  36840. private _isStencilOpDirty;
  36841. private _stencilTest;
  36842. private _stencilMask;
  36843. private _stencilFunc;
  36844. private _stencilFuncRef;
  36845. private _stencilFuncMask;
  36846. private _stencilOpStencilFail;
  36847. private _stencilOpDepthFail;
  36848. private _stencilOpStencilDepthPass;
  36849. readonly isDirty: boolean;
  36850. stencilFunc: number;
  36851. stencilFuncRef: number;
  36852. stencilFuncMask: number;
  36853. stencilOpStencilFail: number;
  36854. stencilOpDepthFail: number;
  36855. stencilOpStencilDepthPass: number;
  36856. stencilMask: number;
  36857. stencilTest: boolean;
  36858. constructor();
  36859. reset(): void;
  36860. apply(gl: WebGLRenderingContext): void;
  36861. }
  36862. }
  36863. declare module BABYLON {
  36864. /**
  36865. * Class used to evalaute queries containing `and` and `or` operators
  36866. */
  36867. class AndOrNotEvaluator {
  36868. /**
  36869. * Evaluate a query
  36870. * @param query defines the query to evaluate
  36871. * @param evaluateCallback defines the callback used to filter result
  36872. * @returns true if the query matches
  36873. */
  36874. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36875. private static _HandleParenthesisContent;
  36876. private static _SimplifyNegation;
  36877. }
  36878. }
  36879. declare module BABYLON {
  36880. /**
  36881. * Defines the list of states available for a task inside a AssetsManager
  36882. */
  36883. enum AssetTaskState {
  36884. /**
  36885. * Initialization
  36886. */
  36887. INIT = 0,
  36888. /**
  36889. * Running
  36890. */
  36891. RUNNING = 1,
  36892. /**
  36893. * Done
  36894. */
  36895. DONE = 2,
  36896. /**
  36897. * Error
  36898. */
  36899. ERROR = 3
  36900. }
  36901. /**
  36902. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36903. */
  36904. abstract class AbstractAssetTask {
  36905. /**
  36906. * Task name
  36907. */ name: string;
  36908. /**
  36909. * Callback called when the task is successful
  36910. */
  36911. onSuccess: (task: any) => void;
  36912. /**
  36913. * Callback called when the task is not successful
  36914. */
  36915. onError: (task: any, message?: string, exception?: any) => void;
  36916. /**
  36917. * Creates a new AssetsManager
  36918. * @param name defines the name of the task
  36919. */
  36920. constructor(
  36921. /**
  36922. * Task name
  36923. */ name: string);
  36924. private _isCompleted;
  36925. private _taskState;
  36926. private _errorObject;
  36927. /**
  36928. * Get if the task is completed
  36929. */
  36930. readonly isCompleted: boolean;
  36931. /**
  36932. * Gets the current state of the task
  36933. */
  36934. readonly taskState: AssetTaskState;
  36935. /**
  36936. * Gets the current error object (if task is in error)
  36937. */
  36938. readonly errorObject: {
  36939. message?: string;
  36940. exception?: any;
  36941. };
  36942. /**
  36943. * Internal only
  36944. * @hidden
  36945. */
  36946. _setErrorObject(message?: string, exception?: any): void;
  36947. /**
  36948. * Execute the current task
  36949. * @param scene defines the scene where you want your assets to be loaded
  36950. * @param onSuccess is a callback called when the task is successfully executed
  36951. * @param onError is a callback called if an error occurs
  36952. */
  36953. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36954. /**
  36955. * Execute the current task
  36956. * @param scene defines the scene where you want your assets to be loaded
  36957. * @param onSuccess is a callback called when the task is successfully executed
  36958. * @param onError is a callback called if an error occurs
  36959. */
  36960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36961. /**
  36962. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36963. * This can be used with failed tasks that have the reason for failure fixed.
  36964. */
  36965. reset(): void;
  36966. private onErrorCallback;
  36967. private onDoneCallback;
  36968. }
  36969. /**
  36970. * Define the interface used by progress events raised during assets loading
  36971. */
  36972. interface IAssetsProgressEvent {
  36973. /**
  36974. * Defines the number of remaining tasks to process
  36975. */
  36976. remainingCount: number;
  36977. /**
  36978. * Defines the total number of tasks
  36979. */
  36980. totalCount: number;
  36981. /**
  36982. * Defines the task that was just processed
  36983. */
  36984. task: AbstractAssetTask;
  36985. }
  36986. /**
  36987. * Class used to share progress information about assets loading
  36988. */
  36989. class AssetsProgressEvent implements IAssetsProgressEvent {
  36990. /**
  36991. * Defines the number of remaining tasks to process
  36992. */
  36993. remainingCount: number;
  36994. /**
  36995. * Defines the total number of tasks
  36996. */
  36997. totalCount: number;
  36998. /**
  36999. * Defines the task that was just processed
  37000. */
  37001. task: AbstractAssetTask;
  37002. /**
  37003. * Creates a AssetsProgressEvent
  37004. * @param remainingCount defines the number of remaining tasks to process
  37005. * @param totalCount defines the total number of tasks
  37006. * @param task defines the task that was just processed
  37007. */
  37008. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37009. }
  37010. /**
  37011. * Define a task used by AssetsManager to load meshes
  37012. */
  37013. class MeshAssetTask extends AbstractAssetTask {
  37014. /**
  37015. * Defines the name of the task
  37016. */
  37017. name: string;
  37018. /**
  37019. * Defines the list of mesh's names you want to load
  37020. */
  37021. meshesNames: any;
  37022. /**
  37023. * Defines the root url to use as a base to load your meshes and associated resources
  37024. */
  37025. rootUrl: string;
  37026. /**
  37027. * Defines the filename of the scene to load from
  37028. */
  37029. sceneFilename: string;
  37030. /**
  37031. * Gets the list of loaded meshes
  37032. */
  37033. loadedMeshes: Array<AbstractMesh>;
  37034. /**
  37035. * Gets the list of loaded particle systems
  37036. */
  37037. loadedParticleSystems: Array<IParticleSystem>;
  37038. /**
  37039. * Gets the list of loaded skeletons
  37040. */
  37041. loadedSkeletons: Array<Skeleton>;
  37042. /**
  37043. * Callback called when the task is successful
  37044. */
  37045. onSuccess: (task: MeshAssetTask) => void;
  37046. /**
  37047. * Callback called when the task is successful
  37048. */
  37049. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37050. /**
  37051. * Creates a new MeshAssetTask
  37052. * @param name defines the name of the task
  37053. * @param meshesNames defines the list of mesh's names you want to load
  37054. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37055. * @param sceneFilename defines the filename of the scene to load from
  37056. */
  37057. constructor(
  37058. /**
  37059. * Defines the name of the task
  37060. */
  37061. name: string,
  37062. /**
  37063. * Defines the list of mesh's names you want to load
  37064. */
  37065. meshesNames: any,
  37066. /**
  37067. * Defines the root url to use as a base to load your meshes and associated resources
  37068. */
  37069. rootUrl: string,
  37070. /**
  37071. * Defines the filename of the scene to load from
  37072. */
  37073. sceneFilename: string);
  37074. /**
  37075. * Execute the current task
  37076. * @param scene defines the scene where you want your assets to be loaded
  37077. * @param onSuccess is a callback called when the task is successfully executed
  37078. * @param onError is a callback called if an error occurs
  37079. */
  37080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37081. }
  37082. /**
  37083. * Define a task used by AssetsManager to load text content
  37084. */
  37085. class TextFileAssetTask extends AbstractAssetTask {
  37086. /**
  37087. * Defines the name of the task
  37088. */
  37089. name: string;
  37090. /**
  37091. * Defines the location of the file to load
  37092. */
  37093. url: string;
  37094. /**
  37095. * Gets the loaded text string
  37096. */
  37097. text: string;
  37098. /**
  37099. * Callback called when the task is successful
  37100. */
  37101. onSuccess: (task: TextFileAssetTask) => void;
  37102. /**
  37103. * Callback called when the task is successful
  37104. */
  37105. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37106. /**
  37107. * Creates a new TextFileAssetTask object
  37108. * @param name defines the name of the task
  37109. * @param url defines the location of the file to load
  37110. */
  37111. constructor(
  37112. /**
  37113. * Defines the name of the task
  37114. */
  37115. name: string,
  37116. /**
  37117. * Defines the location of the file to load
  37118. */
  37119. url: string);
  37120. /**
  37121. * Execute the current task
  37122. * @param scene defines the scene where you want your assets to be loaded
  37123. * @param onSuccess is a callback called when the task is successfully executed
  37124. * @param onError is a callback called if an error occurs
  37125. */
  37126. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37127. }
  37128. /**
  37129. * Define a task used by AssetsManager to load binary data
  37130. */
  37131. class BinaryFileAssetTask extends AbstractAssetTask {
  37132. /**
  37133. * Defines the name of the task
  37134. */
  37135. name: string;
  37136. /**
  37137. * Defines the location of the file to load
  37138. */
  37139. url: string;
  37140. /**
  37141. * Gets the lodaded data (as an array buffer)
  37142. */
  37143. data: ArrayBuffer;
  37144. /**
  37145. * Callback called when the task is successful
  37146. */
  37147. onSuccess: (task: BinaryFileAssetTask) => void;
  37148. /**
  37149. * Callback called when the task is successful
  37150. */
  37151. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37152. /**
  37153. * Creates a new BinaryFileAssetTask object
  37154. * @param name defines the name of the new task
  37155. * @param url defines the location of the file to load
  37156. */
  37157. constructor(
  37158. /**
  37159. * Defines the name of the task
  37160. */
  37161. name: string,
  37162. /**
  37163. * Defines the location of the file to load
  37164. */
  37165. url: string);
  37166. /**
  37167. * Execute the current task
  37168. * @param scene defines the scene where you want your assets to be loaded
  37169. * @param onSuccess is a callback called when the task is successfully executed
  37170. * @param onError is a callback called if an error occurs
  37171. */
  37172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37173. }
  37174. /**
  37175. * Define a task used by AssetsManager to load images
  37176. */
  37177. class ImageAssetTask extends AbstractAssetTask {
  37178. /**
  37179. * Defines the name of the task
  37180. */
  37181. name: string;
  37182. /**
  37183. * Defines the location of the image to load
  37184. */
  37185. url: string;
  37186. /**
  37187. * Gets the loaded images
  37188. */
  37189. image: HTMLImageElement;
  37190. /**
  37191. * Callback called when the task is successful
  37192. */
  37193. onSuccess: (task: ImageAssetTask) => void;
  37194. /**
  37195. * Callback called when the task is successful
  37196. */
  37197. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37198. /**
  37199. * Creates a new ImageAssetTask
  37200. * @param name defines the name of the task
  37201. * @param url defines the location of the image to load
  37202. */
  37203. constructor(
  37204. /**
  37205. * Defines the name of the task
  37206. */
  37207. name: string,
  37208. /**
  37209. * Defines the location of the image to load
  37210. */
  37211. url: string);
  37212. /**
  37213. * Execute the current task
  37214. * @param scene defines the scene where you want your assets to be loaded
  37215. * @param onSuccess is a callback called when the task is successfully executed
  37216. * @param onError is a callback called if an error occurs
  37217. */
  37218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37219. }
  37220. /**
  37221. * Defines the interface used by texture loading tasks
  37222. */
  37223. interface ITextureAssetTask<TEX extends BaseTexture> {
  37224. /**
  37225. * Gets the loaded texture
  37226. */
  37227. texture: TEX;
  37228. }
  37229. /**
  37230. * Define a task used by AssetsManager to load 2D textures
  37231. */
  37232. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37233. /**
  37234. * Defines the name of the task
  37235. */
  37236. name: string;
  37237. /**
  37238. * Defines the location of the file to load
  37239. */
  37240. url: string;
  37241. /**
  37242. * Defines if mipmap should not be generated (default is false)
  37243. */
  37244. noMipmap?: boolean | undefined;
  37245. /**
  37246. * Defines if texture must be inverted on Y axis (default is false)
  37247. */
  37248. invertY?: boolean | undefined;
  37249. /**
  37250. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37251. */
  37252. samplingMode: number;
  37253. /**
  37254. * Gets the loaded texture
  37255. */
  37256. texture: Texture;
  37257. /**
  37258. * Callback called when the task is successful
  37259. */
  37260. onSuccess: (task: TextureAssetTask) => void;
  37261. /**
  37262. * Callback called when the task is successful
  37263. */
  37264. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37265. /**
  37266. * Creates a new TextureAssetTask object
  37267. * @param name defines the name of the task
  37268. * @param url defines the location of the file to load
  37269. * @param noMipmap defines if mipmap should not be generated (default is false)
  37270. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37271. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37272. */
  37273. constructor(
  37274. /**
  37275. * Defines the name of the task
  37276. */
  37277. name: string,
  37278. /**
  37279. * Defines the location of the file to load
  37280. */
  37281. url: string,
  37282. /**
  37283. * Defines if mipmap should not be generated (default is false)
  37284. */
  37285. noMipmap?: boolean | undefined,
  37286. /**
  37287. * Defines if texture must be inverted on Y axis (default is false)
  37288. */
  37289. invertY?: boolean | undefined,
  37290. /**
  37291. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37292. */
  37293. samplingMode?: number);
  37294. /**
  37295. * Execute the current task
  37296. * @param scene defines the scene where you want your assets to be loaded
  37297. * @param onSuccess is a callback called when the task is successfully executed
  37298. * @param onError is a callback called if an error occurs
  37299. */
  37300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37301. }
  37302. /**
  37303. * Define a task used by AssetsManager to load cube textures
  37304. */
  37305. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37306. /**
  37307. * Defines the name of the task
  37308. */
  37309. name: string;
  37310. /**
  37311. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37312. */
  37313. url: string;
  37314. /**
  37315. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37316. */
  37317. extensions?: string[] | undefined;
  37318. /**
  37319. * Defines if mipmaps should not be generated (default is false)
  37320. */
  37321. noMipmap?: boolean | undefined;
  37322. /**
  37323. * Defines the explicit list of files (undefined by default)
  37324. */
  37325. files?: string[] | undefined;
  37326. /**
  37327. * Gets the loaded texture
  37328. */
  37329. texture: CubeTexture;
  37330. /**
  37331. * Callback called when the task is successful
  37332. */
  37333. onSuccess: (task: CubeTextureAssetTask) => void;
  37334. /**
  37335. * Callback called when the task is successful
  37336. */
  37337. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37338. /**
  37339. * Creates a new CubeTextureAssetTask
  37340. * @param name defines the name of the task
  37341. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37342. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37343. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37344. * @param files defines the explicit list of files (undefined by default)
  37345. */
  37346. constructor(
  37347. /**
  37348. * Defines the name of the task
  37349. */
  37350. name: string,
  37351. /**
  37352. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37353. */
  37354. url: string,
  37355. /**
  37356. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37357. */
  37358. extensions?: string[] | undefined,
  37359. /**
  37360. * Defines if mipmaps should not be generated (default is false)
  37361. */
  37362. noMipmap?: boolean | undefined,
  37363. /**
  37364. * Defines the explicit list of files (undefined by default)
  37365. */
  37366. files?: string[] | undefined);
  37367. /**
  37368. * Execute the current task
  37369. * @param scene defines the scene where you want your assets to be loaded
  37370. * @param onSuccess is a callback called when the task is successfully executed
  37371. * @param onError is a callback called if an error occurs
  37372. */
  37373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37374. }
  37375. /**
  37376. * Define a task used by AssetsManager to load HDR cube textures
  37377. */
  37378. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37379. /**
  37380. * Defines the name of the task
  37381. */
  37382. name: string;
  37383. /**
  37384. * Defines the location of the file to load
  37385. */
  37386. url: string;
  37387. /**
  37388. * Defines the desired size (the more it increases the longer the generation will be)
  37389. */
  37390. size: number;
  37391. /**
  37392. * Defines if mipmaps should not be generated (default is false)
  37393. */
  37394. noMipmap: boolean;
  37395. /**
  37396. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37397. */
  37398. generateHarmonics: boolean;
  37399. /**
  37400. * 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)
  37401. */
  37402. gammaSpace: boolean;
  37403. /**
  37404. * Internal Use Only
  37405. */
  37406. reserved: boolean;
  37407. /**
  37408. * Gets the loaded texture
  37409. */
  37410. texture: HDRCubeTexture;
  37411. /**
  37412. * Callback called when the task is successful
  37413. */
  37414. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37415. /**
  37416. * Callback called when the task is successful
  37417. */
  37418. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37419. /**
  37420. * Creates a new HDRCubeTextureAssetTask object
  37421. * @param name defines the name of the task
  37422. * @param url defines the location of the file to load
  37423. * @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.
  37424. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37425. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37426. * @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)
  37427. * @param reserved Internal use only
  37428. */
  37429. constructor(
  37430. /**
  37431. * Defines the name of the task
  37432. */
  37433. name: string,
  37434. /**
  37435. * Defines the location of the file to load
  37436. */
  37437. url: string,
  37438. /**
  37439. * Defines the desired size (the more it increases the longer the generation will be)
  37440. */
  37441. size: number,
  37442. /**
  37443. * Defines if mipmaps should not be generated (default is false)
  37444. */
  37445. noMipmap?: boolean,
  37446. /**
  37447. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37448. */
  37449. generateHarmonics?: boolean,
  37450. /**
  37451. * 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)
  37452. */
  37453. gammaSpace?: boolean,
  37454. /**
  37455. * Internal Use Only
  37456. */
  37457. reserved?: boolean);
  37458. /**
  37459. * Execute the current task
  37460. * @param scene defines the scene where you want your assets to be loaded
  37461. * @param onSuccess is a callback called when the task is successfully executed
  37462. * @param onError is a callback called if an error occurs
  37463. */
  37464. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37465. }
  37466. /**
  37467. * This class can be used to easily import assets into a scene
  37468. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37469. */
  37470. class AssetsManager {
  37471. private _scene;
  37472. private _isLoading;
  37473. protected _tasks: AbstractAssetTask[];
  37474. protected _waitingTasksCount: number;
  37475. protected _totalTasksCount: number;
  37476. /**
  37477. * Callback called when all tasks are processed
  37478. */
  37479. onFinish: (tasks: AbstractAssetTask[]) => void;
  37480. /**
  37481. * Callback called when a task is successful
  37482. */
  37483. onTaskSuccess: (task: AbstractAssetTask) => void;
  37484. /**
  37485. * Callback called when a task had an error
  37486. */
  37487. onTaskError: (task: AbstractAssetTask) => void;
  37488. /**
  37489. * Callback called when a task is done (whatever the result is)
  37490. */
  37491. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37492. /**
  37493. * Observable called when all tasks are processed
  37494. */
  37495. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37496. /**
  37497. * Observable called when a task had an error
  37498. */
  37499. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37500. /**
  37501. * Observable called when a task is successful
  37502. */
  37503. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37504. /**
  37505. * Observable called when a task is done (whatever the result is)
  37506. */
  37507. onProgressObservable: Observable<IAssetsProgressEvent>;
  37508. /**
  37509. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37511. */
  37512. useDefaultLoadingScreen: boolean;
  37513. /**
  37514. * Creates a new AssetsManager
  37515. * @param scene defines the scene to work on
  37516. */
  37517. constructor(scene: Scene);
  37518. /**
  37519. * Add a MeshAssetTask to the list of active tasks
  37520. * @param taskName defines the name of the new task
  37521. * @param meshesNames defines the name of meshes to load
  37522. * @param rootUrl defines the root url to use to locate files
  37523. * @param sceneFilename defines the filename of the scene file
  37524. * @returns a new MeshAssetTask object
  37525. */
  37526. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37527. /**
  37528. * Add a TextFileAssetTask to the list of active tasks
  37529. * @param taskName defines the name of the new task
  37530. * @param url defines the url of the file to load
  37531. * @returns a new TextFileAssetTask object
  37532. */
  37533. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37534. /**
  37535. * Add a BinaryFileAssetTask to the list of active tasks
  37536. * @param taskName defines the name of the new task
  37537. * @param url defines the url of the file to load
  37538. * @returns a new BinaryFileAssetTask object
  37539. */
  37540. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37541. /**
  37542. * Add a ImageAssetTask to the list of active tasks
  37543. * @param taskName defines the name of the new task
  37544. * @param url defines the url of the file to load
  37545. * @returns a new ImageAssetTask object
  37546. */
  37547. addImageTask(taskName: string, url: string): ImageAssetTask;
  37548. /**
  37549. * Add a TextureAssetTask to the list of active tasks
  37550. * @param taskName defines the name of the new task
  37551. * @param url defines the url of the file to load
  37552. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37553. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37554. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37555. * @returns a new TextureAssetTask object
  37556. */
  37557. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37558. /**
  37559. * Add a CubeTextureAssetTask to the list of active tasks
  37560. * @param taskName defines the name of the new task
  37561. * @param url defines the url of the file to load
  37562. * @param extensions defines the extension to use to load the cube map (can be null)
  37563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37564. * @param files defines the list of files to load (can be null)
  37565. * @returns a new CubeTextureAssetTask object
  37566. */
  37567. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37568. /**
  37569. *
  37570. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37571. * @param taskName defines the name of the new task
  37572. * @param url defines the url of the file to load
  37573. * @param size defines the size you want for the cubemap (can be null)
  37574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37575. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37576. * @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)
  37577. * @param reserved Internal use only
  37578. * @returns a new HDRCubeTextureAssetTask object
  37579. */
  37580. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37581. /**
  37582. * Remove a task from the assets manager.
  37583. * @param task the task to remove
  37584. */
  37585. removeTask(task: AbstractAssetTask): void;
  37586. private _decreaseWaitingTasksCount;
  37587. private _runTask;
  37588. /**
  37589. * Reset the AssetsManager and remove all tasks
  37590. * @return the current instance of the AssetsManager
  37591. */
  37592. reset(): AssetsManager;
  37593. /**
  37594. * Start the loading process
  37595. * @return the current instance of the AssetsManager
  37596. */
  37597. load(): AssetsManager;
  37598. }
  37599. }
  37600. declare module BABYLON {
  37601. /**
  37602. * Direct draw surface info
  37603. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37604. */
  37605. interface DDSInfo {
  37606. /**
  37607. * Width of the texture
  37608. */
  37609. width: number;
  37610. /**
  37611. * Width of the texture
  37612. */
  37613. height: number;
  37614. /**
  37615. * Number of Mipmaps for the texture
  37616. * @see https://en.wikipedia.org/wiki/Mipmap
  37617. */
  37618. mipmapCount: number;
  37619. /**
  37620. * If the textures format is a known fourCC format
  37621. * @see https://www.fourcc.org/
  37622. */
  37623. isFourCC: boolean;
  37624. /**
  37625. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37626. */
  37627. isRGB: boolean;
  37628. /**
  37629. * If the texture is a lumincance format
  37630. */
  37631. isLuminance: boolean;
  37632. /**
  37633. * If this is a cube texture
  37634. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37635. */
  37636. isCube: boolean;
  37637. /**
  37638. * If the texture is a compressed format eg. FOURCC_DXT1
  37639. */
  37640. isCompressed: boolean;
  37641. /**
  37642. * The dxgiFormat of the texture
  37643. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37644. */
  37645. dxgiFormat: number;
  37646. /**
  37647. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37648. */
  37649. textureType: number;
  37650. /**
  37651. * Sphericle polynomial created for the dds texture
  37652. */
  37653. sphericalPolynomial?: SphericalPolynomial;
  37654. }
  37655. /**
  37656. * Class used to provide DDS decompression tools
  37657. */
  37658. class DDSTools {
  37659. /**
  37660. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37661. */
  37662. static StoreLODInAlphaChannel: boolean;
  37663. /**
  37664. * Gets DDS information from an array buffer
  37665. * @param arrayBuffer defines the array buffer to read data from
  37666. * @returns the DDS information
  37667. */
  37668. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37669. private static _FloatView;
  37670. private static _Int32View;
  37671. private static _ToHalfFloat;
  37672. private static _FromHalfFloat;
  37673. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37674. private static _GetHalfFloatRGBAArrayBuffer;
  37675. private static _GetFloatRGBAArrayBuffer;
  37676. private static _GetFloatAsUIntRGBAArrayBuffer;
  37677. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37678. private static _GetRGBAArrayBuffer;
  37679. private static _ExtractLongWordOrder;
  37680. private static _GetRGBArrayBuffer;
  37681. private static _GetLuminanceArrayBuffer;
  37682. /**
  37683. * Uploads DDS Levels to a Babylon Texture
  37684. * @hidden
  37685. */
  37686. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37691. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37692. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37693. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37694. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37695. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37696. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37697. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37698. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37699. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37700. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37701. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37702. /**
  37703. * Decorator used to define property that can be serialized as reference to a camera
  37704. * @param sourceName defines the name of the property to decorate
  37705. */
  37706. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37707. /**
  37708. * Class used to help serialization objects
  37709. */
  37710. class SerializationHelper {
  37711. /**
  37712. * Static function used to serialized a specific entity
  37713. * @param entity defines the entity to serialize
  37714. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37715. * @returns a JSON compatible object representing the serialization of the entity
  37716. */
  37717. static Serialize<T>(entity: T, serializationObject?: any): any;
  37718. /**
  37719. * Creates a new entity from a serialization data object
  37720. * @param creationFunction defines a function used to instanciated the new entity
  37721. * @param source defines the source serialization data
  37722. * @param scene defines the hosting scene
  37723. * @param rootUrl defines the root url for resources
  37724. * @returns a new entity
  37725. */
  37726. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37727. /**
  37728. * Clones an object
  37729. * @param creationFunction defines the function used to instanciate the new object
  37730. * @param source defines the source object
  37731. * @returns the cloned object
  37732. */
  37733. static Clone<T>(creationFunction: () => T, source: T): T;
  37734. /**
  37735. * Instanciates a new object based on a source one (some data will be shared between both object)
  37736. * @param creationFunction defines the function used to instanciate the new object
  37737. * @param source defines the source object
  37738. * @returns the new object
  37739. */
  37740. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37741. }
  37742. }
  37743. declare module BABYLON {
  37744. /**
  37745. * Wrapper class for promise with external resolve and reject.
  37746. */
  37747. class Deferred<T> {
  37748. /**
  37749. * The promise associated with this deferred object.
  37750. */
  37751. readonly promise: Promise<T>;
  37752. private _resolve;
  37753. private _reject;
  37754. /**
  37755. * The resolve method of the promise associated with this deferred object.
  37756. */
  37757. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37758. /**
  37759. * The reject method of the promise associated with this deferred object.
  37760. */
  37761. readonly reject: (reason?: any) => void;
  37762. /**
  37763. * Constructor for this deferred object.
  37764. */
  37765. constructor();
  37766. }
  37767. }
  37768. declare module BABYLON {
  37769. /**
  37770. * Raw texture data and descriptor sufficient for WebGL texture upload
  37771. */
  37772. interface EnvironmentTextureInfo {
  37773. /**
  37774. * Version of the environment map
  37775. */
  37776. version: number;
  37777. /**
  37778. * Width of image
  37779. */
  37780. width: number;
  37781. /**
  37782. * Irradiance information stored in the file.
  37783. */
  37784. irradiance: any;
  37785. /**
  37786. * Specular information stored in the file.
  37787. */
  37788. specular: any;
  37789. }
  37790. /**
  37791. * Sets of helpers addressing the serialization and deserialization of environment texture
  37792. * stored in a BabylonJS env file.
  37793. * Those files are usually stored as .env files.
  37794. */
  37795. class EnvironmentTextureTools {
  37796. /**
  37797. * Magic number identifying the env file.
  37798. */
  37799. private static _MagicBytes;
  37800. /**
  37801. * Gets the environment info from an env file.
  37802. * @param data The array buffer containing the .env bytes.
  37803. * @returns the environment file info (the json header) if successfully parsed.
  37804. */
  37805. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37806. /**
  37807. * Creates an environment texture from a loaded cube texture.
  37808. * @param texture defines the cube texture to convert in env file
  37809. * @return a promise containing the environment data if succesfull.
  37810. */
  37811. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37812. /**
  37813. * Creates a JSON representation of the spherical data.
  37814. * @param texture defines the texture containing the polynomials
  37815. * @return the JSON representation of the spherical info
  37816. */
  37817. private static _CreateEnvTextureIrradiance;
  37818. /**
  37819. * Uploads the texture info contained in the env file to the GPU.
  37820. * @param texture defines the internal texture to upload to
  37821. * @param arrayBuffer defines the buffer cotaining the data to load
  37822. * @param info defines the texture info retrieved through the GetEnvInfo method
  37823. * @returns a promise
  37824. */
  37825. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37826. /**
  37827. * Uploads the levels of image data to the GPU.
  37828. * @param texture defines the internal texture to upload to
  37829. * @param imageData defines the array buffer views of image data [mipmap][face]
  37830. * @returns a promise
  37831. */
  37832. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37833. /**
  37834. * Uploads spherical polynomials information to the texture.
  37835. * @param texture defines the texture we are trying to upload the information to
  37836. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37837. */
  37838. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37839. }
  37840. }
  37841. declare module BABYLON {
  37842. /**
  37843. * Class used to help managing file picking and drag'n'drop
  37844. */
  37845. class FilesInput {
  37846. /**
  37847. * List of files ready to be loaded
  37848. */
  37849. static FilesToLoad: {
  37850. [key: string]: File;
  37851. };
  37852. /**
  37853. * Callback called when a file is processed
  37854. */
  37855. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37856. private _engine;
  37857. private _currentScene;
  37858. private _sceneLoadedCallback;
  37859. private _progressCallback;
  37860. private _additionalRenderLoopLogicCallback;
  37861. private _textureLoadingCallback;
  37862. private _startingProcessingFilesCallback;
  37863. private _onReloadCallback;
  37864. private _errorCallback;
  37865. private _elementToMonitor;
  37866. private _sceneFileToLoad;
  37867. private _filesToLoad;
  37868. /**
  37869. * Creates a new FilesInput
  37870. * @param engine defines the rendering engine
  37871. * @param scene defines the hosting scene
  37872. * @param sceneLoadedCallback callback called when scene is loaded
  37873. * @param progressCallback callback called to track progress
  37874. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37875. * @param textureLoadingCallback callback called when a texture is loading
  37876. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37877. * @param onReloadCallback callback called when a reload is requested
  37878. * @param errorCallback callback call if an error occurs
  37879. */
  37880. 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);
  37881. private _dragEnterHandler;
  37882. private _dragOverHandler;
  37883. private _dropHandler;
  37884. /**
  37885. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37886. * @param elementToMonitor defines the DOM element to track
  37887. */
  37888. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37889. /**
  37890. * Release all associated resources
  37891. */
  37892. dispose(): void;
  37893. private renderFunction;
  37894. private drag;
  37895. private drop;
  37896. private _traverseFolder;
  37897. private _processFiles;
  37898. /**
  37899. * Load files from a drop event
  37900. * @param event defines the drop event to use as source
  37901. */
  37902. loadFiles(event: any): void;
  37903. private _processReload;
  37904. /**
  37905. * Reload the current scene from the loaded files
  37906. */
  37907. reload(): void;
  37908. }
  37909. }
  37910. declare module BABYLON {
  37911. /**
  37912. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37913. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37914. */
  37915. class KhronosTextureContainer {
  37916. /** contents of the KTX container file */
  37917. arrayBuffer: any;
  37918. private static HEADER_LEN;
  37919. private static COMPRESSED_2D;
  37920. private static COMPRESSED_3D;
  37921. private static TEX_2D;
  37922. private static TEX_3D;
  37923. /**
  37924. * Gets the openGL type
  37925. */
  37926. glType: number;
  37927. /**
  37928. * Gets the openGL type size
  37929. */
  37930. glTypeSize: number;
  37931. /**
  37932. * Gets the openGL format
  37933. */
  37934. glFormat: number;
  37935. /**
  37936. * Gets the openGL internal format
  37937. */
  37938. glInternalFormat: number;
  37939. /**
  37940. * Gets the base internal format
  37941. */
  37942. glBaseInternalFormat: number;
  37943. /**
  37944. * Gets image width in pixel
  37945. */
  37946. pixelWidth: number;
  37947. /**
  37948. * Gets image height in pixel
  37949. */
  37950. pixelHeight: number;
  37951. /**
  37952. * Gets image depth in pixels
  37953. */
  37954. pixelDepth: number;
  37955. /**
  37956. * Gets the number of array elements
  37957. */
  37958. numberOfArrayElements: number;
  37959. /**
  37960. * Gets the number of faces
  37961. */
  37962. numberOfFaces: number;
  37963. /**
  37964. * Gets the number of mipmap levels
  37965. */
  37966. numberOfMipmapLevels: number;
  37967. /**
  37968. * Gets the bytes of key value data
  37969. */
  37970. bytesOfKeyValueData: number;
  37971. /**
  37972. * Gets the load type
  37973. */
  37974. loadType: number;
  37975. /**
  37976. * Creates a new KhronosTextureContainer
  37977. * @param arrayBuffer contents of the KTX container file
  37978. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37979. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37980. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37981. */
  37982. constructor(
  37983. /** contents of the KTX container file */
  37984. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37985. /**
  37986. * Revert the endianness of a value.
  37987. * Not as fast hardware based, but will probably never need to use
  37988. * @param val defines the value to convert
  37989. * @returns the new value
  37990. */
  37991. switchEndianness(val: number): number;
  37992. /**
  37993. * Uploads KTX content to a Babylon Texture.
  37994. * It is assumed that the texture has already been created & is currently bound
  37995. * @hidden
  37996. */
  37997. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37998. private _upload2DCompressedLevels;
  37999. }
  38000. }
  38001. declare module BABYLON {
  38002. /**
  38003. * A class serves as a medium between the observable and its observers
  38004. */
  38005. class EventState {
  38006. /**
  38007. * Create a new EventState
  38008. * @param mask defines the mask associated with this state
  38009. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38010. * @param target defines the original target of the state
  38011. * @param currentTarget defines the current target of the state
  38012. */
  38013. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38014. /**
  38015. * Initialize the current event state
  38016. * @param mask defines the mask associated with this state
  38017. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38018. * @param target defines the original target of the state
  38019. * @param currentTarget defines the current target of the state
  38020. * @returns the current event state
  38021. */
  38022. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38023. /**
  38024. * An Observer can set this property to true to prevent subsequent observers of being notified
  38025. */
  38026. skipNextObservers: boolean;
  38027. /**
  38028. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38029. */
  38030. mask: number;
  38031. /**
  38032. * The object that originally notified the event
  38033. */
  38034. target?: any;
  38035. /**
  38036. * The current object in the bubbling phase
  38037. */
  38038. currentTarget?: any;
  38039. /**
  38040. * This will be populated with the return value of the last function that was executed.
  38041. * If it is the first function in the callback chain it will be the event data.
  38042. */
  38043. lastReturnValue?: any;
  38044. }
  38045. /**
  38046. * Represent an Observer registered to a given Observable object.
  38047. */
  38048. class Observer<T> {
  38049. /**
  38050. * Defines the callback to call when the observer is notified
  38051. */
  38052. callback: (eventData: T, eventState: EventState) => void;
  38053. /**
  38054. * Defines the mask of the observer (used to filter notifications)
  38055. */
  38056. mask: number;
  38057. /**
  38058. * Defines the current scope used to restore the JS context
  38059. */
  38060. scope: any;
  38061. /** @hidden */
  38062. _willBeUnregistered: boolean;
  38063. /**
  38064. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38065. */
  38066. unregisterOnNextCall: boolean;
  38067. /**
  38068. * Creates a new observer
  38069. * @param callback defines the callback to call when the observer is notified
  38070. * @param mask defines the mask of the observer (used to filter notifications)
  38071. * @param scope defines the current scope used to restore the JS context
  38072. */
  38073. constructor(
  38074. /**
  38075. * Defines the callback to call when the observer is notified
  38076. */
  38077. callback: (eventData: T, eventState: EventState) => void,
  38078. /**
  38079. * Defines the mask of the observer (used to filter notifications)
  38080. */
  38081. mask: number,
  38082. /**
  38083. * Defines the current scope used to restore the JS context
  38084. */
  38085. scope?: any);
  38086. }
  38087. /**
  38088. * Represent a list of observers registered to multiple Observables object.
  38089. */
  38090. class MultiObserver<T> {
  38091. private _observers;
  38092. private _observables;
  38093. /**
  38094. * Release associated resources
  38095. */
  38096. dispose(): void;
  38097. /**
  38098. * Raise a callback when one of the observable will notify
  38099. * @param observables defines a list of observables to watch
  38100. * @param callback defines the callback to call on notification
  38101. * @param mask defines the mask used to filter notifications
  38102. * @param scope defines the current scope used to restore the JS context
  38103. * @returns the new MultiObserver
  38104. */
  38105. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38106. }
  38107. /**
  38108. * The Observable class is a simple implementation of the Observable pattern.
  38109. *
  38110. * 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.
  38111. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38112. * 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).
  38113. * 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.
  38114. */
  38115. class Observable<T> {
  38116. private _observers;
  38117. private _eventState;
  38118. private _onObserverAdded;
  38119. /**
  38120. * Creates a new observable
  38121. * @param onObserverAdded defines a callback to call when a new observer is added
  38122. */
  38123. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38124. /**
  38125. * Create a new Observer with the specified callback
  38126. * @param callback the callback that will be executed for that Observer
  38127. * @param mask the mask used to filter observers
  38128. * @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.
  38129. * @param scope optional scope for the callback to be called from
  38130. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38131. * @returns the new observer created for the callback
  38132. */
  38133. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38134. /**
  38135. * Create a new Observer with the specified callback and unregisters after the next notification
  38136. * @param callback the callback that will be executed for that Observer
  38137. * @returns the new observer created for the callback
  38138. */
  38139. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38140. /**
  38141. * Remove an Observer from the Observable object
  38142. * @param observer the instance of the Observer to remove
  38143. * @returns false if it doesn't belong to this Observable
  38144. */
  38145. remove(observer: Nullable<Observer<T>>): boolean;
  38146. /**
  38147. * Remove a callback from the Observable object
  38148. * @param callback the callback to remove
  38149. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38150. * @returns false if it doesn't belong to this Observable
  38151. */
  38152. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38153. private _deferUnregister;
  38154. private _remove;
  38155. /**
  38156. * Notify all Observers by calling their respective callback with the given data
  38157. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38158. * @param eventData defines the data to send to all observers
  38159. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38160. * @param target defines the original target of the state
  38161. * @param currentTarget defines the current target of the state
  38162. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38163. */
  38164. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38165. /**
  38166. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38167. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38168. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38169. * and it is crucial that all callbacks will be executed.
  38170. * The order of the callbacks is kept, callbacks are not executed parallel.
  38171. *
  38172. * @param eventData The data to be sent to each callback
  38173. * @param mask is used to filter observers defaults to -1
  38174. * @param target defines the callback target (see EventState)
  38175. * @param currentTarget defines he current object in the bubbling phase
  38176. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38177. */
  38178. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38179. /**
  38180. * Notify a specific observer
  38181. * @param observer defines the observer to notify
  38182. * @param eventData defines the data to be sent to each callback
  38183. * @param mask is used to filter observers defaults to -1
  38184. */
  38185. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38186. /**
  38187. * Gets a boolean indicating if the observable has at least one observer
  38188. * @returns true is the Observable has at least one Observer registered
  38189. */
  38190. hasObservers(): boolean;
  38191. /**
  38192. * Clear the list of observers
  38193. */
  38194. clear(): void;
  38195. /**
  38196. * Clone the current observable
  38197. * @returns a new observable
  38198. */
  38199. clone(): Observable<T>;
  38200. /**
  38201. * Does this observable handles observer registered with a given mask
  38202. * @param mask defines the mask to be tested
  38203. * @return whether or not one observer registered with the given mask is handeled
  38204. **/
  38205. hasSpecificMask(mask?: number): boolean;
  38206. }
  38207. }
  38208. declare module BABYLON {
  38209. /**
  38210. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38211. */
  38212. class PerformanceMonitor {
  38213. private _enabled;
  38214. private _rollingFrameTime;
  38215. private _lastFrameTimeMs;
  38216. /**
  38217. * constructor
  38218. * @param frameSampleSize The number of samples required to saturate the sliding window
  38219. */
  38220. constructor(frameSampleSize?: number);
  38221. /**
  38222. * Samples current frame
  38223. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38224. */
  38225. sampleFrame(timeMs?: number): void;
  38226. /**
  38227. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38228. */
  38229. readonly averageFrameTime: number;
  38230. /**
  38231. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38232. */
  38233. readonly averageFrameTimeVariance: number;
  38234. /**
  38235. * Returns the frame time of the most recent frame
  38236. */
  38237. readonly instantaneousFrameTime: number;
  38238. /**
  38239. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38240. */
  38241. readonly averageFPS: number;
  38242. /**
  38243. * Returns the average framerate in frames per second using the most recent frame time
  38244. */
  38245. readonly instantaneousFPS: number;
  38246. /**
  38247. * Returns true if enough samples have been taken to completely fill the sliding window
  38248. */
  38249. readonly isSaturated: boolean;
  38250. /**
  38251. * Enables contributions to the sliding window sample set
  38252. */
  38253. enable(): void;
  38254. /**
  38255. * Disables contributions to the sliding window sample set
  38256. * Samples will not be interpolated over the disabled period
  38257. */
  38258. disable(): void;
  38259. /**
  38260. * Returns true if sampling is enabled
  38261. */
  38262. readonly isEnabled: boolean;
  38263. /**
  38264. * Resets performance monitor
  38265. */
  38266. reset(): void;
  38267. }
  38268. /**
  38269. * RollingAverage
  38270. *
  38271. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38272. */
  38273. class RollingAverage {
  38274. /**
  38275. * Current average
  38276. */
  38277. average: number;
  38278. /**
  38279. * Current variance
  38280. */
  38281. variance: number;
  38282. protected _samples: Array<number>;
  38283. protected _sampleCount: number;
  38284. protected _pos: number;
  38285. protected _m2: number;
  38286. /**
  38287. * constructor
  38288. * @param length The number of samples required to saturate the sliding window
  38289. */
  38290. constructor(length: number);
  38291. /**
  38292. * Adds a sample to the sample set
  38293. * @param v The sample value
  38294. */
  38295. add(v: number): void;
  38296. /**
  38297. * Returns previously added values or null if outside of history or outside the sliding window domain
  38298. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38299. * @return Value previously recorded with add() or null if outside of range
  38300. */
  38301. history(i: number): number;
  38302. /**
  38303. * Returns true if enough samples have been taken to completely fill the sliding window
  38304. * @return true if sample-set saturated
  38305. */
  38306. isSaturated(): boolean;
  38307. /**
  38308. * Resets the rolling average (equivalent to 0 samples taken so far)
  38309. */
  38310. reset(): void;
  38311. /**
  38312. * Wraps a value around the sample range boundaries
  38313. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38314. * @return Wrapped position in sample range
  38315. */
  38316. protected _wrapPosition(i: number): number;
  38317. }
  38318. }
  38319. declare module BABYLON {
  38320. /**
  38321. * Helper class that provides a small promise polyfill
  38322. */
  38323. class PromisePolyfill {
  38324. /**
  38325. * Static function used to check if the polyfill is required
  38326. * If this is the case then the function will inject the polyfill to window.Promise
  38327. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38328. */
  38329. static Apply(force?: boolean): void;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38336. */
  38337. class SceneOptimization {
  38338. /**
  38339. * Defines the priority of this optimization (0 by default which means first in the list)
  38340. */
  38341. priority: number;
  38342. /**
  38343. * Gets a string describing the action executed by the current optimization
  38344. * @returns description string
  38345. */
  38346. getDescription(): string;
  38347. /**
  38348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38349. * @param scene defines the current scene where to apply this optimization
  38350. * @param optimizer defines the current optimizer
  38351. * @returns true if everything that can be done was applied
  38352. */
  38353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38354. /**
  38355. * Creates the SceneOptimization object
  38356. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38357. * @param desc defines the description associated with the optimization
  38358. */
  38359. constructor(
  38360. /**
  38361. * Defines the priority of this optimization (0 by default which means first in the list)
  38362. */
  38363. priority?: number);
  38364. }
  38365. /**
  38366. * Defines an optimization used to reduce the size of render target textures
  38367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38368. */
  38369. class TextureOptimization extends SceneOptimization {
  38370. /**
  38371. * Defines the priority of this optimization (0 by default which means first in the list)
  38372. */
  38373. priority: number;
  38374. /**
  38375. * 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
  38376. */
  38377. maximumSize: number;
  38378. /**
  38379. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38380. */
  38381. step: number;
  38382. /**
  38383. * Gets a string describing the action executed by the current optimization
  38384. * @returns description string
  38385. */
  38386. getDescription(): string;
  38387. /**
  38388. * Creates the TextureOptimization object
  38389. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38390. * @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
  38391. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38392. */
  38393. constructor(
  38394. /**
  38395. * Defines the priority of this optimization (0 by default which means first in the list)
  38396. */
  38397. priority?: number,
  38398. /**
  38399. * 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
  38400. */
  38401. maximumSize?: number,
  38402. /**
  38403. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38404. */
  38405. step?: number);
  38406. /**
  38407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38408. * @param scene defines the current scene where to apply this optimization
  38409. * @param optimizer defines the current optimizer
  38410. * @returns true if everything that can be done was applied
  38411. */
  38412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38413. }
  38414. /**
  38415. * Defines an optimization used to increase or decrease the rendering resolution
  38416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38417. */
  38418. class HardwareScalingOptimization extends SceneOptimization {
  38419. /**
  38420. * Defines the priority of this optimization (0 by default which means first in the list)
  38421. */
  38422. priority: number;
  38423. /**
  38424. * Defines the maximum scale to use (2 by default)
  38425. */
  38426. maximumScale: number;
  38427. /**
  38428. * Defines the step to use between two passes (0.5 by default)
  38429. */
  38430. step: number;
  38431. private _currentScale;
  38432. private _directionOffset;
  38433. /**
  38434. * Gets a string describing the action executed by the current optimization
  38435. * @return description string
  38436. */
  38437. getDescription(): string;
  38438. /**
  38439. * Creates the HardwareScalingOptimization object
  38440. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38441. * @param maximumScale defines the maximum scale to use (2 by default)
  38442. * @param step defines the step to use between two passes (0.5 by default)
  38443. */
  38444. constructor(
  38445. /**
  38446. * Defines the priority of this optimization (0 by default which means first in the list)
  38447. */
  38448. priority?: number,
  38449. /**
  38450. * Defines the maximum scale to use (2 by default)
  38451. */
  38452. maximumScale?: number,
  38453. /**
  38454. * Defines the step to use between two passes (0.5 by default)
  38455. */
  38456. step?: number);
  38457. /**
  38458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38459. * @param scene defines the current scene where to apply this optimization
  38460. * @param optimizer defines the current optimizer
  38461. * @returns true if everything that can be done was applied
  38462. */
  38463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38464. }
  38465. /**
  38466. * Defines an optimization used to remove shadows
  38467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38468. */
  38469. class ShadowsOptimization extends SceneOptimization {
  38470. /**
  38471. * Gets a string describing the action executed by the current optimization
  38472. * @return description string
  38473. */
  38474. getDescription(): string;
  38475. /**
  38476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38477. * @param scene defines the current scene where to apply this optimization
  38478. * @param optimizer defines the current optimizer
  38479. * @returns true if everything that can be done was applied
  38480. */
  38481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38482. }
  38483. /**
  38484. * Defines an optimization used to turn post-processes off
  38485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38486. */
  38487. class PostProcessesOptimization extends SceneOptimization {
  38488. /**
  38489. * Gets a string describing the action executed by the current optimization
  38490. * @return description string
  38491. */
  38492. getDescription(): string;
  38493. /**
  38494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38495. * @param scene defines the current scene where to apply this optimization
  38496. * @param optimizer defines the current optimizer
  38497. * @returns true if everything that can be done was applied
  38498. */
  38499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38500. }
  38501. /**
  38502. * Defines an optimization used to turn lens flares off
  38503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38504. */
  38505. class LensFlaresOptimization extends SceneOptimization {
  38506. /**
  38507. * Gets a string describing the action executed by the current optimization
  38508. * @return description string
  38509. */
  38510. getDescription(): string;
  38511. /**
  38512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38513. * @param scene defines the current scene where to apply this optimization
  38514. * @param optimizer defines the current optimizer
  38515. * @returns true if everything that can be done was applied
  38516. */
  38517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38518. }
  38519. /**
  38520. * Defines an optimization based on user defined callback.
  38521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38522. */
  38523. class CustomOptimization extends SceneOptimization {
  38524. /**
  38525. * Callback called to apply the custom optimization.
  38526. */
  38527. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38528. /**
  38529. * Callback called to get custom description
  38530. */
  38531. onGetDescription: () => string;
  38532. /**
  38533. * Gets a string describing the action executed by the current optimization
  38534. * @returns description string
  38535. */
  38536. getDescription(): string;
  38537. /**
  38538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38539. * @param scene defines the current scene where to apply this optimization
  38540. * @param optimizer defines the current optimizer
  38541. * @returns true if everything that can be done was applied
  38542. */
  38543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38544. }
  38545. /**
  38546. * Defines an optimization used to turn particles off
  38547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38548. */
  38549. class ParticlesOptimization extends SceneOptimization {
  38550. /**
  38551. * Gets a string describing the action executed by the current optimization
  38552. * @return description string
  38553. */
  38554. getDescription(): string;
  38555. /**
  38556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38557. * @param scene defines the current scene where to apply this optimization
  38558. * @param optimizer defines the current optimizer
  38559. * @returns true if everything that can be done was applied
  38560. */
  38561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38562. }
  38563. /**
  38564. * Defines an optimization used to turn render targets off
  38565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38566. */
  38567. class RenderTargetsOptimization extends SceneOptimization {
  38568. /**
  38569. * Gets a string describing the action executed by the current optimization
  38570. * @return description string
  38571. */
  38572. getDescription(): string;
  38573. /**
  38574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38575. * @param scene defines the current scene where to apply this optimization
  38576. * @param optimizer defines the current optimizer
  38577. * @returns true if everything that can be done was applied
  38578. */
  38579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38580. }
  38581. /**
  38582. * Defines an optimization used to merge meshes with compatible materials
  38583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38584. */
  38585. class MergeMeshesOptimization extends SceneOptimization {
  38586. private static _UpdateSelectionTree;
  38587. /**
  38588. * Gets or sets a boolean which defines if optimization octree has to be updated
  38589. */
  38590. /**
  38591. * Gets or sets a boolean which defines if optimization octree has to be updated
  38592. */
  38593. static UpdateSelectionTree: boolean;
  38594. /**
  38595. * Gets a string describing the action executed by the current optimization
  38596. * @return description string
  38597. */
  38598. getDescription(): string;
  38599. private _canBeMerged;
  38600. /**
  38601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38602. * @param scene defines the current scene where to apply this optimization
  38603. * @param optimizer defines the current optimizer
  38604. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38605. * @returns true if everything that can be done was applied
  38606. */
  38607. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38608. }
  38609. /**
  38610. * Defines a list of options used by SceneOptimizer
  38611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38612. */
  38613. class SceneOptimizerOptions {
  38614. /**
  38615. * Defines the target frame rate to reach (60 by default)
  38616. */
  38617. targetFrameRate: number;
  38618. /**
  38619. * Defines the interval between two checkes (2000ms by default)
  38620. */
  38621. trackerDuration: number;
  38622. /**
  38623. * Gets the list of optimizations to apply
  38624. */
  38625. optimizations: SceneOptimization[];
  38626. /**
  38627. * Creates a new list of options used by SceneOptimizer
  38628. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38629. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38630. */
  38631. constructor(
  38632. /**
  38633. * Defines the target frame rate to reach (60 by default)
  38634. */
  38635. targetFrameRate?: number,
  38636. /**
  38637. * Defines the interval between two checkes (2000ms by default)
  38638. */
  38639. trackerDuration?: number);
  38640. /**
  38641. * Add a new optimization
  38642. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38643. * @returns the current SceneOptimizerOptions
  38644. */
  38645. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38646. /**
  38647. * Add a new custom optimization
  38648. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38649. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38650. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38651. * @returns the current SceneOptimizerOptions
  38652. */
  38653. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38654. /**
  38655. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38656. * @param targetFrameRate defines the target frame rate (60 by default)
  38657. * @returns a SceneOptimizerOptions object
  38658. */
  38659. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38660. /**
  38661. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38662. * @param targetFrameRate defines the target frame rate (60 by default)
  38663. * @returns a SceneOptimizerOptions object
  38664. */
  38665. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38666. /**
  38667. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38668. * @param targetFrameRate defines the target frame rate (60 by default)
  38669. * @returns a SceneOptimizerOptions object
  38670. */
  38671. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38672. }
  38673. /**
  38674. * Class used to run optimizations in order to reach a target frame rate
  38675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38676. */
  38677. class SceneOptimizer implements IDisposable {
  38678. private _isRunning;
  38679. private _options;
  38680. private _scene;
  38681. private _currentPriorityLevel;
  38682. private _targetFrameRate;
  38683. private _trackerDuration;
  38684. private _currentFrameRate;
  38685. private _sceneDisposeObserver;
  38686. private _improvementMode;
  38687. /**
  38688. * Defines an observable called when the optimizer reaches the target frame rate
  38689. */
  38690. onSuccessObservable: Observable<SceneOptimizer>;
  38691. /**
  38692. * Defines an observable called when the optimizer enables an optimization
  38693. */
  38694. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38695. /**
  38696. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38697. */
  38698. onFailureObservable: Observable<SceneOptimizer>;
  38699. /**
  38700. * Gets a boolean indicating if the optimizer is in improvement mode
  38701. */
  38702. readonly isInImprovementMode: boolean;
  38703. /**
  38704. * Gets the current priority level (0 at start)
  38705. */
  38706. readonly currentPriorityLevel: number;
  38707. /**
  38708. * Gets the current frame rate checked by the SceneOptimizer
  38709. */
  38710. readonly currentFrameRate: number;
  38711. /**
  38712. * Gets or sets the current target frame rate (60 by default)
  38713. */
  38714. /**
  38715. * Gets or sets the current target frame rate (60 by default)
  38716. */
  38717. targetFrameRate: number;
  38718. /**
  38719. * Gets or sets the current interval between two checks (every 2000ms by default)
  38720. */
  38721. /**
  38722. * Gets or sets the current interval between two checks (every 2000ms by default)
  38723. */
  38724. trackerDuration: number;
  38725. /**
  38726. * Gets the list of active optimizations
  38727. */
  38728. readonly optimizations: SceneOptimization[];
  38729. /**
  38730. * Creates a new SceneOptimizer
  38731. * @param scene defines the scene to work on
  38732. * @param options defines the options to use with the SceneOptimizer
  38733. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38734. * @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)
  38735. */
  38736. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38737. /**
  38738. * Stops the current optimizer
  38739. */
  38740. stop(): void;
  38741. /**
  38742. * Reset the optimizer to initial step (current priority level = 0)
  38743. */
  38744. reset(): void;
  38745. /**
  38746. * Start the optimizer. By default it will try to reach a specific framerate
  38747. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38748. */
  38749. start(): void;
  38750. private _checkCurrentState;
  38751. /**
  38752. * Release all resources
  38753. */
  38754. dispose(): void;
  38755. /**
  38756. * Helper function to create a SceneOptimizer with one single line of code
  38757. * @param scene defines the scene to work on
  38758. * @param options defines the options to use with the SceneOptimizer
  38759. * @param onSuccess defines a callback to call on success
  38760. * @param onFailure defines a callback to call on failure
  38761. * @returns the new SceneOptimizer object
  38762. */
  38763. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /**
  38768. * Class used to serialize a scene into a string
  38769. */
  38770. class SceneSerializer {
  38771. /**
  38772. * Clear cache used by a previous serialization
  38773. */
  38774. static ClearCache(): void;
  38775. /**
  38776. * Serialize a scene into a JSON compatible object
  38777. * @param scene defines the scene to serialize
  38778. * @returns a JSON compatible object
  38779. */
  38780. static Serialize(scene: Scene): any;
  38781. /**
  38782. * Serialize a mesh into a JSON compatible object
  38783. * @param toSerialize defines the mesh to serialize
  38784. * @param withParents defines if parents must be serialized as well
  38785. * @param withChildren defines if children must be serialized as well
  38786. * @returns a JSON compatible object
  38787. */
  38788. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * Defines an array and its length.
  38794. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38795. */
  38796. interface ISmartArrayLike<T> {
  38797. /**
  38798. * The data of the array.
  38799. */
  38800. data: Array<T>;
  38801. /**
  38802. * The active length of the array.
  38803. */
  38804. length: number;
  38805. }
  38806. /**
  38807. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38808. */
  38809. class SmartArray<T> implements ISmartArrayLike<T> {
  38810. /**
  38811. * The full set of data from the array.
  38812. */
  38813. data: Array<T>;
  38814. /**
  38815. * The active length of the array.
  38816. */
  38817. length: number;
  38818. protected _id: number;
  38819. /**
  38820. * Instantiates a Smart Array.
  38821. * @param capacity defines the default capacity of the array.
  38822. */
  38823. constructor(capacity: number);
  38824. /**
  38825. * Pushes a value at the end of the active data.
  38826. * @param value defines the object to push in the array.
  38827. */
  38828. push(value: T): void;
  38829. /**
  38830. * Iterates over the active data and apply the lambda to them.
  38831. * @param func defines the action to apply on each value.
  38832. */
  38833. forEach(func: (content: T) => void): void;
  38834. /**
  38835. * Sorts the full sets of data.
  38836. * @param compareFn defines the comparison function to apply.
  38837. */
  38838. sort(compareFn: (a: T, b: T) => number): void;
  38839. /**
  38840. * Resets the active data to an empty array.
  38841. */
  38842. reset(): void;
  38843. /**
  38844. * Releases all the data from the array as well as the array.
  38845. */
  38846. dispose(): void;
  38847. /**
  38848. * Concats the active data with a given array.
  38849. * @param array defines the data to concatenate with.
  38850. */
  38851. concat(array: any): void;
  38852. /**
  38853. * Returns the position of a value in the active data.
  38854. * @param value defines the value to find the index for
  38855. * @returns the index if found in the active data otherwise -1
  38856. */
  38857. indexOf(value: T): number;
  38858. /**
  38859. * Returns whether an element is part of the active data.
  38860. * @param value defines the value to look for
  38861. * @returns true if found in the active data otherwise false
  38862. */
  38863. contains(value: T): boolean;
  38864. private static _GlobalId;
  38865. }
  38866. /**
  38867. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38868. * The data in this array can only be present once
  38869. */
  38870. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38871. private _duplicateId;
  38872. /**
  38873. * Pushes a value at the end of the active data.
  38874. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38875. * @param value defines the object to push in the array.
  38876. */
  38877. push(value: T): void;
  38878. /**
  38879. * Pushes a value at the end of the active data.
  38880. * If the data is already present, it won t be added again
  38881. * @param value defines the object to push in the array.
  38882. * @returns true if added false if it was already present
  38883. */
  38884. pushNoDuplicate(value: T): boolean;
  38885. /**
  38886. * Resets the active data to an empty array.
  38887. */
  38888. reset(): void;
  38889. /**
  38890. * Concats the active data with a given array.
  38891. * This ensures no dupplicate will be present in the result.
  38892. * @param array defines the data to concatenate with.
  38893. */
  38894. concatWithNoDuplicate(array: any): void;
  38895. }
  38896. }
  38897. declare module BABYLON {
  38898. /**
  38899. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38900. * The underlying implementation relies on an associative array to ensure the best performances.
  38901. * The value can be anything including 'null' but except 'undefined'
  38902. */
  38903. class StringDictionary<T> {
  38904. /**
  38905. * This will clear this dictionary and copy the content from the 'source' one.
  38906. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38907. * @param source the dictionary to take the content from and copy to this dictionary
  38908. */
  38909. copyFrom(source: StringDictionary<T>): void;
  38910. /**
  38911. * Get a value based from its key
  38912. * @param key the given key to get the matching value from
  38913. * @return the value if found, otherwise undefined is returned
  38914. */
  38915. get(key: string): T | undefined;
  38916. /**
  38917. * Get a value from its key or add it if it doesn't exist.
  38918. * This method will ensure you that a given key/data will be present in the dictionary.
  38919. * @param key the given key to get the matching value from
  38920. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38921. * The factory will only be invoked if there's no data for the given key.
  38922. * @return the value corresponding to the key.
  38923. */
  38924. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38925. /**
  38926. * Get a value from its key if present in the dictionary otherwise add it
  38927. * @param key the key to get the value from
  38928. * @param val if there's no such key/value pair in the dictionary add it with this value
  38929. * @return the value corresponding to the key
  38930. */
  38931. getOrAdd(key: string, val: T): T;
  38932. /**
  38933. * Check if there's a given key in the dictionary
  38934. * @param key the key to check for
  38935. * @return true if the key is present, false otherwise
  38936. */
  38937. contains(key: string): boolean;
  38938. /**
  38939. * Add a new key and its corresponding value
  38940. * @param key the key to add
  38941. * @param value the value corresponding to the key
  38942. * @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
  38943. */
  38944. add(key: string, value: T): boolean;
  38945. /**
  38946. * Update a specific value associated to a key
  38947. * @param key defines the key to use
  38948. * @param value defines the value to store
  38949. * @returns true if the value was updated (or false if the key was not found)
  38950. */
  38951. set(key: string, value: T): boolean;
  38952. /**
  38953. * Get the element of the given key and remove it from the dictionary
  38954. * @param key defines the key to search
  38955. * @returns the value associated with the key or null if not found
  38956. */
  38957. getAndRemove(key: string): Nullable<T>;
  38958. /**
  38959. * Remove a key/value from the dictionary.
  38960. * @param key the key to remove
  38961. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38962. */
  38963. remove(key: string): boolean;
  38964. /**
  38965. * Clear the whole content of the dictionary
  38966. */
  38967. clear(): void;
  38968. /**
  38969. * Gets the current count
  38970. */
  38971. readonly count: number;
  38972. /**
  38973. * Execute a callback on each key/val of the dictionary.
  38974. * Note that you can remove any element in this dictionary in the callback implementation
  38975. * @param callback the callback to execute on a given key/value pair
  38976. */
  38977. forEach(callback: (key: string, val: T) => void): void;
  38978. /**
  38979. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38980. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38981. * Note that you can remove any element in this dictionary in the callback implementation
  38982. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38983. * @returns the first item
  38984. */
  38985. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38986. private _count;
  38987. private _data;
  38988. }
  38989. }
  38990. declare module BABYLON {
  38991. /**
  38992. * Class used to store custom tags
  38993. */
  38994. class Tags {
  38995. /**
  38996. * Adds support for tags on the given object
  38997. * @param obj defines the object to use
  38998. */
  38999. static EnableFor(obj: any): void;
  39000. /**
  39001. * Removes tags support
  39002. * @param obj defines the object to use
  39003. */
  39004. static DisableFor(obj: any): void;
  39005. /**
  39006. * Gets a boolean indicating if the given object has tags
  39007. * @param obj defines the object to use
  39008. * @returns a boolean
  39009. */
  39010. static HasTags(obj: any): boolean;
  39011. /**
  39012. * Gets the tags available on a given object
  39013. * @param obj defines the object to use
  39014. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39015. * @returns the tags
  39016. */
  39017. static GetTags(obj: any, asString?: boolean): any;
  39018. /**
  39019. * Adds tags to an object
  39020. * @param obj defines the object to use
  39021. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39022. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39023. */
  39024. static AddTagsTo(obj: any, tagsString: string): void;
  39025. /**
  39026. * @hidden
  39027. */
  39028. static _AddTagTo(obj: any, tag: string): void;
  39029. /**
  39030. * Removes specific tags from a specific object
  39031. * @param obj defines the object to use
  39032. * @param tagsString defines the tags to remove
  39033. */
  39034. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39035. /**
  39036. * @hidden
  39037. */
  39038. static _RemoveTagFrom(obj: any, tag: string): void;
  39039. /**
  39040. * Defines if tags hosted on an object match a given query
  39041. * @param obj defines the object to use
  39042. * @param tagsQuery defines the tag query
  39043. * @returns a boolean
  39044. */
  39045. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39046. }
  39047. }
  39048. declare module BABYLON {
  39049. /**
  39050. * Class used to host texture specific utilities
  39051. */
  39052. class TextureTools {
  39053. /**
  39054. * Uses the GPU to create a copy texture rescaled at a given size
  39055. * @param texture Texture to copy from
  39056. * @param width defines the desired width
  39057. * @param height defines the desired height
  39058. * @param useBilinearMode defines if bilinear mode has to be used
  39059. * @return the generated texture
  39060. */
  39061. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39062. /**
  39063. * Gets an environment BRDF texture for a given scene
  39064. * @param scene defines the hosting scene
  39065. * @returns the environment BRDF texture
  39066. */
  39067. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39068. private static _environmentBRDFBase64Texture;
  39069. }
  39070. }
  39071. declare module BABYLON {
  39072. /**
  39073. * Based on jsTGALoader - Javascript loader for TGA file
  39074. * By Vincent Thibault
  39075. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39076. */
  39077. class TGATools {
  39078. private static _TYPE_INDEXED;
  39079. private static _TYPE_RGB;
  39080. private static _TYPE_GREY;
  39081. private static _TYPE_RLE_INDEXED;
  39082. private static _TYPE_RLE_RGB;
  39083. private static _TYPE_RLE_GREY;
  39084. private static _ORIGIN_MASK;
  39085. private static _ORIGIN_SHIFT;
  39086. private static _ORIGIN_BL;
  39087. private static _ORIGIN_BR;
  39088. private static _ORIGIN_UL;
  39089. private static _ORIGIN_UR;
  39090. /**
  39091. * Gets the header of a TGA file
  39092. * @param data defines the TGA data
  39093. * @returns the header
  39094. */
  39095. static GetTGAHeader(data: Uint8Array): any;
  39096. /**
  39097. * Uploads TGA content to a Babylon Texture
  39098. * @hidden
  39099. */
  39100. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39101. /** @hidden */
  39102. 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;
  39103. /** @hidden */
  39104. 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;
  39105. /** @hidden */
  39106. 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;
  39107. /** @hidden */
  39108. 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;
  39109. /** @hidden */
  39110. 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;
  39111. /** @hidden */
  39112. 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;
  39113. }
  39114. }
  39115. declare module BABYLON {
  39116. /**
  39117. * Interface for any object that can request an animation frame
  39118. */
  39119. interface ICustomAnimationFrameRequester {
  39120. /**
  39121. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39122. */
  39123. renderFunction?: Function;
  39124. /**
  39125. * Called to request the next frame to render to
  39126. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39127. */
  39128. requestAnimationFrame: Function;
  39129. /**
  39130. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39131. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39132. */
  39133. requestID?: number;
  39134. }
  39135. /**
  39136. * Interface containing an array of animations
  39137. */
  39138. interface IAnimatable {
  39139. /**
  39140. * Array of animations
  39141. */
  39142. animations: Array<Animation>;
  39143. }
  39144. /** Interface used by value gradients (color, factor, ...) */
  39145. interface IValueGradient {
  39146. /**
  39147. * Gets or sets the gradient value (between 0 and 1)
  39148. */
  39149. gradient: number;
  39150. }
  39151. /** Class used to store color4 gradient */
  39152. class ColorGradient implements IValueGradient {
  39153. /**
  39154. * Gets or sets the gradient value (between 0 and 1)
  39155. */
  39156. gradient: number;
  39157. /**
  39158. * Gets or sets first associated color
  39159. */
  39160. color1: Color4;
  39161. /**
  39162. * Gets or sets second associated color
  39163. */
  39164. color2?: Color4;
  39165. /**
  39166. * Will get a color picked randomly between color1 and color2.
  39167. * If color2 is undefined then color1 will be used
  39168. * @param result defines the target Color4 to store the result in
  39169. */
  39170. getColorToRef(result: Color4): void;
  39171. }
  39172. /** Class used to store color 3 gradient */
  39173. class Color3Gradient implements IValueGradient {
  39174. /**
  39175. * Gets or sets the gradient value (between 0 and 1)
  39176. */
  39177. gradient: number;
  39178. /**
  39179. * Gets or sets the associated color
  39180. */
  39181. color: Color3;
  39182. }
  39183. /** Class used to store factor gradient */
  39184. class FactorGradient implements IValueGradient {
  39185. /**
  39186. * Gets or sets the gradient value (between 0 and 1)
  39187. */
  39188. gradient: number;
  39189. /**
  39190. * Gets or sets first associated factor
  39191. */
  39192. factor1: number;
  39193. /**
  39194. * Gets or sets second associated factor
  39195. */
  39196. factor2?: number;
  39197. /**
  39198. * Will get a number picked randomly between factor1 and factor2.
  39199. * If factor2 is undefined then factor1 will be used
  39200. * @returns the picked number
  39201. */
  39202. getFactor(): number;
  39203. }
  39204. /**
  39205. * @ignore
  39206. * Application error to support additional information when loading a file
  39207. */
  39208. class LoadFileError extends Error {
  39209. /** defines the optional XHR request */
  39210. request?: XMLHttpRequest | undefined;
  39211. private static _setPrototypeOf;
  39212. /**
  39213. * Creates a new LoadFileError
  39214. * @param message defines the message of the error
  39215. * @param request defines the optional XHR request
  39216. */
  39217. constructor(message: string,
  39218. /** defines the optional XHR request */
  39219. request?: XMLHttpRequest | undefined);
  39220. }
  39221. /**
  39222. * Class used to define a retry strategy when error happens while loading assets
  39223. */
  39224. class RetryStrategy {
  39225. /**
  39226. * Function used to defines an exponential back off strategy
  39227. * @param maxRetries defines the maximum number of retries (3 by default)
  39228. * @param baseInterval defines the interval between retries
  39229. * @returns the strategy function to use
  39230. */
  39231. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39232. }
  39233. /**
  39234. * File request interface
  39235. */
  39236. interface IFileRequest {
  39237. /**
  39238. * Raised when the request is complete (success or error).
  39239. */
  39240. onCompleteObservable: Observable<IFileRequest>;
  39241. /**
  39242. * Aborts the request for a file.
  39243. */
  39244. abort: () => void;
  39245. }
  39246. /**
  39247. * Class containing a set of static utilities functions
  39248. */
  39249. class Tools {
  39250. /**
  39251. * Gets or sets the base URL to use to load assets
  39252. */
  39253. static BaseUrl: string;
  39254. /**
  39255. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39256. */
  39257. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39258. /**
  39259. * Default behaviour for cors in the application.
  39260. * It can be a string if the expected behavior is identical in the entire app.
  39261. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39262. */
  39263. static CorsBehavior: string | ((url: string | string[]) => string);
  39264. /**
  39265. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39266. * @ignorenaming
  39267. */
  39268. static UseFallbackTexture: boolean;
  39269. /**
  39270. * Use this object to register external classes like custom textures or material
  39271. * to allow the laoders to instantiate them
  39272. */
  39273. static RegisteredExternalClasses: {
  39274. [key: string]: Object;
  39275. };
  39276. /**
  39277. * Texture content used if a texture cannot loaded
  39278. * @ignorenaming
  39279. */
  39280. static fallbackTexture: string;
  39281. /**
  39282. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39283. * @param u defines the coordinate on X axis
  39284. * @param v defines the coordinate on Y axis
  39285. * @param width defines the width of the source data
  39286. * @param height defines the height of the source data
  39287. * @param pixels defines the source byte array
  39288. * @param color defines the output color
  39289. */
  39290. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39291. /**
  39292. * Interpolates between a and b via alpha
  39293. * @param a The lower value (returned when alpha = 0)
  39294. * @param b The upper value (returned when alpha = 1)
  39295. * @param alpha The interpolation-factor
  39296. * @return The mixed value
  39297. */
  39298. static Mix(a: number, b: number, alpha: number): number;
  39299. /**
  39300. * Tries to instantiate a new object from a given class name
  39301. * @param className defines the class name to instantiate
  39302. * @returns the new object or null if the system was not able to do the instantiation
  39303. */
  39304. static Instantiate(className: string): any;
  39305. /**
  39306. * Provides a slice function that will work even on IE
  39307. * @param data defines the array to slice
  39308. * @param start defines the start of the data (optional)
  39309. * @param end defines the end of the data (optional)
  39310. * @returns the new sliced array
  39311. */
  39312. static Slice<T>(data: T, start?: number, end?: number): T;
  39313. /**
  39314. * Polyfill for setImmediate
  39315. * @param action defines the action to execute after the current execution block
  39316. */
  39317. static SetImmediate(action: () => void): void;
  39318. /**
  39319. * Function indicating if a number is an exponent of 2
  39320. * @param value defines the value to test
  39321. * @returns true if the value is an exponent of 2
  39322. */
  39323. static IsExponentOfTwo(value: number): boolean;
  39324. private static _tmpFloatArray;
  39325. /**
  39326. * Returns the nearest 32-bit single precision float representation of a Number
  39327. * @param value A Number. If the parameter is of a different type, it will get converted
  39328. * to a number or to NaN if it cannot be converted
  39329. * @returns number
  39330. */
  39331. static FloatRound(value: number): number;
  39332. /**
  39333. * Find the next highest power of two.
  39334. * @param x Number to start search from.
  39335. * @return Next highest power of two.
  39336. */
  39337. static CeilingPOT(x: number): number;
  39338. /**
  39339. * Find the next lowest power of two.
  39340. * @param x Number to start search from.
  39341. * @return Next lowest power of two.
  39342. */
  39343. static FloorPOT(x: number): number;
  39344. /**
  39345. * Find the nearest power of two.
  39346. * @param x Number to start search from.
  39347. * @return Next nearest power of two.
  39348. */
  39349. static NearestPOT(x: number): number;
  39350. /**
  39351. * Get the closest exponent of two
  39352. * @param value defines the value to approximate
  39353. * @param max defines the maximum value to return
  39354. * @param mode defines how to define the closest value
  39355. * @returns closest exponent of two of the given value
  39356. */
  39357. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39358. /**
  39359. * Extracts the filename from a path
  39360. * @param path defines the path to use
  39361. * @returns the filename
  39362. */
  39363. static GetFilename(path: string): string;
  39364. /**
  39365. * Extracts the "folder" part of a path (everything before the filename).
  39366. * @param uri The URI to extract the info from
  39367. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39368. * @returns The "folder" part of the path
  39369. */
  39370. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39371. /**
  39372. * Extracts text content from a DOM element hierarchy
  39373. * @param element defines the root element
  39374. * @returns a string
  39375. */
  39376. static GetDOMTextContent(element: HTMLElement): string;
  39377. /**
  39378. * Convert an angle in radians to degrees
  39379. * @param angle defines the angle to convert
  39380. * @returns the angle in degrees
  39381. */
  39382. static ToDegrees(angle: number): number;
  39383. /**
  39384. * Convert an angle in degrees to radians
  39385. * @param angle defines the angle to convert
  39386. * @returns the angle in radians
  39387. */
  39388. static ToRadians(angle: number): number;
  39389. /**
  39390. * Encode a buffer to a base64 string
  39391. * @param buffer defines the buffer to encode
  39392. * @returns the encoded string
  39393. */
  39394. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39395. /**
  39396. * Extracts minimum and maximum values from a list of indexed positions
  39397. * @param positions defines the positions to use
  39398. * @param indices defines the indices to the positions
  39399. * @param indexStart defines the start index
  39400. * @param indexCount defines the end index
  39401. * @param bias defines bias value to add to the result
  39402. * @return minimum and maximum values
  39403. */
  39404. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39405. minimum: Vector3;
  39406. maximum: Vector3;
  39407. };
  39408. /**
  39409. * Extracts minimum and maximum values from a list of positions
  39410. * @param positions defines the positions to use
  39411. * @param start defines the start index in the positions array
  39412. * @param count defines the number of positions to handle
  39413. * @param bias defines bias value to add to the result
  39414. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39415. * @return minimum and maximum values
  39416. */
  39417. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39418. minimum: Vector3;
  39419. maximum: Vector3;
  39420. };
  39421. /**
  39422. * Returns an array if obj is not an array
  39423. * @param obj defines the object to evaluate as an array
  39424. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39425. * @returns either obj directly if obj is an array or a new array containing obj
  39426. */
  39427. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39428. /**
  39429. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39430. * @param size the number of element to construct and put in the array
  39431. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39432. * @returns a new array filled with new objects
  39433. */
  39434. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39435. /**
  39436. * Gets the pointer prefix to use
  39437. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39438. */
  39439. static GetPointerPrefix(): string;
  39440. /**
  39441. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39442. * @param func - the function to be called
  39443. * @param requester - the object that will request the next frame. Falls back to window.
  39444. * @returns frame number
  39445. */
  39446. static QueueNewFrame(func: () => void, requester?: any): number;
  39447. /**
  39448. * Ask the browser to promote the current element to fullscreen rendering mode
  39449. * @param element defines the DOM element to promote
  39450. */
  39451. static RequestFullscreen(element: HTMLElement): void;
  39452. /**
  39453. * Asks the browser to exit fullscreen mode
  39454. */
  39455. static ExitFullscreen(): void;
  39456. /**
  39457. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39458. * @param url define the url we are trying
  39459. * @param element define the dom element where to configure the cors policy
  39460. */
  39461. static SetCorsBehavior(url: string | string[], element: {
  39462. crossOrigin: string | null;
  39463. }): void;
  39464. /**
  39465. * Removes unwanted characters from an url
  39466. * @param url defines the url to clean
  39467. * @returns the cleaned url
  39468. */
  39469. static CleanUrl(url: string): string;
  39470. /**
  39471. * Gets or sets a function used to pre-process url before using them to load assets
  39472. */
  39473. static PreprocessUrl: (url: string) => string;
  39474. /**
  39475. * Loads an image as an HTMLImageElement.
  39476. * @param input url string, ArrayBuffer, or Blob to load
  39477. * @param onLoad callback called when the image successfully loads
  39478. * @param onError callback called when the image fails to load
  39479. * @param offlineProvider offline provider for caching
  39480. * @returns the HTMLImageElement of the loaded image
  39481. */
  39482. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39483. /**
  39484. * Loads a file
  39485. * @param url url string, ArrayBuffer, or Blob to load
  39486. * @param onSuccess callback called when the file successfully loads
  39487. * @param onProgress callback called while file is loading (if the server supports this mode)
  39488. * @param offlineProvider defines the offline provider for caching
  39489. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39490. * @param onError callback called when the file fails to load
  39491. * @returns a file request object
  39492. */
  39493. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  39494. /**
  39495. * Load a script (identified by an url). When the url returns, the
  39496. * content of this file is added into a new script element, attached to the DOM (body element)
  39497. * @param scriptUrl defines the url of the script to laod
  39498. * @param onSuccess defines the callback called when the script is loaded
  39499. * @param onError defines the callback to call if an error occurs
  39500. */
  39501. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39502. /**
  39503. * Loads a file from a blob
  39504. * @param fileToLoad defines the blob to use
  39505. * @param callback defines the callback to call when data is loaded
  39506. * @param progressCallback defines the callback to call during loading process
  39507. * @returns a file request object
  39508. */
  39509. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39510. /**
  39511. * Loads a file
  39512. * @param fileToLoad defines the file to load
  39513. * @param callback defines the callback to call when data is loaded
  39514. * @param progressCallBack defines the callback to call during loading process
  39515. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39516. * @returns a file request object
  39517. */
  39518. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39519. /**
  39520. * Creates a data url from a given string content
  39521. * @param content defines the content to convert
  39522. * @returns the new data url link
  39523. */
  39524. static FileAsURL(content: string): string;
  39525. /**
  39526. * Format the given number to a specific decimal format
  39527. * @param value defines the number to format
  39528. * @param decimals defines the number of decimals to use
  39529. * @returns the formatted string
  39530. */
  39531. static Format(value: number, decimals?: number): string;
  39532. /**
  39533. * Checks if a given vector is inside a specific range
  39534. * @param v defines the vector to test
  39535. * @param min defines the minimum range
  39536. * @param max defines the maximum range
  39537. */
  39538. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39539. /**
  39540. * Tries to copy an object by duplicating every property
  39541. * @param source defines the source object
  39542. * @param destination defines the target object
  39543. * @param doNotCopyList defines a list of properties to avoid
  39544. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39545. */
  39546. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39547. /**
  39548. * Gets a boolean indicating if the given object has no own property
  39549. * @param obj defines the object to test
  39550. * @returns true if object has no own property
  39551. */
  39552. static IsEmpty(obj: any): boolean;
  39553. /**
  39554. * Function used to register events at window level
  39555. * @param events defines the events to register
  39556. */
  39557. static RegisterTopRootEvents(events: {
  39558. name: string;
  39559. handler: Nullable<(e: FocusEvent) => any>;
  39560. }[]): void;
  39561. /**
  39562. * Function used to unregister events from window level
  39563. * @param events defines the events to unregister
  39564. */
  39565. static UnregisterTopRootEvents(events: {
  39566. name: string;
  39567. handler: Nullable<(e: FocusEvent) => any>;
  39568. }[]): void;
  39569. /**
  39570. * Dumps the current bound framebuffer
  39571. * @param width defines the rendering width
  39572. * @param height defines the rendering height
  39573. * @param engine defines the hosting engine
  39574. * @param successCallback defines the callback triggered once the data are available
  39575. * @param mimeType defines the mime type of the result
  39576. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39577. */
  39578. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39579. /**
  39580. * Converts the canvas data to blob.
  39581. * This acts as a polyfill for browsers not supporting the to blob function.
  39582. * @param canvas Defines the canvas to extract the data from
  39583. * @param successCallback Defines the callback triggered once the data are available
  39584. * @param mimeType Defines the mime type of the result
  39585. */
  39586. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39587. /**
  39588. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39589. * @param successCallback defines the callback triggered once the data are available
  39590. * @param mimeType defines the mime type of the result
  39591. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39592. */
  39593. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39594. /**
  39595. * Downloads a blob in the browser
  39596. * @param blob defines the blob to download
  39597. * @param fileName defines the name of the downloaded file
  39598. */
  39599. static Download(blob: Blob, fileName: string): void;
  39600. /**
  39601. * Captures a screenshot of the current rendering
  39602. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39603. * @param engine defines the rendering engine
  39604. * @param camera defines the source camera
  39605. * @param size This parameter can be set to a single number or to an object with the
  39606. * following (optional) properties: precision, width, height. If a single number is passed,
  39607. * it will be used for both width and height. If an object is passed, the screenshot size
  39608. * will be derived from the parameters. The precision property is a multiplier allowing
  39609. * rendering at a higher or lower resolution
  39610. * @param successCallback defines the callback receives a single parameter which contains the
  39611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39612. * src parameter of an <img> to display it
  39613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39614. * Check your browser for supported MIME types
  39615. */
  39616. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39617. /**
  39618. * Generates an image screenshot from the specified camera.
  39619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39620. * @param engine The engine to use for rendering
  39621. * @param camera The camera to use for rendering
  39622. * @param size This parameter can be set to a single number or to an object with the
  39623. * following (optional) properties: precision, width, height. If a single number is passed,
  39624. * it will be used for both width and height. If an object is passed, the screenshot size
  39625. * will be derived from the parameters. The precision property is a multiplier allowing
  39626. * rendering at a higher or lower resolution
  39627. * @param successCallback The callback receives a single parameter which contains the
  39628. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39629. * src parameter of an <img> to display it
  39630. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39631. * Check your browser for supported MIME types
  39632. * @param samples Texture samples (default: 1)
  39633. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39634. * @param fileName A name for for the downloaded file.
  39635. */
  39636. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39637. /**
  39638. * Validates if xhr data is correct
  39639. * @param xhr defines the request to validate
  39640. * @param dataType defines the expected data type
  39641. * @returns true if data is correct
  39642. */
  39643. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39644. /**
  39645. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39646. * Be aware Math.random() could cause collisions, but:
  39647. * "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"
  39648. * @returns a pseudo random id
  39649. */
  39650. static RandomId(): string;
  39651. /**
  39652. * Test if the given uri is a base64 string
  39653. * @param uri The uri to test
  39654. * @return True if the uri is a base64 string or false otherwise
  39655. */
  39656. static IsBase64(uri: string): boolean;
  39657. /**
  39658. * Decode the given base64 uri.
  39659. * @param uri The uri to decode
  39660. * @return The decoded base64 data.
  39661. */
  39662. static DecodeBase64(uri: string): ArrayBuffer;
  39663. /**
  39664. * No log
  39665. */
  39666. static readonly NoneLogLevel: number;
  39667. /**
  39668. * Only message logs
  39669. */
  39670. static readonly MessageLogLevel: number;
  39671. /**
  39672. * Only warning logs
  39673. */
  39674. static readonly WarningLogLevel: number;
  39675. /**
  39676. * Only error logs
  39677. */
  39678. static readonly ErrorLogLevel: number;
  39679. /**
  39680. * All logs
  39681. */
  39682. static readonly AllLogLevel: number;
  39683. private static _LogCache;
  39684. /**
  39685. * Gets a value indicating the number of loading errors
  39686. * @ignorenaming
  39687. */
  39688. static errorsCount: number;
  39689. /**
  39690. * Callback called when a new log is added
  39691. */
  39692. static OnNewCacheEntry: (entry: string) => void;
  39693. private static _AddLogEntry;
  39694. private static _FormatMessage;
  39695. private static _LogDisabled;
  39696. private static _LogEnabled;
  39697. private static _WarnDisabled;
  39698. private static _WarnEnabled;
  39699. private static _ErrorDisabled;
  39700. private static _ErrorEnabled;
  39701. /**
  39702. * Log a message to the console
  39703. */
  39704. static Log: (message: string) => void;
  39705. /**
  39706. * Write a warning message to the console
  39707. */
  39708. static Warn: (message: string) => void;
  39709. /**
  39710. * Write an error message to the console
  39711. */
  39712. static Error: (message: string) => void;
  39713. /**
  39714. * Gets current log cache (list of logs)
  39715. */
  39716. static readonly LogCache: string;
  39717. /**
  39718. * Clears the log cache
  39719. */
  39720. static ClearLogCache(): void;
  39721. /**
  39722. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39723. */
  39724. static LogLevels: number;
  39725. /**
  39726. * Checks if the loaded document was accessed via `file:`-Protocol.
  39727. * @returns boolean
  39728. */
  39729. static IsFileURL(): boolean;
  39730. /**
  39731. * Checks if the window object exists
  39732. * @returns true if the window object exists
  39733. */
  39734. static IsWindowObjectExist(): boolean;
  39735. /**
  39736. * No performance log
  39737. */
  39738. static readonly PerformanceNoneLogLevel: number;
  39739. /**
  39740. * Use user marks to log performance
  39741. */
  39742. static readonly PerformanceUserMarkLogLevel: number;
  39743. /**
  39744. * Log performance to the console
  39745. */
  39746. static readonly PerformanceConsoleLogLevel: number;
  39747. private static _performance;
  39748. /**
  39749. * Sets the current performance log level
  39750. */
  39751. static PerformanceLogLevel: number;
  39752. private static _StartPerformanceCounterDisabled;
  39753. private static _EndPerformanceCounterDisabled;
  39754. private static _StartUserMark;
  39755. private static _EndUserMark;
  39756. private static _StartPerformanceConsole;
  39757. private static _EndPerformanceConsole;
  39758. /**
  39759. * Starts a performance counter
  39760. */
  39761. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39762. /**
  39763. * Ends a specific performance coutner
  39764. */
  39765. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39766. /**
  39767. * Gets either window.performance.now() if supported or Date.now() else
  39768. */
  39769. static readonly Now: number;
  39770. /**
  39771. * This method will return the name of the class used to create the instance of the given object.
  39772. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39773. * @param object the object to get the class name from
  39774. * @param isType defines if the object is actually a type
  39775. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39776. */
  39777. static GetClassName(object: any, isType?: boolean): string;
  39778. /**
  39779. * Gets the first element of an array satisfying a given predicate
  39780. * @param array defines the array to browse
  39781. * @param predicate defines the predicate to use
  39782. * @returns null if not found or the element
  39783. */
  39784. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39785. /**
  39786. * This method will return the name of the full name of the class, including its owning module (if any).
  39787. * 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).
  39788. * @param object the object to get the class name from
  39789. * @param isType defines if the object is actually a type
  39790. * @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.
  39791. * @ignorenaming
  39792. */
  39793. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39794. /**
  39795. * Returns a promise that resolves after the given amount of time.
  39796. * @param delay Number of milliseconds to delay
  39797. * @returns Promise that resolves after the given amount of time
  39798. */
  39799. static DelayAsync(delay: number): Promise<void>;
  39800. /**
  39801. * Gets the current gradient from an array of IValueGradient
  39802. * @param ratio defines the current ratio to get
  39803. * @param gradients defines the array of IValueGradient
  39804. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39805. */
  39806. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39807. }
  39808. /**
  39809. * This class is used to track a performance counter which is number based.
  39810. * The user has access to many properties which give statistics of different nature.
  39811. *
  39812. * The implementer can track two kinds of Performance Counter: time and count.
  39813. * 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.
  39814. * 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.
  39815. */
  39816. class PerfCounter {
  39817. /**
  39818. * Gets or sets a global boolean to turn on and off all the counters
  39819. */
  39820. static Enabled: boolean;
  39821. /**
  39822. * Returns the smallest value ever
  39823. */
  39824. readonly min: number;
  39825. /**
  39826. * Returns the biggest value ever
  39827. */
  39828. readonly max: number;
  39829. /**
  39830. * Returns the average value since the performance counter is running
  39831. */
  39832. readonly average: number;
  39833. /**
  39834. * Returns the average value of the last second the counter was monitored
  39835. */
  39836. readonly lastSecAverage: number;
  39837. /**
  39838. * Returns the current value
  39839. */
  39840. readonly current: number;
  39841. /**
  39842. * Gets the accumulated total
  39843. */
  39844. readonly total: number;
  39845. /**
  39846. * Gets the total value count
  39847. */
  39848. readonly count: number;
  39849. /**
  39850. * Creates a new counter
  39851. */
  39852. constructor();
  39853. /**
  39854. * Call this method to start monitoring a new frame.
  39855. * 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.
  39856. */
  39857. fetchNewFrame(): void;
  39858. /**
  39859. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39860. * @param newCount the count value to add to the monitored count
  39861. * @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.
  39862. */
  39863. addCount(newCount: number, fetchResult: boolean): void;
  39864. /**
  39865. * Start monitoring this performance counter
  39866. */
  39867. beginMonitoring(): void;
  39868. /**
  39869. * Compute the time lapsed since the previous beginMonitoring() call.
  39870. * @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
  39871. */
  39872. endMonitoring(newFrame?: boolean): void;
  39873. private _fetchResult;
  39874. private _startMonitoringTime;
  39875. private _min;
  39876. private _max;
  39877. private _average;
  39878. private _current;
  39879. private _totalValueCount;
  39880. private _totalAccumulated;
  39881. private _lastSecAverage;
  39882. private _lastSecAccumulated;
  39883. private _lastSecTime;
  39884. private _lastSecValueCount;
  39885. }
  39886. /**
  39887. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39888. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39889. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39890. * @param name The name of the class, case should be preserved
  39891. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39892. */
  39893. function className(name: string, module?: string): (target: Object) => void;
  39894. /**
  39895. * An implementation of a loop for asynchronous functions.
  39896. */
  39897. class AsyncLoop {
  39898. /**
  39899. * Defines the number of iterations for the loop
  39900. */
  39901. iterations: number;
  39902. /**
  39903. * Defines the current index of the loop.
  39904. */
  39905. index: number;
  39906. private _done;
  39907. private _fn;
  39908. private _successCallback;
  39909. /**
  39910. * Constructor.
  39911. * @param iterations the number of iterations.
  39912. * @param func the function to run each iteration
  39913. * @param successCallback the callback that will be called upon succesful execution
  39914. * @param offset starting offset.
  39915. */
  39916. constructor(
  39917. /**
  39918. * Defines the number of iterations for the loop
  39919. */
  39920. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39921. /**
  39922. * Execute the next iteration. Must be called after the last iteration was finished.
  39923. */
  39924. executeNext(): void;
  39925. /**
  39926. * Break the loop and run the success callback.
  39927. */
  39928. breakLoop(): void;
  39929. /**
  39930. * Create and run an async loop.
  39931. * @param iterations the number of iterations.
  39932. * @param fn the function to run each iteration
  39933. * @param successCallback the callback that will be called upon succesful execution
  39934. * @param offset starting offset.
  39935. * @returns the created async loop object
  39936. */
  39937. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39938. /**
  39939. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39940. * @param iterations total number of iterations
  39941. * @param syncedIterations number of synchronous iterations in each async iteration.
  39942. * @param fn the function to call each iteration.
  39943. * @param callback a success call back that will be called when iterating stops.
  39944. * @param breakFunction a break condition (optional)
  39945. * @param timeout timeout settings for the setTimeout function. default - 0.
  39946. * @returns the created async loop object
  39947. */
  39948. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39949. }
  39950. }
  39951. interface HTMLCanvasElement {
  39952. /** Track wether a record is in progress */
  39953. isRecording: boolean;
  39954. /** Capture Stream method defined by some browsers */
  39955. captureStream(fps?: number): MediaStream;
  39956. }
  39957. interface MediaRecorder {
  39958. /** Starts recording */
  39959. start(timeSlice: number): void;
  39960. /** Stops recording */
  39961. stop(): void;
  39962. /** Event raised when an error arised. */
  39963. onerror: (event: ErrorEvent) => void;
  39964. /** Event raised when the recording stops. */
  39965. onstop: (event: Event) => void;
  39966. /** Event raised when a new chunk of data is available and should be tracked. */
  39967. ondataavailable: (event: Event) => void;
  39968. }
  39969. interface MediaRecorderOptions {
  39970. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39971. mimeType?: string;
  39972. /** The chosen bitrate for the audio component of the media. */
  39973. audioBitsPerSecond?: number;
  39974. /** The chosen bitrate for the video component of the media. */
  39975. videoBitsPerSecond?: number;
  39976. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  39977. bitsPerSecond?: number;
  39978. }
  39979. interface MediaRecorderConstructor {
  39980. /**
  39981. * A reference to the prototype.
  39982. */
  39983. readonly prototype: MediaRecorder;
  39984. /**
  39985. * Creates a new MediaRecorder.
  39986. * @param stream Defines the stream to record.
  39987. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39988. */
  39989. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39990. }
  39991. /**
  39992. * MediaRecoreder object available in some browsers.
  39993. */
  39994. declare var MediaRecorder: MediaRecorderConstructor;
  39995. declare module BABYLON {
  39996. /**
  39997. * This represents the different options avilable for the video capture.
  39998. */
  39999. interface VideoRecorderOptions {
  40000. /** Defines the mime type of the video */
  40001. mimeType: string;
  40002. /** Defines the video the video should be recorded at */
  40003. fps: number;
  40004. /** Defines the chunk size for the recording data */
  40005. recordChunckSize: number;
  40006. }
  40007. /**
  40008. * This can helps recording videos from BabylonJS.
  40009. * This is based on the available WebRTC functionalities of the browser.
  40010. *
  40011. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40012. */
  40013. class VideoRecorder {
  40014. private static readonly _defaultOptions;
  40015. /**
  40016. * Returns wehther or not the VideoRecorder is available in your browser.
  40017. * @param engine Defines the Babylon Engine to check the support for
  40018. * @returns true if supported otherwise false
  40019. */
  40020. static IsSupported(engine: Engine): boolean;
  40021. private readonly _options;
  40022. private _canvas;
  40023. private _mediaRecorder;
  40024. private _recordedChunks;
  40025. private _fileName;
  40026. private _resolve;
  40027. private _reject;
  40028. /**
  40029. * True wether a recording is already in progress.
  40030. */
  40031. readonly isRecording: boolean;
  40032. /**
  40033. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40034. * a video file.
  40035. * @param engine Defines the BabylonJS Engine you wish to record
  40036. * @param options Defines options that can be used to customized the capture
  40037. */
  40038. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40039. /**
  40040. * Stops the current recording before the default capture timeout passed in the startRecording
  40041. * functions.
  40042. */
  40043. stopRecording(): void;
  40044. /**
  40045. * Starts recording the canvas for a max duration specified in parameters.
  40046. * @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.
  40047. * @param maxDuration Defines the maximum recording time in seconds.
  40048. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40049. * @return a promise callback at the end of the recording with the video data in Blob.
  40050. */
  40051. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40052. /**
  40053. * Releases internal resources used during the recording.
  40054. */
  40055. dispose(): void;
  40056. private _handleDataAvailable;
  40057. private _handleError;
  40058. private _handleStop;
  40059. }
  40060. }
  40061. declare module BABYLON {
  40062. /**
  40063. * Defines the potential axis of a Joystick
  40064. */
  40065. enum JoystickAxis {
  40066. /** X axis */
  40067. X = 0,
  40068. /** Y axis */
  40069. Y = 1,
  40070. /** Z axis */
  40071. Z = 2
  40072. }
  40073. /**
  40074. * Class used to define virtual joystick (used in touch mode)
  40075. */
  40076. class VirtualJoystick {
  40077. /**
  40078. * Gets or sets a boolean indicating that left and right values must be inverted
  40079. */
  40080. reverseLeftRight: boolean;
  40081. /**
  40082. * Gets or sets a boolean indicating that up and down values must be inverted
  40083. */
  40084. reverseUpDown: boolean;
  40085. /**
  40086. * Gets the offset value for the position (ie. the change of the position value)
  40087. */
  40088. deltaPosition: Vector3;
  40089. /**
  40090. * Gets a boolean indicating if the virtual joystick was pressed
  40091. */
  40092. pressed: boolean;
  40093. private static _globalJoystickIndex;
  40094. private static vjCanvas;
  40095. private static vjCanvasContext;
  40096. private static vjCanvasWidth;
  40097. private static vjCanvasHeight;
  40098. private static halfWidth;
  40099. private _action;
  40100. private _axisTargetedByLeftAndRight;
  40101. private _axisTargetedByUpAndDown;
  40102. private _joystickSensibility;
  40103. private _inversedSensibility;
  40104. private _joystickPointerID;
  40105. private _joystickColor;
  40106. private _joystickPointerPos;
  40107. private _joystickPreviousPointerPos;
  40108. private _joystickPointerStartPos;
  40109. private _deltaJoystickVector;
  40110. private _leftJoystick;
  40111. private _touches;
  40112. private _onPointerDownHandlerRef;
  40113. private _onPointerMoveHandlerRef;
  40114. private _onPointerUpHandlerRef;
  40115. private _onResize;
  40116. /**
  40117. * Creates a new virtual joystick
  40118. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40119. */
  40120. constructor(leftJoystick?: boolean);
  40121. /**
  40122. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40123. * @param newJoystickSensibility defines the new sensibility
  40124. */
  40125. setJoystickSensibility(newJoystickSensibility: number): void;
  40126. private _onPointerDown;
  40127. private _onPointerMove;
  40128. private _onPointerUp;
  40129. /**
  40130. * Change the color of the virtual joystick
  40131. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40132. */
  40133. setJoystickColor(newColor: string): void;
  40134. /**
  40135. * Defines a callback to call when the joystick is touched
  40136. * @param action defines the callback
  40137. */
  40138. setActionOnTouch(action: () => any): void;
  40139. /**
  40140. * Defines which axis you'd like to control for left & right
  40141. * @param axis defines the axis to use
  40142. */
  40143. setAxisForLeftRight(axis: JoystickAxis): void;
  40144. /**
  40145. * Defines which axis you'd like to control for up & down
  40146. * @param axis defines the axis to use
  40147. */
  40148. setAxisForUpDown(axis: JoystickAxis): void;
  40149. private _drawVirtualJoystick;
  40150. /**
  40151. * Release internal HTML canvas
  40152. */
  40153. releaseCanvas(): void;
  40154. }
  40155. }
  40156. declare module BABYLON {
  40157. /**
  40158. * Helper class to push actions to a pool of workers.
  40159. */
  40160. class WorkerPool implements IDisposable {
  40161. private _workerInfos;
  40162. private _pendingActions;
  40163. /**
  40164. * Constructor
  40165. * @param workers Array of workers to use for actions
  40166. */
  40167. constructor(workers: Array<Worker>);
  40168. /**
  40169. * Terminates all workers and clears any pending actions.
  40170. */
  40171. dispose(): void;
  40172. /**
  40173. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40174. * pended until a worker has completed its action.
  40175. * @param action The action to perform. Call onComplete when the action is complete.
  40176. */
  40177. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40178. private _execute;
  40179. }
  40180. }
  40181. declare module BABYLON {
  40182. /**
  40183. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40185. */
  40186. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40187. /**
  40188. * Gets the name of the behavior.
  40189. */
  40190. readonly name: string;
  40191. private _zoomStopsAnimation;
  40192. private _idleRotationSpeed;
  40193. private _idleRotationWaitTime;
  40194. private _idleRotationSpinupTime;
  40195. /**
  40196. * Sets the flag that indicates if user zooming should stop animation.
  40197. */
  40198. /**
  40199. * Gets the flag that indicates if user zooming should stop animation.
  40200. */
  40201. zoomStopsAnimation: boolean;
  40202. /**
  40203. * Sets the default speed at which the camera rotates around the model.
  40204. */
  40205. /**
  40206. * Gets the default speed at which the camera rotates around the model.
  40207. */
  40208. idleRotationSpeed: number;
  40209. /**
  40210. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40211. */
  40212. /**
  40213. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40214. */
  40215. idleRotationWaitTime: number;
  40216. /**
  40217. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40218. */
  40219. /**
  40220. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40221. */
  40222. idleRotationSpinupTime: number;
  40223. /**
  40224. * Gets a value indicating if the camera is currently rotating because of this behavior
  40225. */
  40226. readonly rotationInProgress: boolean;
  40227. private _onPrePointerObservableObserver;
  40228. private _onAfterCheckInputsObserver;
  40229. private _attachedCamera;
  40230. private _isPointerDown;
  40231. private _lastFrameTime;
  40232. private _lastInteractionTime;
  40233. private _cameraRotationSpeed;
  40234. /**
  40235. * Initializes the behavior.
  40236. */
  40237. init(): void;
  40238. /**
  40239. * Attaches the behavior to its arc rotate camera.
  40240. * @param camera Defines the camera to attach the behavior to
  40241. */
  40242. attach(camera: ArcRotateCamera): void;
  40243. /**
  40244. * Detaches the behavior from its current arc rotate camera.
  40245. */
  40246. detach(): void;
  40247. /**
  40248. * Returns true if user is scrolling.
  40249. * @return true if user is scrolling.
  40250. */
  40251. private _userIsZooming;
  40252. private _lastFrameRadius;
  40253. private _shouldAnimationStopForInteraction;
  40254. /**
  40255. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40256. */
  40257. private _applyUserInteraction;
  40258. private _userIsMoving;
  40259. }
  40260. }
  40261. declare module BABYLON {
  40262. /**
  40263. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40264. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40265. */
  40266. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40267. /**
  40268. * Gets the name of the behavior.
  40269. */
  40270. readonly name: string;
  40271. /**
  40272. * The easing function used by animations
  40273. */
  40274. static EasingFunction: BackEase;
  40275. /**
  40276. * The easing mode used by animations
  40277. */
  40278. static EasingMode: number;
  40279. /**
  40280. * The duration of the animation, in milliseconds
  40281. */
  40282. transitionDuration: number;
  40283. /**
  40284. * Length of the distance animated by the transition when lower radius is reached
  40285. */
  40286. lowerRadiusTransitionRange: number;
  40287. /**
  40288. * Length of the distance animated by the transition when upper radius is reached
  40289. */
  40290. upperRadiusTransitionRange: number;
  40291. private _autoTransitionRange;
  40292. /**
  40293. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40294. */
  40295. /**
  40296. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40297. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40298. */
  40299. autoTransitionRange: boolean;
  40300. private _attachedCamera;
  40301. private _onAfterCheckInputsObserver;
  40302. private _onMeshTargetChangedObserver;
  40303. /**
  40304. * Initializes the behavior.
  40305. */
  40306. init(): void;
  40307. /**
  40308. * Attaches the behavior to its arc rotate camera.
  40309. * @param camera Defines the camera to attach the behavior to
  40310. */
  40311. attach(camera: ArcRotateCamera): void;
  40312. /**
  40313. * Detaches the behavior from its current arc rotate camera.
  40314. */
  40315. detach(): void;
  40316. private _radiusIsAnimating;
  40317. private _radiusBounceTransition;
  40318. private _animatables;
  40319. private _cachedWheelPrecision;
  40320. /**
  40321. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40322. * @param radiusLimit The limit to check against.
  40323. * @return Bool to indicate if at limit.
  40324. */
  40325. private _isRadiusAtLimit;
  40326. /**
  40327. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40328. * @param radiusDelta The delta by which to animate to. Can be negative.
  40329. */
  40330. private _applyBoundRadiusAnimation;
  40331. /**
  40332. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40333. */
  40334. protected _clearAnimationLocks(): void;
  40335. /**
  40336. * Stops and removes all animations that have been applied to the camera
  40337. */
  40338. stopAllAnimations(): void;
  40339. }
  40340. }
  40341. declare module BABYLON {
  40342. /**
  40343. * The framing behavior (BABYLON.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.
  40344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40345. */
  40346. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40347. /**
  40348. * Gets the name of the behavior.
  40349. */
  40350. readonly name: string;
  40351. private _mode;
  40352. private _radiusScale;
  40353. private _positionScale;
  40354. private _defaultElevation;
  40355. private _elevationReturnTime;
  40356. private _elevationReturnWaitTime;
  40357. private _zoomStopsAnimation;
  40358. private _framingTime;
  40359. /**
  40360. * The easing function used by animations
  40361. */
  40362. static EasingFunction: ExponentialEase;
  40363. /**
  40364. * The easing mode used by animations
  40365. */
  40366. static EasingMode: number;
  40367. /**
  40368. * Sets the current mode used by the behavior
  40369. */
  40370. /**
  40371. * Gets current mode used by the behavior.
  40372. */
  40373. mode: number;
  40374. /**
  40375. * Sets the scale applied to the radius (1 by default)
  40376. */
  40377. /**
  40378. * Gets the scale applied to the radius
  40379. */
  40380. radiusScale: number;
  40381. /**
  40382. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40383. */
  40384. /**
  40385. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40386. */
  40387. positionScale: number;
  40388. /**
  40389. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40390. * behaviour is triggered, in radians.
  40391. */
  40392. /**
  40393. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40394. * behaviour is triggered, in radians.
  40395. */
  40396. defaultElevation: number;
  40397. /**
  40398. * Sets the time (in milliseconds) taken to return to the default beta position.
  40399. * Negative value indicates camera should not return to default.
  40400. */
  40401. /**
  40402. * Gets the time (in milliseconds) taken to return to the default beta position.
  40403. * Negative value indicates camera should not return to default.
  40404. */
  40405. elevationReturnTime: number;
  40406. /**
  40407. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40408. */
  40409. /**
  40410. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40411. */
  40412. elevationReturnWaitTime: number;
  40413. /**
  40414. * Sets the flag that indicates if user zooming should stop animation.
  40415. */
  40416. /**
  40417. * Gets the flag that indicates if user zooming should stop animation.
  40418. */
  40419. zoomStopsAnimation: boolean;
  40420. /**
  40421. * Sets the transition time when framing the mesh, in milliseconds
  40422. */
  40423. /**
  40424. * Gets the transition time when framing the mesh, in milliseconds
  40425. */
  40426. framingTime: number;
  40427. /**
  40428. * Define if the behavior should automatically change the configured
  40429. * camera limits and sensibilities.
  40430. */
  40431. autoCorrectCameraLimitsAndSensibility: boolean;
  40432. private _onPrePointerObservableObserver;
  40433. private _onAfterCheckInputsObserver;
  40434. private _onMeshTargetChangedObserver;
  40435. private _attachedCamera;
  40436. private _isPointerDown;
  40437. private _lastInteractionTime;
  40438. /**
  40439. * Initializes the behavior.
  40440. */
  40441. init(): void;
  40442. /**
  40443. * Attaches the behavior to its arc rotate camera.
  40444. * @param camera Defines the camera to attach the behavior to
  40445. */
  40446. attach(camera: ArcRotateCamera): void;
  40447. /**
  40448. * Detaches the behavior from its current arc rotate camera.
  40449. */
  40450. detach(): void;
  40451. private _animatables;
  40452. private _betaIsAnimating;
  40453. private _betaTransition;
  40454. private _radiusTransition;
  40455. private _vectorTransition;
  40456. /**
  40457. * Targets the given mesh and updates zoom level accordingly.
  40458. * @param mesh The mesh to target.
  40459. * @param radius Optional. If a cached radius position already exists, overrides default.
  40460. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40461. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40462. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40463. */
  40464. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40465. /**
  40466. * Targets the given mesh with its children and updates zoom level accordingly.
  40467. * @param mesh The mesh to target.
  40468. * @param radius Optional. If a cached radius position already exists, overrides default.
  40469. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40472. */
  40473. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40474. /**
  40475. * Targets the given meshes with their children and updates zoom level accordingly.
  40476. * @param meshes The mesh to target.
  40477. * @param radius Optional. If a cached radius position already exists, overrides default.
  40478. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40481. */
  40482. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40483. /**
  40484. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40485. * @param minimumWorld Determines the smaller position of the bounding box extend
  40486. * @param maximumWorld Determines the bigger position of the bounding box extend
  40487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40489. */
  40490. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40491. /**
  40492. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40493. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40494. * frustum width.
  40495. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40496. * to fully enclose the mesh in the viewing frustum.
  40497. */
  40498. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40499. /**
  40500. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40501. * is automatically returned to its default position (expected to be above ground plane).
  40502. */
  40503. private _maintainCameraAboveGround;
  40504. /**
  40505. * Returns the frustum slope based on the canvas ratio and camera FOV
  40506. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40507. */
  40508. private _getFrustumSlope;
  40509. /**
  40510. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40511. */
  40512. private _clearAnimationLocks;
  40513. /**
  40514. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40515. */
  40516. private _applyUserInteraction;
  40517. /**
  40518. * Stops and removes all animations that have been applied to the camera
  40519. */
  40520. stopAllAnimations(): void;
  40521. /**
  40522. * Gets a value indicating if the user is moving the camera
  40523. */
  40524. readonly isUserIsMoving: boolean;
  40525. /**
  40526. * The camera can move all the way towards the mesh.
  40527. */
  40528. static IgnoreBoundsSizeMode: number;
  40529. /**
  40530. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40531. */
  40532. static FitFrustumSidesMode: number;
  40533. }
  40534. }
  40535. declare module BABYLON {
  40536. /**
  40537. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40538. */
  40539. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40540. private ui;
  40541. /**
  40542. * The name of the behavior
  40543. */
  40544. name: string;
  40545. /**
  40546. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40547. */
  40548. distanceAwayFromFace: number;
  40549. /**
  40550. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40551. */
  40552. distanceAwayFromBottomOfFace: number;
  40553. private _faceVectors;
  40554. private _target;
  40555. private _scene;
  40556. private _onRenderObserver;
  40557. private _tmpMatrix;
  40558. private _tmpVector;
  40559. /**
  40560. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40561. * @param ui The transform node that should be attched to the mesh
  40562. */
  40563. constructor(ui: BABYLON.TransformNode);
  40564. /**
  40565. * Initializes the behavior
  40566. */
  40567. init(): void;
  40568. private _closestFace;
  40569. private _zeroVector;
  40570. private _lookAtTmpMatrix;
  40571. private _lookAtToRef;
  40572. /**
  40573. * Attaches the AttachToBoxBehavior to the passed in mesh
  40574. * @param target The mesh that the specified node will be attached to
  40575. */
  40576. attach(target: BABYLON.Mesh): void;
  40577. /**
  40578. * Detaches the behavior from the mesh
  40579. */
  40580. detach(): void;
  40581. }
  40582. }
  40583. declare module BABYLON {
  40584. /**
  40585. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40586. */
  40587. class FadeInOutBehavior implements Behavior<Mesh> {
  40588. /**
  40589. * Time in milliseconds to delay before fading in (Default: 0)
  40590. */
  40591. delay: number;
  40592. /**
  40593. * Time in milliseconds for the mesh to fade in (Default: 300)
  40594. */
  40595. fadeInTime: number;
  40596. private _millisecondsPerFrame;
  40597. private _hovered;
  40598. private _hoverValue;
  40599. private _ownerNode;
  40600. /**
  40601. * Instatiates the FadeInOutBehavior
  40602. */
  40603. constructor();
  40604. /**
  40605. * The name of the behavior
  40606. */
  40607. readonly name: string;
  40608. /**
  40609. * Initializes the behavior
  40610. */
  40611. init(): void;
  40612. /**
  40613. * Attaches the fade behavior on the passed in mesh
  40614. * @param ownerNode The mesh that will be faded in/out once attached
  40615. */
  40616. attach(ownerNode: Mesh): void;
  40617. /**
  40618. * Detaches the behavior from the mesh
  40619. */
  40620. detach(): void;
  40621. /**
  40622. * Triggers the mesh to begin fading in or out
  40623. * @param value if the object should fade in or out (true to fade in)
  40624. */
  40625. fadeIn(value: boolean): void;
  40626. private _update;
  40627. private _setAllVisibility;
  40628. }
  40629. }
  40630. declare module BABYLON {
  40631. /**
  40632. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40633. */
  40634. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40635. private _dragBehaviorA;
  40636. private _dragBehaviorB;
  40637. private _startDistance;
  40638. private _initialScale;
  40639. private _targetScale;
  40640. private _ownerNode;
  40641. private _sceneRenderObserver;
  40642. /**
  40643. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40644. */
  40645. constructor();
  40646. /**
  40647. * The name of the behavior
  40648. */
  40649. readonly name: string;
  40650. /**
  40651. * Initializes the behavior
  40652. */
  40653. init(): void;
  40654. private _getCurrentDistance;
  40655. /**
  40656. * Attaches the scale behavior the passed in mesh
  40657. * @param ownerNode The mesh that will be scaled around once attached
  40658. */
  40659. attach(ownerNode: Mesh): void;
  40660. /**
  40661. * Detaches the behavior from the mesh
  40662. */
  40663. detach(): void;
  40664. }
  40665. }
  40666. declare module BABYLON {
  40667. /**
  40668. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40669. */
  40670. class PointerDragBehavior implements Behavior<Mesh> {
  40671. private static _AnyMouseID;
  40672. private _attachedNode;
  40673. private _dragPlane;
  40674. private _scene;
  40675. private _pointerObserver;
  40676. private _beforeRenderObserver;
  40677. private static _planeScene;
  40678. /**
  40679. * 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)
  40680. */
  40681. maxDragAngle: number;
  40682. /**
  40683. * @hidden
  40684. */
  40685. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40686. /**
  40687. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40688. */
  40689. currentDraggingPointerID: number;
  40690. /**
  40691. * The last position where the pointer hit the drag plane in world space
  40692. */
  40693. lastDragPosition: Vector3;
  40694. /**
  40695. * If the behavior is currently in a dragging state
  40696. */
  40697. dragging: boolean;
  40698. /**
  40699. * 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)
  40700. */
  40701. dragDeltaRatio: number;
  40702. /**
  40703. * If the drag plane orientation should be updated during the dragging (Default: true)
  40704. */
  40705. updateDragPlane: boolean;
  40706. private _debugMode;
  40707. private _moving;
  40708. /**
  40709. * Fires each time the attached mesh is dragged with the pointer
  40710. * * delta between last drag position and current drag position in world space
  40711. * * dragDistance along the drag axis
  40712. * * dragPlaneNormal normal of the current drag plane used during the drag
  40713. * * dragPlanePoint in world space where the drag intersects the drag plane
  40714. */
  40715. onDragObservable: Observable<{
  40716. delta: Vector3;
  40717. dragPlanePoint: Vector3;
  40718. dragPlaneNormal: Vector3;
  40719. dragDistance: number;
  40720. pointerId: number;
  40721. }>;
  40722. /**
  40723. * Fires each time a drag begins (eg. mouse down on mesh)
  40724. */
  40725. onDragStartObservable: Observable<{
  40726. dragPlanePoint: Vector3;
  40727. pointerId: number;
  40728. }>;
  40729. /**
  40730. * Fires each time a drag ends (eg. mouse release after drag)
  40731. */
  40732. onDragEndObservable: Observable<{
  40733. dragPlanePoint: Vector3;
  40734. pointerId: number;
  40735. }>;
  40736. /**
  40737. * If the attached mesh should be moved when dragged
  40738. */
  40739. moveAttached: boolean;
  40740. /**
  40741. * If the drag behavior will react to drag events (Default: true)
  40742. */
  40743. enabled: boolean;
  40744. /**
  40745. * If camera controls should be detached during the drag
  40746. */
  40747. detachCameraControls: boolean;
  40748. /**
  40749. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40750. */
  40751. useObjectOrienationForDragging: boolean;
  40752. private _options;
  40753. /**
  40754. * Creates a pointer drag behavior that can be attached to a mesh
  40755. * @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)
  40756. */
  40757. constructor(options?: {
  40758. dragAxis?: Vector3;
  40759. dragPlaneNormal?: Vector3;
  40760. });
  40761. /**
  40762. * The name of the behavior
  40763. */
  40764. readonly name: string;
  40765. /**
  40766. * Initializes the behavior
  40767. */
  40768. init(): void;
  40769. private _tmpVector;
  40770. private _alternatePickedPoint;
  40771. private _worldDragAxis;
  40772. private _targetPosition;
  40773. private _attachedElement;
  40774. /**
  40775. * Attaches the drag behavior the passed in mesh
  40776. * @param ownerNode The mesh that will be dragged around once attached
  40777. */
  40778. attach(ownerNode: Mesh): void;
  40779. /**
  40780. * Force relase the drag action by code.
  40781. */
  40782. releaseDrag(): void;
  40783. private _startDragRay;
  40784. private _lastPointerRay;
  40785. /**
  40786. * Simulates the start of a pointer drag event on the behavior
  40787. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40788. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40789. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40790. */
  40791. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40792. private _startDrag;
  40793. private _dragDelta;
  40794. private _moveDrag;
  40795. private _pickWithRayOnDragPlane;
  40796. private _pointA;
  40797. private _pointB;
  40798. private _pointC;
  40799. private _lineA;
  40800. private _lineB;
  40801. private _localAxis;
  40802. private _lookAt;
  40803. private _updateDragPlanePosition;
  40804. /**
  40805. * Detaches the behavior from the mesh
  40806. */
  40807. detach(): void;
  40808. }
  40809. }
  40810. declare module BABYLON {
  40811. /**
  40812. * 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
  40813. */
  40814. class SixDofDragBehavior implements Behavior<Mesh> {
  40815. private static _virtualScene;
  40816. private _ownerNode;
  40817. private _sceneRenderObserver;
  40818. private _scene;
  40819. private _targetPosition;
  40820. private _virtualOriginMesh;
  40821. private _virtualDragMesh;
  40822. private _pointerObserver;
  40823. private _moving;
  40824. private _startingOrientation;
  40825. /**
  40826. * 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)
  40827. */
  40828. private zDragFactor;
  40829. /**
  40830. * If the behavior is currently in a dragging state
  40831. */
  40832. dragging: boolean;
  40833. /**
  40834. * 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)
  40835. */
  40836. dragDeltaRatio: number;
  40837. /**
  40838. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40839. */
  40840. currentDraggingPointerID: number;
  40841. /**
  40842. * If camera controls should be detached during the drag
  40843. */
  40844. detachCameraControls: boolean;
  40845. /**
  40846. * Fires each time a drag starts
  40847. */
  40848. onDragStartObservable: Observable<{}>;
  40849. /**
  40850. * Fires each time a drag ends (eg. mouse release after drag)
  40851. */
  40852. onDragEndObservable: Observable<{}>;
  40853. /**
  40854. * 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
  40855. */
  40856. constructor();
  40857. /**
  40858. * The name of the behavior
  40859. */
  40860. readonly name: string;
  40861. /**
  40862. * Initializes the behavior
  40863. */
  40864. init(): void;
  40865. /**
  40866. * Attaches the scale behavior the passed in mesh
  40867. * @param ownerNode The mesh that will be scaled around once attached
  40868. */
  40869. attach(ownerNode: Mesh): void;
  40870. /**
  40871. * Detaches the behavior from the mesh
  40872. */
  40873. detach(): void;
  40874. }
  40875. }
  40876. declare module BABYLON {
  40877. /**
  40878. * Manage the gamepad inputs to control an arc rotate camera.
  40879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40880. */
  40881. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40882. /**
  40883. * Defines the camera the input is attached to.
  40884. */
  40885. camera: ArcRotateCamera;
  40886. /**
  40887. * Defines the gamepad the input is gathering event from.
  40888. */
  40889. gamepad: Nullable<Gamepad>;
  40890. /**
  40891. * Defines the gamepad rotation sensiblity.
  40892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40893. */
  40894. gamepadRotationSensibility: number;
  40895. /**
  40896. * Defines the gamepad move sensiblity.
  40897. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40898. */
  40899. gamepadMoveSensibility: number;
  40900. private _onGamepadConnectedObserver;
  40901. private _onGamepadDisconnectedObserver;
  40902. /**
  40903. * Attach the input controls to a specific dom element to get the input from.
  40904. * @param element Defines the element the controls should be listened from
  40905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40906. */
  40907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40908. /**
  40909. * Detach the current controls from the specified dom element.
  40910. * @param element Defines the element to stop listening the inputs from
  40911. */
  40912. detachControl(element: Nullable<HTMLElement>): void;
  40913. /**
  40914. * Update the current camera state depending on the inputs that have been used this frame.
  40915. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40916. */
  40917. checkInputs(): void;
  40918. /**
  40919. * Gets the class name of the current intput.
  40920. * @returns the class name
  40921. */
  40922. getClassName(): string;
  40923. /**
  40924. * Get the friendly name associated with the input class.
  40925. * @returns the input friendly name
  40926. */
  40927. getSimpleName(): string;
  40928. }
  40929. }
  40930. declare module BABYLON {
  40931. /**
  40932. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40934. */
  40935. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40936. /**
  40937. * Defines the camera the input is attached to.
  40938. */
  40939. camera: ArcRotateCamera;
  40940. /**
  40941. * Defines the list of key codes associated with the up action (increase alpha)
  40942. */
  40943. keysUp: number[];
  40944. /**
  40945. * Defines the list of key codes associated with the down action (decrease alpha)
  40946. */
  40947. keysDown: number[];
  40948. /**
  40949. * Defines the list of key codes associated with the left action (increase beta)
  40950. */
  40951. keysLeft: number[];
  40952. /**
  40953. * Defines the list of key codes associated with the right action (decrease beta)
  40954. */
  40955. keysRight: number[];
  40956. /**
  40957. * Defines the list of key codes associated with the reset action.
  40958. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40959. */
  40960. keysReset: number[];
  40961. /**
  40962. * Defines the panning sensibility of the inputs.
  40963. * (How fast is the camera paning)
  40964. */
  40965. panningSensibility: number;
  40966. /**
  40967. * Defines the zooming sensibility of the inputs.
  40968. * (How fast is the camera zooming)
  40969. */
  40970. zoomingSensibility: number;
  40971. /**
  40972. * Defines wether maintaining the alt key down switch the movement mode from
  40973. * orientation to zoom.
  40974. */
  40975. useAltToZoom: boolean;
  40976. /**
  40977. * Rotation speed of the camera
  40978. */
  40979. angularSpeed: number;
  40980. private _keys;
  40981. private _ctrlPressed;
  40982. private _altPressed;
  40983. private _onCanvasBlurObserver;
  40984. private _onKeyboardObserver;
  40985. private _engine;
  40986. private _scene;
  40987. /**
  40988. * Attach the input controls to a specific dom element to get the input from.
  40989. * @param element Defines the element the controls should be listened from
  40990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40991. */
  40992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40993. /**
  40994. * Detach the current controls from the specified dom element.
  40995. * @param element Defines the element to stop listening the inputs from
  40996. */
  40997. detachControl(element: Nullable<HTMLElement>): void;
  40998. /**
  40999. * Update the current camera state depending on the inputs that have been used this frame.
  41000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41001. */
  41002. checkInputs(): void;
  41003. /**
  41004. * Gets the class name of the current intput.
  41005. * @returns the class name
  41006. */
  41007. getClassName(): string;
  41008. /**
  41009. * Get the friendly name associated with the input class.
  41010. * @returns the input friendly name
  41011. */
  41012. getSimpleName(): string;
  41013. }
  41014. }
  41015. declare module BABYLON {
  41016. /**
  41017. * Manage the mouse wheel inputs to control an arc rotate camera.
  41018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41019. */
  41020. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41021. /**
  41022. * Defines the camera the input is attached to.
  41023. */
  41024. camera: ArcRotateCamera;
  41025. /**
  41026. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41027. */
  41028. wheelPrecision: number;
  41029. /**
  41030. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41031. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41032. */
  41033. wheelDeltaPercentage: number;
  41034. private _wheel;
  41035. private _observer;
  41036. /**
  41037. * Attach the input controls to a specific dom element to get the input from.
  41038. * @param element Defines the element the controls should be listened from
  41039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41040. */
  41041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41042. /**
  41043. * Detach the current controls from the specified dom element.
  41044. * @param element Defines the element to stop listening the inputs from
  41045. */
  41046. detachControl(element: Nullable<HTMLElement>): void;
  41047. /**
  41048. * Gets the class name of the current intput.
  41049. * @returns the class name
  41050. */
  41051. getClassName(): string;
  41052. /**
  41053. * Get the friendly name associated with the input class.
  41054. * @returns the input friendly name
  41055. */
  41056. getSimpleName(): string;
  41057. }
  41058. }
  41059. declare module BABYLON {
  41060. /**
  41061. * Manage the pointers inputs to control an arc rotate camera.
  41062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41063. */
  41064. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41065. /**
  41066. * Defines the camera the input is attached to.
  41067. */
  41068. camera: ArcRotateCamera;
  41069. /**
  41070. * Defines the buttons associated with the input to handle camera move.
  41071. */
  41072. buttons: number[];
  41073. /**
  41074. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41075. */
  41076. angularSensibilityX: number;
  41077. /**
  41078. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41079. */
  41080. angularSensibilityY: number;
  41081. /**
  41082. * Defines the pointer pinch precision or how fast is the camera zooming.
  41083. */
  41084. pinchPrecision: number;
  41085. /**
  41086. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41087. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41088. */
  41089. pinchDeltaPercentage: number;
  41090. /**
  41091. * Defines the pointer panning sensibility or how fast is the camera moving.
  41092. */
  41093. panningSensibility: number;
  41094. /**
  41095. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41096. */
  41097. multiTouchPanning: boolean;
  41098. /**
  41099. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41100. */
  41101. multiTouchPanAndZoom: boolean;
  41102. /**
  41103. * Revers pinch action direction.
  41104. */
  41105. pinchInwards: boolean;
  41106. private _isPanClick;
  41107. private _pointerInput;
  41108. private _observer;
  41109. private _onMouseMove;
  41110. private _onGestureStart;
  41111. private _onGesture;
  41112. private _MSGestureHandler;
  41113. private _onLostFocus;
  41114. private _onContextMenu;
  41115. /**
  41116. * Attach the input controls to a specific dom element to get the input from.
  41117. * @param element Defines the element the controls should be listened from
  41118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41119. */
  41120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41121. /**
  41122. * Detach the current controls from the specified dom element.
  41123. * @param element Defines the element to stop listening the inputs from
  41124. */
  41125. detachControl(element: Nullable<HTMLElement>): void;
  41126. /**
  41127. * Gets the class name of the current intput.
  41128. * @returns the class name
  41129. */
  41130. getClassName(): string;
  41131. /**
  41132. * Get the friendly name associated with the input class.
  41133. * @returns the input friendly name
  41134. */
  41135. getSimpleName(): string;
  41136. }
  41137. }
  41138. declare module BABYLON {
  41139. /**
  41140. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41142. */
  41143. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41144. /**
  41145. * Defines the camera the input is attached to.
  41146. */
  41147. camera: ArcRotateCamera;
  41148. /**
  41149. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41150. */
  41151. alphaCorrection: number;
  41152. /**
  41153. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41154. */
  41155. gammaCorrection: number;
  41156. private _alpha;
  41157. private _gamma;
  41158. private _dirty;
  41159. private _deviceOrientationHandler;
  41160. /**
  41161. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41162. */
  41163. constructor();
  41164. /**
  41165. * Attach the input controls to a specific dom element to get the input from.
  41166. * @param element Defines the element the controls should be listened from
  41167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41168. */
  41169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41170. /** @hidden */
  41171. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41172. /**
  41173. * Update the current camera state depending on the inputs that have been used this frame.
  41174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41175. */
  41176. checkInputs(): void;
  41177. /**
  41178. * Detach the current controls from the specified dom element.
  41179. * @param element Defines the element to stop listening the inputs from
  41180. */
  41181. detachControl(element: Nullable<HTMLElement>): void;
  41182. /**
  41183. * Gets the class name of the current intput.
  41184. * @returns the class name
  41185. */
  41186. getClassName(): string;
  41187. /**
  41188. * Get the friendly name associated with the input class.
  41189. * @returns the input friendly name
  41190. */
  41191. getSimpleName(): string;
  41192. }
  41193. }
  41194. declare module BABYLON {
  41195. /**
  41196. * Listen to keyboard events to control the camera.
  41197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41198. */
  41199. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41200. /**
  41201. * Defines the camera the input is attached to.
  41202. */
  41203. camera: FlyCamera;
  41204. /**
  41205. * The list of keyboard keys used to control the forward move of the camera.
  41206. */
  41207. keysForward: number[];
  41208. /**
  41209. * The list of keyboard keys used to control the backward move of the camera.
  41210. */
  41211. keysBackward: number[];
  41212. /**
  41213. * The list of keyboard keys used to control the forward move of the camera.
  41214. */
  41215. keysUp: number[];
  41216. /**
  41217. * The list of keyboard keys used to control the backward move of the camera.
  41218. */
  41219. keysDown: number[];
  41220. /**
  41221. * The list of keyboard keys used to control the right strafe move of the camera.
  41222. */
  41223. keysRight: number[];
  41224. /**
  41225. * The list of keyboard keys used to control the left strafe move of the camera.
  41226. */
  41227. keysLeft: number[];
  41228. private _keys;
  41229. private _onCanvasBlurObserver;
  41230. private _onKeyboardObserver;
  41231. private _engine;
  41232. private _scene;
  41233. /**
  41234. * Attach the input controls to a specific dom element to get the input from.
  41235. * @param element Defines the element the controls should be listened from
  41236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41237. */
  41238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41239. /**
  41240. * Detach the current controls from the specified dom element.
  41241. * @param element Defines the element to stop listening the inputs from
  41242. */
  41243. detachControl(element: Nullable<HTMLElement>): void;
  41244. /**
  41245. * Gets the class name of the current intput.
  41246. * @returns the class name
  41247. */
  41248. getClassName(): string;
  41249. /** @hidden */
  41250. _onLostFocus(e: FocusEvent): void;
  41251. /**
  41252. * Get the friendly name associated with the input class.
  41253. * @returns the input friendly name
  41254. */
  41255. getSimpleName(): string;
  41256. /**
  41257. * Update the current camera state depending on the inputs that have been used this frame.
  41258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41259. */
  41260. checkInputs(): void;
  41261. }
  41262. }
  41263. declare module BABYLON {
  41264. /**
  41265. * Listen to mouse events to control the camera.
  41266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41267. */
  41268. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41269. /**
  41270. * Defines the camera the input is attached to.
  41271. */
  41272. camera: FlyCamera;
  41273. /**
  41274. * Defines if touch is enabled. (Default is true.)
  41275. */
  41276. touchEnabled: boolean;
  41277. /**
  41278. * Defines the buttons associated with the input to handle camera rotation.
  41279. */
  41280. buttons: number[];
  41281. /**
  41282. * Assign buttons for Yaw control.
  41283. */
  41284. buttonsYaw: number[];
  41285. /**
  41286. * Assign buttons for Pitch control.
  41287. */
  41288. buttonsPitch: number[];
  41289. /**
  41290. * Assign buttons for Roll control.
  41291. */
  41292. buttonsRoll: number[];
  41293. /**
  41294. * Detect if any button is being pressed while mouse is moved.
  41295. * -1 = Mouse locked.
  41296. * 0 = Left button.
  41297. * 1 = Middle Button.
  41298. * 2 = Right Button.
  41299. */
  41300. activeButton: number;
  41301. /**
  41302. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41303. * Higher values reduce its sensitivity.
  41304. */
  41305. angularSensibility: number;
  41306. private _mousemoveCallback;
  41307. private _observer;
  41308. private _rollObserver;
  41309. private previousPosition;
  41310. private noPreventDefault;
  41311. private element;
  41312. /**
  41313. * Listen to mouse events to control the camera.
  41314. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41316. */
  41317. constructor(touchEnabled?: boolean);
  41318. /**
  41319. * Attach the mouse control to the HTML DOM element.
  41320. * @param element Defines the element that listens to the input events.
  41321. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41322. */
  41323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41324. /**
  41325. * Detach the current controls from the specified dom element.
  41326. * @param element Defines the element to stop listening the inputs from
  41327. */
  41328. detachControl(element: Nullable<HTMLElement>): void;
  41329. /**
  41330. * Gets the class name of the current input.
  41331. * @returns the class name.
  41332. */
  41333. getClassName(): string;
  41334. /**
  41335. * Get the friendly name associated with the input class.
  41336. * @returns the input's friendly name.
  41337. */
  41338. getSimpleName(): string;
  41339. private _pointerInput;
  41340. private _onMouseMove;
  41341. /**
  41342. * Rotate camera by mouse offset.
  41343. */
  41344. private rotateCamera;
  41345. }
  41346. }
  41347. declare module BABYLON {
  41348. /**
  41349. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41350. * Screen rotation is taken into account.
  41351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41352. */
  41353. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41354. private _camera;
  41355. private _screenOrientationAngle;
  41356. private _constantTranform;
  41357. private _screenQuaternion;
  41358. private _alpha;
  41359. private _beta;
  41360. private _gamma;
  41361. /**
  41362. * Instantiates a new input
  41363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41364. */
  41365. constructor();
  41366. /**
  41367. * Define the camera controlled by the input.
  41368. */
  41369. camera: FreeCamera;
  41370. /**
  41371. * Attach the input controls to a specific dom element to get the input from.
  41372. * @param element Defines the element the controls should be listened from
  41373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41374. */
  41375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41376. private _orientationChanged;
  41377. private _deviceOrientation;
  41378. /**
  41379. * Detach the current controls from the specified dom element.
  41380. * @param element Defines the element to stop listening the inputs from
  41381. */
  41382. detachControl(element: Nullable<HTMLElement>): void;
  41383. /**
  41384. * Update the current camera state depending on the inputs that have been used this frame.
  41385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41386. */
  41387. checkInputs(): void;
  41388. /**
  41389. * Gets the class name of the current intput.
  41390. * @returns the class name
  41391. */
  41392. getClassName(): string;
  41393. /**
  41394. * Get the friendly name associated with the input class.
  41395. * @returns the input friendly name
  41396. */
  41397. getSimpleName(): string;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Manage the gamepad inputs to control a free camera.
  41403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41404. */
  41405. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41406. /**
  41407. * Define the camera the input is attached to.
  41408. */
  41409. camera: FreeCamera;
  41410. /**
  41411. * Define the Gamepad controlling the input
  41412. */
  41413. gamepad: Nullable<Gamepad>;
  41414. /**
  41415. * Defines the gamepad rotation sensiblity.
  41416. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41417. */
  41418. gamepadAngularSensibility: number;
  41419. /**
  41420. * Defines the gamepad move sensiblity.
  41421. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41422. */
  41423. gamepadMoveSensibility: number;
  41424. private _onGamepadConnectedObserver;
  41425. private _onGamepadDisconnectedObserver;
  41426. private _cameraTransform;
  41427. private _deltaTransform;
  41428. private _vector3;
  41429. private _vector2;
  41430. /**
  41431. * Attach the input controls to a specific dom element to get the input from.
  41432. * @param element Defines the element the controls should be listened from
  41433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41434. */
  41435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41436. /**
  41437. * Detach the current controls from the specified dom element.
  41438. * @param element Defines the element to stop listening the inputs from
  41439. */
  41440. detachControl(element: Nullable<HTMLElement>): void;
  41441. /**
  41442. * Update the current camera state depending on the inputs that have been used this frame.
  41443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41444. */
  41445. checkInputs(): void;
  41446. /**
  41447. * Gets the class name of the current intput.
  41448. * @returns the class name
  41449. */
  41450. getClassName(): string;
  41451. /**
  41452. * Get the friendly name associated with the input class.
  41453. * @returns the input friendly name
  41454. */
  41455. getSimpleName(): string;
  41456. }
  41457. }
  41458. declare module BABYLON {
  41459. /**
  41460. * Manage the keyboard inputs to control the movement of a free camera.
  41461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41462. */
  41463. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41464. /**
  41465. * Defines the camera the input is attached to.
  41466. */
  41467. camera: FreeCamera;
  41468. /**
  41469. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41470. */
  41471. keysUp: number[];
  41472. /**
  41473. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41474. */
  41475. keysDown: number[];
  41476. /**
  41477. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41478. */
  41479. keysLeft: number[];
  41480. /**
  41481. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41482. */
  41483. keysRight: number[];
  41484. private _keys;
  41485. private _onCanvasBlurObserver;
  41486. private _onKeyboardObserver;
  41487. private _engine;
  41488. private _scene;
  41489. /**
  41490. * Attach the input controls to a specific dom element to get the input from.
  41491. * @param element Defines the element the controls should be listened from
  41492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41493. */
  41494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41495. /**
  41496. * Detach the current controls from the specified dom element.
  41497. * @param element Defines the element to stop listening the inputs from
  41498. */
  41499. detachControl(element: Nullable<HTMLElement>): void;
  41500. /**
  41501. * Update the current camera state depending on the inputs that have been used this frame.
  41502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41503. */
  41504. checkInputs(): void;
  41505. /**
  41506. * Gets the class name of the current intput.
  41507. * @returns the class name
  41508. */
  41509. getClassName(): string;
  41510. /** @hidden */
  41511. _onLostFocus(e: FocusEvent): void;
  41512. /**
  41513. * Get the friendly name associated with the input class.
  41514. * @returns the input friendly name
  41515. */
  41516. getSimpleName(): string;
  41517. }
  41518. }
  41519. declare module BABYLON {
  41520. /**
  41521. * Manage the mouse inputs to control the movement of a free camera.
  41522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41523. */
  41524. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41525. /**
  41526. * Define if touch is enabled in the mouse input
  41527. */
  41528. touchEnabled: boolean;
  41529. /**
  41530. * Defines the camera the input is attached to.
  41531. */
  41532. camera: FreeCamera;
  41533. /**
  41534. * Defines the buttons associated with the input to handle camera move.
  41535. */
  41536. buttons: number[];
  41537. /**
  41538. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41539. */
  41540. angularSensibility: number;
  41541. private _pointerInput;
  41542. private _onMouseMove;
  41543. private _observer;
  41544. private previousPosition;
  41545. /**
  41546. * Manage the mouse inputs to control the movement of a free camera.
  41547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41548. * @param touchEnabled Defines if touch is enabled or not
  41549. */
  41550. constructor(
  41551. /**
  41552. * Define if touch is enabled in the mouse input
  41553. */
  41554. touchEnabled?: boolean);
  41555. /**
  41556. * Attach the input controls to a specific dom element to get the input from.
  41557. * @param element Defines the element the controls should be listened from
  41558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41559. */
  41560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41561. /**
  41562. * Detach the current controls from the specified dom element.
  41563. * @param element Defines the element to stop listening the inputs from
  41564. */
  41565. detachControl(element: Nullable<HTMLElement>): void;
  41566. /**
  41567. * Gets the class name of the current intput.
  41568. * @returns the class name
  41569. */
  41570. getClassName(): string;
  41571. /**
  41572. * Get the friendly name associated with the input class.
  41573. * @returns the input friendly name
  41574. */
  41575. getSimpleName(): string;
  41576. }
  41577. }
  41578. declare module BABYLON {
  41579. /**
  41580. * Manage the touch inputs to control the movement of a free camera.
  41581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41582. */
  41583. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41584. /**
  41585. * Defines the camera the input is attached to.
  41586. */
  41587. camera: FreeCamera;
  41588. /**
  41589. * Defines the touch sensibility for rotation.
  41590. * The higher the faster.
  41591. */
  41592. touchAngularSensibility: number;
  41593. /**
  41594. * Defines the touch sensibility for move.
  41595. * The higher the faster.
  41596. */
  41597. touchMoveSensibility: number;
  41598. private _offsetX;
  41599. private _offsetY;
  41600. private _pointerPressed;
  41601. private _pointerInput;
  41602. private _observer;
  41603. private _onLostFocus;
  41604. /**
  41605. * Attach the input controls to a specific dom element to get the input from.
  41606. * @param element Defines the element the controls should be listened from
  41607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41608. */
  41609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41610. /**
  41611. * Detach the current controls from the specified dom element.
  41612. * @param element Defines the element to stop listening the inputs from
  41613. */
  41614. detachControl(element: Nullable<HTMLElement>): void;
  41615. /**
  41616. * Update the current camera state depending on the inputs that have been used this frame.
  41617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41618. */
  41619. checkInputs(): void;
  41620. /**
  41621. * Gets the class name of the current intput.
  41622. * @returns the class name
  41623. */
  41624. getClassName(): string;
  41625. /**
  41626. * Get the friendly name associated with the input class.
  41627. * @returns the input friendly name
  41628. */
  41629. getSimpleName(): string;
  41630. }
  41631. }
  41632. declare module BABYLON {
  41633. /**
  41634. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41636. */
  41637. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41638. /**
  41639. * Defines the camera the input is attached to.
  41640. */
  41641. camera: FreeCamera;
  41642. private _leftjoystick;
  41643. private _rightjoystick;
  41644. /**
  41645. * Gets the left stick of the virtual joystick.
  41646. * @returns The virtual Joystick
  41647. */
  41648. getLeftJoystick(): VirtualJoystick;
  41649. /**
  41650. * Gets the right stick of the virtual joystick.
  41651. * @returns The virtual Joystick
  41652. */
  41653. getRightJoystick(): VirtualJoystick;
  41654. /**
  41655. * Update the current camera state depending on the inputs that have been used this frame.
  41656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41657. */
  41658. checkInputs(): void;
  41659. /**
  41660. * Attach the input controls to a specific dom element to get the input from.
  41661. * @param element Defines the element the controls should be listened from
  41662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41663. */
  41664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41665. /**
  41666. * Detach the current controls from the specified dom element.
  41667. * @param element Defines the element to stop listening the inputs from
  41668. */
  41669. detachControl(element: Nullable<HTMLElement>): void;
  41670. /**
  41671. * Gets the class name of the current intput.
  41672. * @returns the class name
  41673. */
  41674. getClassName(): string;
  41675. /**
  41676. * Get the friendly name associated with the input class.
  41677. * @returns the input friendly name
  41678. */
  41679. getSimpleName(): string;
  41680. }
  41681. }
  41682. declare module BABYLON {
  41683. /**
  41684. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41685. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41686. */
  41687. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41688. /**
  41689. * Creates a new AnaglyphArcRotateCamera
  41690. * @param name defines camera name
  41691. * @param alpha defines alpha angle (in radians)
  41692. * @param beta defines beta angle (in radians)
  41693. * @param radius defines radius
  41694. * @param target defines camera target
  41695. * @param interaxialDistance defines distance between each color axis
  41696. * @param scene defines the hosting scene
  41697. */
  41698. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41699. /**
  41700. * Gets camera class name
  41701. * @returns AnaglyphArcRotateCamera
  41702. */
  41703. getClassName(): string;
  41704. }
  41705. }
  41706. declare module BABYLON {
  41707. /**
  41708. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41709. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41710. */
  41711. class AnaglyphFreeCamera extends FreeCamera {
  41712. /**
  41713. * Creates a new AnaglyphFreeCamera
  41714. * @param name defines camera name
  41715. * @param position defines initial position
  41716. * @param interaxialDistance defines distance between each color axis
  41717. * @param scene defines the hosting scene
  41718. */
  41719. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41720. /**
  41721. * Gets camera class name
  41722. * @returns AnaglyphFreeCamera
  41723. */
  41724. getClassName(): string;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41730. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41731. */
  41732. class AnaglyphGamepadCamera extends GamepadCamera {
  41733. /**
  41734. * Creates a new AnaglyphGamepadCamera
  41735. * @param name defines camera name
  41736. * @param position defines initial position
  41737. * @param interaxialDistance defines distance between each color axis
  41738. * @param scene defines the hosting scene
  41739. */
  41740. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41741. /**
  41742. * Gets camera class name
  41743. * @returns AnaglyphGamepadCamera
  41744. */
  41745. getClassName(): string;
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. /**
  41750. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41751. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41752. */
  41753. class AnaglyphUniversalCamera extends UniversalCamera {
  41754. /**
  41755. * Creates a new AnaglyphUniversalCamera
  41756. * @param name defines camera name
  41757. * @param position defines initial position
  41758. * @param interaxialDistance defines distance between each color axis
  41759. * @param scene defines the hosting scene
  41760. */
  41761. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41762. /**
  41763. * Gets camera class name
  41764. * @returns AnaglyphUniversalCamera
  41765. */
  41766. getClassName(): string;
  41767. }
  41768. }
  41769. declare module BABYLON {
  41770. /**
  41771. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41772. * @see http://doc.babylonjs.com/features/cameras
  41773. */
  41774. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41775. /**
  41776. * Creates a new StereoscopicArcRotateCamera
  41777. * @param name defines camera name
  41778. * @param alpha defines alpha angle (in radians)
  41779. * @param beta defines beta angle (in radians)
  41780. * @param radius defines radius
  41781. * @param target defines camera target
  41782. * @param interaxialDistance defines distance between each color axis
  41783. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41784. * @param scene defines the hosting scene
  41785. */
  41786. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41787. /**
  41788. * Gets camera class name
  41789. * @returns StereoscopicArcRotateCamera
  41790. */
  41791. getClassName(): string;
  41792. }
  41793. }
  41794. declare module BABYLON {
  41795. /**
  41796. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41797. * @see http://doc.babylonjs.com/features/cameras
  41798. */
  41799. class StereoscopicFreeCamera extends FreeCamera {
  41800. /**
  41801. * Creates a new StereoscopicFreeCamera
  41802. * @param name defines camera name
  41803. * @param position defines initial position
  41804. * @param interaxialDistance defines distance between each color axis
  41805. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41806. * @param scene defines the hosting scene
  41807. */
  41808. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41809. /**
  41810. * Gets camera class name
  41811. * @returns StereoscopicFreeCamera
  41812. */
  41813. getClassName(): string;
  41814. }
  41815. }
  41816. declare module BABYLON {
  41817. /**
  41818. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41819. * @see http://doc.babylonjs.com/features/cameras
  41820. */
  41821. class StereoscopicGamepadCamera extends GamepadCamera {
  41822. /**
  41823. * Creates a new StereoscopicGamepadCamera
  41824. * @param name defines camera name
  41825. * @param position defines initial position
  41826. * @param interaxialDistance defines distance between each color axis
  41827. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41828. * @param scene defines the hosting scene
  41829. */
  41830. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41831. /**
  41832. * Gets camera class name
  41833. * @returns StereoscopicGamepadCamera
  41834. */
  41835. getClassName(): string;
  41836. }
  41837. }
  41838. declare module BABYLON {
  41839. /**
  41840. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41841. * @see http://doc.babylonjs.com/features/cameras
  41842. */
  41843. class StereoscopicUniversalCamera extends UniversalCamera {
  41844. /**
  41845. * Creates a new StereoscopicUniversalCamera
  41846. * @param name defines camera name
  41847. * @param position defines initial position
  41848. * @param interaxialDistance defines distance between each color axis
  41849. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41850. * @param scene defines the hosting scene
  41851. */
  41852. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41853. /**
  41854. * Gets camera class name
  41855. * @returns StereoscopicUniversalCamera
  41856. */
  41857. getClassName(): string;
  41858. }
  41859. }
  41860. declare module BABYLON {
  41861. /**
  41862. * This represents all the required metrics to create a VR camera.
  41863. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41864. */
  41865. class VRCameraMetrics {
  41866. /**
  41867. * Define the horizontal resolution off the screen.
  41868. */
  41869. hResolution: number;
  41870. /**
  41871. * Define the vertical resolution off the screen.
  41872. */
  41873. vResolution: number;
  41874. /**
  41875. * Define the horizontal screen size.
  41876. */
  41877. hScreenSize: number;
  41878. /**
  41879. * Define the vertical screen size.
  41880. */
  41881. vScreenSize: number;
  41882. /**
  41883. * Define the vertical screen center position.
  41884. */
  41885. vScreenCenter: number;
  41886. /**
  41887. * Define the distance of the eyes to the screen.
  41888. */
  41889. eyeToScreenDistance: number;
  41890. /**
  41891. * Define the distance between both lenses
  41892. */
  41893. lensSeparationDistance: number;
  41894. /**
  41895. * Define the distance between both viewer's eyes.
  41896. */
  41897. interpupillaryDistance: number;
  41898. /**
  41899. * Define the distortion factor of the VR postprocess.
  41900. * Please, touch with care.
  41901. */
  41902. distortionK: number[];
  41903. /**
  41904. * Define the chromatic aberration correction factors for the VR post process.
  41905. */
  41906. chromaAbCorrection: number[];
  41907. /**
  41908. * Define the scale factor of the post process.
  41909. * The smaller the better but the slower.
  41910. */
  41911. postProcessScaleFactor: number;
  41912. /**
  41913. * Define an offset for the lens center.
  41914. */
  41915. lensCenterOffset: number;
  41916. /**
  41917. * Define if the current vr camera should compensate the distortion of the lense or not.
  41918. */
  41919. compensateDistortion: boolean;
  41920. /**
  41921. * Gets the rendering aspect ratio based on the provided resolutions.
  41922. */
  41923. readonly aspectRatio: number;
  41924. /**
  41925. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41926. */
  41927. readonly aspectRatioFov: number;
  41928. /**
  41929. * @hidden
  41930. */
  41931. readonly leftHMatrix: Matrix;
  41932. /**
  41933. * @hidden
  41934. */
  41935. readonly rightHMatrix: Matrix;
  41936. /**
  41937. * @hidden
  41938. */
  41939. readonly leftPreViewMatrix: Matrix;
  41940. /**
  41941. * @hidden
  41942. */
  41943. readonly rightPreViewMatrix: Matrix;
  41944. /**
  41945. * Get the default VRMetrics based on the most generic setup.
  41946. * @returns the default vr metrics
  41947. */
  41948. static GetDefault(): VRCameraMetrics;
  41949. }
  41950. }
  41951. declare module BABYLON {
  41952. /**
  41953. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41954. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41955. */
  41956. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41957. /**
  41958. * Creates a new VRDeviceOrientationArcRotateCamera
  41959. * @param name defines camera name
  41960. * @param alpha defines the camera rotation along the logitudinal axis
  41961. * @param beta defines the camera rotation along the latitudinal axis
  41962. * @param radius defines the camera distance from its target
  41963. * @param target defines the camera target
  41964. * @param scene defines the scene the camera belongs to
  41965. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41966. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41967. */
  41968. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41969. /**
  41970. * Gets camera class name
  41971. * @returns VRDeviceOrientationArcRotateCamera
  41972. */
  41973. getClassName(): string;
  41974. }
  41975. }
  41976. declare module BABYLON {
  41977. /**
  41978. * Camera used to simulate VR rendering (based on FreeCamera)
  41979. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41980. */
  41981. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41982. /**
  41983. * Creates a new VRDeviceOrientationFreeCamera
  41984. * @param name defines camera name
  41985. * @param position defines the start position of the camera
  41986. * @param scene defines the scene the camera belongs to
  41987. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41988. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41989. */
  41990. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41991. /**
  41992. * Gets camera class name
  41993. * @returns VRDeviceOrientationFreeCamera
  41994. */
  41995. getClassName(): string;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42001. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42002. */
  42003. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42004. /**
  42005. * Creates a new VRDeviceOrientationGamepadCamera
  42006. * @param name defines camera name
  42007. * @param position defines the start position of the camera
  42008. * @param scene defines the scene the camera belongs to
  42009. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42010. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42011. */
  42012. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42013. /**
  42014. * Gets camera class name
  42015. * @returns VRDeviceOrientationGamepadCamera
  42016. */
  42017. getClassName(): string;
  42018. }
  42019. }
  42020. declare module BABYLON {
  42021. /**
  42022. * Options to modify the vr teleportation behavior.
  42023. */
  42024. interface VRTeleportationOptions {
  42025. /**
  42026. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42027. */
  42028. floorMeshName?: string;
  42029. /**
  42030. * A list of meshes to be used as the teleportation floor. (default: empty)
  42031. */
  42032. floorMeshes?: Mesh[];
  42033. }
  42034. /**
  42035. * Options to modify the vr experience helper's behavior.
  42036. */
  42037. interface VRExperienceHelperOptions extends WebVROptions {
  42038. /**
  42039. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42040. */
  42041. createDeviceOrientationCamera?: boolean;
  42042. /**
  42043. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42044. */
  42045. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42046. /**
  42047. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42048. */
  42049. laserToggle?: boolean;
  42050. /**
  42051. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42052. */
  42053. floorMeshes?: Mesh[];
  42054. }
  42055. /**
  42056. * Helps to quickly add VR support to an existing scene.
  42057. * See http://doc.babylonjs.com/how_to/webvr_helper
  42058. */
  42059. class VRExperienceHelper {
  42060. /** Options to modify the vr experience helper's behavior. */
  42061. webVROptions: VRExperienceHelperOptions;
  42062. private _scene;
  42063. private _position;
  42064. private _btnVR;
  42065. private _btnVRDisplayed;
  42066. private _webVRsupported;
  42067. private _webVRready;
  42068. private _webVRrequesting;
  42069. private _webVRpresenting;
  42070. private _hasEnteredVR;
  42071. private _fullscreenVRpresenting;
  42072. private _canvas;
  42073. private _webVRCamera;
  42074. private _vrDeviceOrientationCamera;
  42075. private _deviceOrientationCamera;
  42076. private _existingCamera;
  42077. private _onKeyDown;
  42078. private _onVrDisplayPresentChange;
  42079. private _onVRDisplayChanged;
  42080. private _onVRRequestPresentStart;
  42081. private _onVRRequestPresentComplete;
  42082. /**
  42083. * Observable raised when entering VR.
  42084. */
  42085. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42086. /**
  42087. * Observable raised when exiting VR.
  42088. */
  42089. onExitingVRObservable: Observable<VRExperienceHelper>;
  42090. /**
  42091. * Observable raised when controller mesh is loaded.
  42092. */
  42093. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42094. /** Return this.onEnteringVRObservable
  42095. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42096. */
  42097. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42098. /** Return this.onExitingVRObservable
  42099. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42100. */
  42101. readonly onExitingVR: Observable<VRExperienceHelper>;
  42102. /** Return this.onControllerMeshLoadedObservable
  42103. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42104. */
  42105. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42106. private _rayLength;
  42107. private _useCustomVRButton;
  42108. private _teleportationRequested;
  42109. private _teleportActive;
  42110. private _floorMeshName;
  42111. private _floorMeshesCollection;
  42112. private _rotationAllowed;
  42113. private _teleportBackwardsVector;
  42114. private _teleportationTarget;
  42115. private _isDefaultTeleportationTarget;
  42116. private _postProcessMove;
  42117. private _teleportationFillColor;
  42118. private _teleportationBorderColor;
  42119. private _rotationAngle;
  42120. private _haloCenter;
  42121. private _cameraGazer;
  42122. private _padSensibilityUp;
  42123. private _padSensibilityDown;
  42124. private _leftController;
  42125. private _rightController;
  42126. /**
  42127. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42128. */
  42129. onNewMeshSelected: Observable<AbstractMesh>;
  42130. /**
  42131. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42132. */
  42133. onNewMeshPicked: Observable<PickingInfo>;
  42134. private _circleEase;
  42135. /**
  42136. * Observable raised before camera teleportation
  42137. */
  42138. onBeforeCameraTeleport: Observable<Vector3>;
  42139. /**
  42140. * Observable raised after camera teleportation
  42141. */
  42142. onAfterCameraTeleport: Observable<Vector3>;
  42143. /**
  42144. * Observable raised when current selected mesh gets unselected
  42145. */
  42146. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42147. private _raySelectionPredicate;
  42148. /**
  42149. * To be optionaly changed by user to define custom ray selection
  42150. */
  42151. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42152. /**
  42153. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42154. */
  42155. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42156. /**
  42157. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42158. */
  42159. teleportationEnabled: boolean;
  42160. private _defaultHeight;
  42161. private _teleportationInitialized;
  42162. private _interactionsEnabled;
  42163. private _interactionsRequested;
  42164. private _displayGaze;
  42165. private _displayLaserPointer;
  42166. /**
  42167. * The mesh used to display where the user is going to teleport.
  42168. */
  42169. /**
  42170. * Sets the mesh to be used to display where the user is going to teleport.
  42171. */
  42172. teleportationTarget: Mesh;
  42173. /**
  42174. * 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
  42175. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42176. * See http://doc.babylonjs.com/resources/baking_transformations
  42177. */
  42178. gazeTrackerMesh: Mesh;
  42179. /**
  42180. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42181. */
  42182. updateGazeTrackerScale: boolean;
  42183. /**
  42184. * The gaze tracking mesh corresponding to the left controller
  42185. */
  42186. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42187. /**
  42188. * The gaze tracking mesh corresponding to the right controller
  42189. */
  42190. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42191. /**
  42192. * If the ray of the gaze should be displayed.
  42193. */
  42194. /**
  42195. * Sets if the ray of the gaze should be displayed.
  42196. */
  42197. displayGaze: boolean;
  42198. /**
  42199. * If the ray of the LaserPointer should be displayed.
  42200. */
  42201. /**
  42202. * Sets if the ray of the LaserPointer should be displayed.
  42203. */
  42204. displayLaserPointer: boolean;
  42205. /**
  42206. * The deviceOrientationCamera used as the camera when not in VR.
  42207. */
  42208. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42209. /**
  42210. * Based on the current WebVR support, returns the current VR camera used.
  42211. */
  42212. readonly currentVRCamera: Nullable<Camera>;
  42213. /**
  42214. * The webVRCamera which is used when in VR.
  42215. */
  42216. readonly webVRCamera: WebVRFreeCamera;
  42217. /**
  42218. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42219. */
  42220. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42221. private readonly _teleportationRequestInitiated;
  42222. /**
  42223. * Instantiates a VRExperienceHelper.
  42224. * Helps to quickly add VR support to an existing scene.
  42225. * @param scene The scene the VRExperienceHelper belongs to.
  42226. * @param webVROptions Options to modify the vr experience helper's behavior.
  42227. */
  42228. constructor(scene: Scene,
  42229. /** Options to modify the vr experience helper's behavior. */
  42230. webVROptions?: VRExperienceHelperOptions);
  42231. private _onDefaultMeshLoaded;
  42232. private _onResize;
  42233. private _onFullscreenChange;
  42234. /**
  42235. * Gets a value indicating if we are currently in VR mode.
  42236. */
  42237. readonly isInVRMode: boolean;
  42238. private onVrDisplayPresentChange;
  42239. private onVRDisplayChanged;
  42240. private moveButtonToBottomRight;
  42241. private displayVRButton;
  42242. private updateButtonVisibility;
  42243. /**
  42244. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42245. * Otherwise, will use the fullscreen API.
  42246. */
  42247. enterVR(): void;
  42248. /**
  42249. * Attempt to exit VR, or fullscreen.
  42250. */
  42251. exitVR(): void;
  42252. /**
  42253. * The position of the vr experience helper.
  42254. */
  42255. /**
  42256. * Sets the position of the vr experience helper.
  42257. */
  42258. position: Vector3;
  42259. /**
  42260. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42261. */
  42262. enableInteractions(): void;
  42263. private readonly _noControllerIsActive;
  42264. private beforeRender;
  42265. private _isTeleportationFloor;
  42266. /**
  42267. * Adds a floor mesh to be used for teleportation.
  42268. * @param floorMesh the mesh to be used for teleportation.
  42269. */
  42270. addFloorMesh(floorMesh: Mesh): void;
  42271. /**
  42272. * Removes a floor mesh from being used for teleportation.
  42273. * @param floorMesh the mesh to be removed.
  42274. */
  42275. removeFloorMesh(floorMesh: Mesh): void;
  42276. /**
  42277. * Enables interactions and teleportation using the VR controllers and gaze.
  42278. * @param vrTeleportationOptions options to modify teleportation behavior.
  42279. */
  42280. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42281. private _onNewGamepadConnected;
  42282. private _tryEnableInteractionOnController;
  42283. private _onNewGamepadDisconnected;
  42284. private _enableInteractionOnController;
  42285. private _checkTeleportWithRay;
  42286. private _checkRotate;
  42287. private _checkTeleportBackwards;
  42288. private _enableTeleportationOnController;
  42289. private _createTeleportationCircles;
  42290. private _displayTeleportationTarget;
  42291. private _hideTeleportationTarget;
  42292. private _rotateCamera;
  42293. private _moveTeleportationSelectorTo;
  42294. private _workingVector;
  42295. private _workingQuaternion;
  42296. private _workingMatrix;
  42297. /**
  42298. * Teleports the users feet to the desired location
  42299. * @param location The location where the user's feet should be placed
  42300. */
  42301. teleportCamera(location: Vector3): void;
  42302. private _convertNormalToDirectionOfRay;
  42303. private _castRayAndSelectObject;
  42304. private _notifySelectedMeshUnselected;
  42305. /**
  42306. * Sets the color of the laser ray from the vr controllers.
  42307. * @param color new color for the ray.
  42308. */
  42309. changeLaserColor(color: Color3): void;
  42310. /**
  42311. * Sets the color of the ray from the vr headsets gaze.
  42312. * @param color new color for the ray.
  42313. */
  42314. changeGazeColor(color: Color3): void;
  42315. /**
  42316. * Exits VR and disposes of the vr experience helper
  42317. */
  42318. dispose(): void;
  42319. /**
  42320. * Gets the name of the VRExperienceHelper class
  42321. * @returns "VRExperienceHelper"
  42322. */
  42323. getClassName(): string;
  42324. }
  42325. }
  42326. declare module BABYLON {
  42327. /**
  42328. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42329. * IMPORTANT!! The data is right-hand data.
  42330. * @export
  42331. * @interface DevicePose
  42332. */
  42333. interface DevicePose {
  42334. /**
  42335. * The position of the device, values in array are [x,y,z].
  42336. */
  42337. readonly position: Nullable<Float32Array>;
  42338. /**
  42339. * The linearVelocity of the device, values in array are [x,y,z].
  42340. */
  42341. readonly linearVelocity: Nullable<Float32Array>;
  42342. /**
  42343. * The linearAcceleration of the device, values in array are [x,y,z].
  42344. */
  42345. readonly linearAcceleration: Nullable<Float32Array>;
  42346. /**
  42347. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42348. */
  42349. readonly orientation: Nullable<Float32Array>;
  42350. /**
  42351. * The angularVelocity of the device, values in array are [x,y,z].
  42352. */
  42353. readonly angularVelocity: Nullable<Float32Array>;
  42354. /**
  42355. * The angularAcceleration of the device, values in array are [x,y,z].
  42356. */
  42357. readonly angularAcceleration: Nullable<Float32Array>;
  42358. }
  42359. /**
  42360. * Interface representing a pose controlled object in Babylon.
  42361. * A pose controlled object has both regular pose values as well as pose values
  42362. * from an external device such as a VR head mounted display
  42363. */
  42364. interface PoseControlled {
  42365. /**
  42366. * The position of the object in babylon space.
  42367. */
  42368. position: Vector3;
  42369. /**
  42370. * The rotation quaternion of the object in babylon space.
  42371. */
  42372. rotationQuaternion: Quaternion;
  42373. /**
  42374. * The position of the device in babylon space.
  42375. */
  42376. devicePosition?: Vector3;
  42377. /**
  42378. * The rotation quaternion of the device in babylon space.
  42379. */
  42380. deviceRotationQuaternion: Quaternion;
  42381. /**
  42382. * The raw pose coming from the device.
  42383. */
  42384. rawPose: Nullable<DevicePose>;
  42385. /**
  42386. * The scale of the device to be used when translating from device space to babylon space.
  42387. */
  42388. deviceScaleFactor: number;
  42389. /**
  42390. * Updates the poseControlled values based on the input device pose.
  42391. * @param poseData the pose data to update the object with
  42392. */
  42393. updateFromDevice(poseData: DevicePose): void;
  42394. }
  42395. /**
  42396. * Set of options to customize the webVRCamera
  42397. */
  42398. interface WebVROptions {
  42399. /**
  42400. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42401. */
  42402. trackPosition?: boolean;
  42403. /**
  42404. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42405. */
  42406. positionScale?: number;
  42407. /**
  42408. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42409. */
  42410. displayName?: string;
  42411. /**
  42412. * Should the native controller meshes be initialized. (default: true)
  42413. */
  42414. controllerMeshes?: boolean;
  42415. /**
  42416. * Creating a default HemiLight only on controllers. (default: true)
  42417. */
  42418. defaultLightingOnControllers?: boolean;
  42419. /**
  42420. * If you don't want to use the default VR button of the helper. (default: false)
  42421. */
  42422. useCustomVRButton?: boolean;
  42423. /**
  42424. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42425. */
  42426. customVRButton?: HTMLButtonElement;
  42427. /**
  42428. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42429. */
  42430. rayLength?: number;
  42431. /**
  42432. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42433. */
  42434. defaultHeight?: number;
  42435. }
  42436. /**
  42437. * This represents a WebVR camera.
  42438. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42439. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42440. */
  42441. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42442. private webVROptions;
  42443. /**
  42444. * @hidden
  42445. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42446. */
  42447. _vrDevice: any;
  42448. /**
  42449. * The rawPose of the vrDevice.
  42450. */
  42451. rawPose: Nullable<DevicePose>;
  42452. private _onVREnabled;
  42453. private _specsVersion;
  42454. private _attached;
  42455. private _frameData;
  42456. protected _descendants: Array<Node>;
  42457. private _deviceRoomPosition;
  42458. /** @hidden */
  42459. _deviceRoomRotationQuaternion: Quaternion;
  42460. private _standingMatrix;
  42461. /**
  42462. * Represents device position in babylon space.
  42463. */
  42464. devicePosition: Vector3;
  42465. /**
  42466. * Represents device rotation in babylon space.
  42467. */
  42468. deviceRotationQuaternion: Quaternion;
  42469. /**
  42470. * The scale of the device to be used when translating from device space to babylon space.
  42471. */
  42472. deviceScaleFactor: number;
  42473. private _deviceToWorld;
  42474. private _worldToDevice;
  42475. /**
  42476. * References to the webVR controllers for the vrDevice.
  42477. */
  42478. controllers: Array<WebVRController>;
  42479. /**
  42480. * Emits an event when a controller is attached.
  42481. */
  42482. onControllersAttachedObservable: Observable<WebVRController[]>;
  42483. /**
  42484. * Emits an event when a controller's mesh has been loaded;
  42485. */
  42486. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42487. /**
  42488. * Emits an event when the HMD's pose has been updated.
  42489. */
  42490. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42491. private _poseSet;
  42492. /**
  42493. * If the rig cameras be used as parent instead of this camera.
  42494. */
  42495. rigParenting: boolean;
  42496. private _lightOnControllers;
  42497. private _defaultHeight?;
  42498. /**
  42499. * Instantiates a WebVRFreeCamera.
  42500. * @param name The name of the WebVRFreeCamera
  42501. * @param position The starting anchor position for the camera
  42502. * @param scene The scene the camera belongs to
  42503. * @param webVROptions a set of customizable options for the webVRCamera
  42504. */
  42505. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42506. /**
  42507. * Gets the device distance from the ground in meters.
  42508. * @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.
  42509. */
  42510. deviceDistanceToRoomGround(): number;
  42511. /**
  42512. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42513. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42514. */
  42515. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42516. /**
  42517. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42518. * @returns A promise with a boolean set to if the standing matrix is supported.
  42519. */
  42520. useStandingMatrixAsync(): Promise<boolean>;
  42521. /**
  42522. * Disposes the camera
  42523. */
  42524. dispose(): void;
  42525. /**
  42526. * Gets a vrController by name.
  42527. * @param name The name of the controller to retreive
  42528. * @returns the controller matching the name specified or null if not found
  42529. */
  42530. getControllerByName(name: string): Nullable<WebVRController>;
  42531. private _leftController;
  42532. /**
  42533. * The controller corrisponding to the users left hand.
  42534. */
  42535. readonly leftController: Nullable<WebVRController>;
  42536. private _rightController;
  42537. /**
  42538. * The controller corrisponding to the users right hand.
  42539. */
  42540. readonly rightController: Nullable<WebVRController>;
  42541. /**
  42542. * Casts a ray forward from the vrCamera's gaze.
  42543. * @param length Length of the ray (default: 100)
  42544. * @returns the ray corrisponding to the gaze
  42545. */
  42546. getForwardRay(length?: number): Ray;
  42547. /**
  42548. * @hidden
  42549. * Updates the camera based on device's frame data
  42550. */
  42551. _checkInputs(): void;
  42552. /**
  42553. * Updates the poseControlled values based on the input device pose.
  42554. * @param poseData Pose coming from the device
  42555. */
  42556. updateFromDevice(poseData: DevicePose): void;
  42557. private _htmlElementAttached;
  42558. private _detachIfAttached;
  42559. /**
  42560. * WebVR's attach control will start broadcasting frames to the device.
  42561. * Note that in certain browsers (chrome for example) this function must be called
  42562. * within a user-interaction callback. Example:
  42563. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42564. *
  42565. * @param element html element to attach the vrDevice to
  42566. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42567. */
  42568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42569. /**
  42570. * Detaches the camera from the html element and disables VR
  42571. *
  42572. * @param element html element to detach from
  42573. */
  42574. detachControl(element: HTMLElement): void;
  42575. /**
  42576. * @returns the name of this class
  42577. */
  42578. getClassName(): string;
  42579. /**
  42580. * Calls resetPose on the vrDisplay
  42581. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42582. */
  42583. resetToCurrentRotation(): void;
  42584. /**
  42585. * @hidden
  42586. * Updates the rig cameras (left and right eye)
  42587. */
  42588. _updateRigCameras(): void;
  42589. private _workingVector;
  42590. private _oneVector;
  42591. private _workingMatrix;
  42592. private updateCacheCalled;
  42593. private _correctPositionIfNotTrackPosition;
  42594. /**
  42595. * @hidden
  42596. * Updates the cached values of the camera
  42597. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42598. */
  42599. _updateCache(ignoreParentClass?: boolean): void;
  42600. /**
  42601. * @hidden
  42602. * Get current device position in babylon world
  42603. */
  42604. _computeDevicePosition(): void;
  42605. /**
  42606. * Updates the current device position and rotation in the babylon world
  42607. */
  42608. update(): void;
  42609. /**
  42610. * @hidden
  42611. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42612. * @returns an identity matrix
  42613. */
  42614. _getViewMatrix(): Matrix;
  42615. private _tmpMatrix;
  42616. /**
  42617. * This function is called by the two RIG cameras.
  42618. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42619. */
  42620. protected _getWebVRViewMatrix(): Matrix;
  42621. protected _getWebVRProjectionMatrix(): Matrix;
  42622. private _onGamepadConnectedObserver;
  42623. private _onGamepadDisconnectedObserver;
  42624. private _updateCacheWhenTrackingDisabledObserver;
  42625. /**
  42626. * Initializes the controllers and their meshes
  42627. */
  42628. initControllers(): void;
  42629. }
  42630. }
  42631. declare module BABYLON {
  42632. /**
  42633. * WebXR Camera which holds the views for the xrSession
  42634. * @see https://doc.babylonjs.com/how_to/webxr
  42635. */
  42636. class WebXRCamera extends FreeCamera {
  42637. private static _TmpMatrix;
  42638. /**
  42639. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42640. * @param name the name of the camera
  42641. * @param scene the scene to add the camera to
  42642. */
  42643. constructor(name: string, scene: BABYLON.Scene);
  42644. private _updateNumberOfRigCameras;
  42645. /** @hidden */
  42646. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42647. /**
  42648. * Updates the cameras position from the current pose information of the XR session
  42649. * @param xrSessionManager the session containing pose information
  42650. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42651. */
  42652. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42653. }
  42654. }
  42655. declare module BABYLON {
  42656. /**
  42657. * Button which can be used to enter a different mode of XR
  42658. */
  42659. class WebXREnterExitUIButton {
  42660. /** button element */
  42661. element: HTMLElement;
  42662. /** XR initialization options for the button */
  42663. initializationOptions: XRSessionCreationOptions;
  42664. /**
  42665. * Creates a WebXREnterExitUIButton
  42666. * @param element button element
  42667. * @param initializationOptions XR initialization options for the button
  42668. */
  42669. constructor(
  42670. /** button element */
  42671. element: HTMLElement,
  42672. /** XR initialization options for the button */
  42673. initializationOptions: XRSessionCreationOptions);
  42674. /**
  42675. * Overwritable function which can be used to update the button's visuals when the state changes
  42676. * @param activeButton the current active button in the UI
  42677. */
  42678. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42679. }
  42680. /**
  42681. * Options to create the webXR UI
  42682. */
  42683. class WebXREnterExitUIOptions {
  42684. /**
  42685. * Context to enter xr with
  42686. */
  42687. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42688. /**
  42689. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42690. */
  42691. customButtons?: Array<WebXREnterExitUIButton>;
  42692. }
  42693. /**
  42694. * UI to allow the user to enter/exit XR mode
  42695. */
  42696. class WebXREnterExitUI implements IDisposable {
  42697. private scene;
  42698. private _overlay;
  42699. private _buttons;
  42700. private _activeButton;
  42701. /**
  42702. * Fired every time the active button is changed.
  42703. *
  42704. * When xr is entered via a button that launches xr that button will be the callback parameter
  42705. *
  42706. * When exiting xr the callback parameter will be null)
  42707. */
  42708. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42709. /**
  42710. * Creates UI to allow the user to enter/exit XR mode
  42711. * @param scene the scene to add the ui to
  42712. * @param helper the xr experience helper to enter/exit xr with
  42713. * @param options options to configure the UI
  42714. * @returns the created ui
  42715. */
  42716. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42717. private constructor();
  42718. private _updateButtons;
  42719. /**
  42720. * Disposes of the object
  42721. */
  42722. dispose(): void;
  42723. }
  42724. }
  42725. declare module BABYLON {
  42726. /**
  42727. * States of the webXR experience
  42728. */
  42729. enum WebXRState {
  42730. /**
  42731. * Transitioning to being in XR mode
  42732. */
  42733. ENTERING_XR = 0,
  42734. /**
  42735. * Transitioning to non XR mode
  42736. */
  42737. EXITING_XR = 1,
  42738. /**
  42739. * In XR mode and presenting
  42740. */
  42741. IN_XR = 2,
  42742. /**
  42743. * Not entered XR mode
  42744. */
  42745. NOT_IN_XR = 3
  42746. }
  42747. /**
  42748. * Helper class used to enable XR
  42749. * @see https://doc.babylonjs.com/how_to/webxr
  42750. */
  42751. class WebXRExperienceHelper implements IDisposable {
  42752. private scene;
  42753. /**
  42754. * 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
  42755. */
  42756. container: AbstractMesh;
  42757. /**
  42758. * Camera used to render xr content
  42759. */
  42760. camera: WebXRCamera;
  42761. /**
  42762. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42763. */
  42764. state: WebXRState;
  42765. private _setState;
  42766. private static _TmpVector;
  42767. /**
  42768. * Fires when the state of the experience helper has changed
  42769. */
  42770. onStateChangedObservable: Observable<WebXRState>;
  42771. /** @hidden */
  42772. _sessionManager: WebXRSessionManager;
  42773. private _nonVRCamera;
  42774. private _originalSceneAutoClear;
  42775. private _supported;
  42776. /**
  42777. * Creates the experience helper
  42778. * @param scene the scene to attach the experience helper to
  42779. * @returns a promise for the experience helper
  42780. */
  42781. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  42782. /**
  42783. * Creates a WebXRExperienceHelper
  42784. * @param scene The scene the helper should be created in
  42785. */
  42786. private constructor();
  42787. /**
  42788. * Exits XR mode and returns the scene to its original state
  42789. * @returns promise that resolves after xr mode has exited
  42790. */
  42791. exitXRAsync(): Promise<void>;
  42792. /**
  42793. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42794. * @param sessionCreationOptions options for the XR session
  42795. * @param frameOfReference frame of reference of the XR session
  42796. * @returns promise that resolves after xr mode has entered
  42797. */
  42798. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42799. /**
  42800. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42801. * @param ray ray to cast into the environment
  42802. * @returns Promise which resolves with a collision point in the environment if it exists
  42803. */
  42804. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42805. /**
  42806. * Updates the global position of the camera by moving the camera's container
  42807. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42808. * @param position The desired global position of the camera
  42809. */
  42810. setPositionOfCameraUsingContainer(position: Vector3): void;
  42811. /**
  42812. * Rotates the xr camera by rotating the camera's container around the camera's position
  42813. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42814. * @param rotation the desired quaternion rotation to apply to the camera
  42815. */
  42816. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42817. /**
  42818. * Checks if the creation options are supported by the xr session
  42819. * @param options creation options
  42820. * @returns true if supported
  42821. */
  42822. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42823. /**
  42824. * Disposes of the experience helper
  42825. */
  42826. dispose(): void;
  42827. }
  42828. }
  42829. declare module BABYLON {
  42830. /**
  42831. * Represents an XR input
  42832. */
  42833. class WebXRController {
  42834. /**
  42835. * 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
  42836. */
  42837. grip?: BABYLON.AbstractMesh;
  42838. /**
  42839. * Pointer which can be used to select objects or attach a visible laser to
  42840. */
  42841. pointer: BABYLON.AbstractMesh;
  42842. /**
  42843. * Creates the controller
  42844. * @see https://doc.babylonjs.com/how_to/webxr
  42845. * @param scene the scene which the controller should be associated to
  42846. */
  42847. constructor(scene: BABYLON.Scene);
  42848. /**
  42849. * Disposes of the object
  42850. */
  42851. dispose(): void;
  42852. }
  42853. /**
  42854. * XR input used to track XR inputs such as controllers/rays
  42855. */
  42856. class WebXRInput implements IDisposable {
  42857. private helper;
  42858. /**
  42859. * XR controllers being tracked
  42860. */
  42861. controllers: Array<WebXRController>;
  42862. private _tmpMatrix;
  42863. private _frameObserver;
  42864. /**
  42865. * Initializes the WebXRInput
  42866. * @param helper experience helper which the input should be created for
  42867. */
  42868. constructor(helper: WebXRExperienceHelper);
  42869. /**
  42870. * Disposes of the object
  42871. */
  42872. dispose(): void;
  42873. }
  42874. }
  42875. declare module BABYLON {
  42876. /**
  42877. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42878. */
  42879. class WebXRManagedOutputCanvas implements IDisposable {
  42880. private _canvas;
  42881. /**
  42882. * xrpresent context of the canvas which can be used to display/mirror xr content
  42883. */
  42884. canvasContext: Nullable<WebGLRenderingContext>;
  42885. /**
  42886. * Initializes the canvas to be added/removed upon entering/exiting xr
  42887. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42888. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42889. */
  42890. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42891. /**
  42892. * Disposes of the object
  42893. */
  42894. dispose(): void;
  42895. private _setManagedOutputCanvas;
  42896. private _addCanvas;
  42897. private _removeCanvas;
  42898. }
  42899. }
  42900. declare module BABYLON {
  42901. /**
  42902. * Manages an XRSession
  42903. * @see https://doc.babylonjs.com/how_to/webxr
  42904. */
  42905. class WebXRSessionManager implements IDisposable {
  42906. private scene;
  42907. /**
  42908. * Fires every time a new xrFrame arrives which can be used to update the camera
  42909. */
  42910. onXRFrameObservable: Observable<any>;
  42911. /**
  42912. * Fires when the xr session is ended either by the device or manually done
  42913. */
  42914. onXRSessionEnded: Observable<any>;
  42915. /** @hidden */
  42916. _xrSession: XRSession;
  42917. /** @hidden */
  42918. _frameOfReference: XRFrameOfReference;
  42919. /** @hidden */
  42920. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42921. /** @hidden */
  42922. _currentXRFrame: Nullable<XRFrame>;
  42923. private _xrNavigator;
  42924. private _xrDevice;
  42925. private _tmpMatrix;
  42926. /**
  42927. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42928. * @param scene The scene which the session should be created for
  42929. */
  42930. constructor(scene: BABYLON.Scene);
  42931. /**
  42932. * Initializes the manager
  42933. * After initialization enterXR can be called to start an XR session
  42934. * @returns Promise which resolves after it is initialized
  42935. */
  42936. initializeAsync(): Promise<void>;
  42937. /**
  42938. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  42939. * @param sessionCreationOptions xr options to create the session with
  42940. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42941. * @returns Promise which resolves after it enters XR
  42942. */
  42943. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42944. /**
  42945. * Stops the xrSession and restores the renderloop
  42946. * @returns Promise which resolves after it exits XR
  42947. */
  42948. exitXRAsync(): Promise<void>;
  42949. /**
  42950. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42951. * @param ray ray to cast into the environment
  42952. * @returns Promise which resolves with a collision point in the environment if it exists
  42953. */
  42954. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42955. /**
  42956. * Checks if a session would be supported for the creation options specified
  42957. * @param options creation options to check if they are supported
  42958. * @returns true if supported
  42959. */
  42960. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42961. /**
  42962. * @hidden
  42963. * Converts the render layer of xrSession to a render target
  42964. * @param session session to create render target for
  42965. * @param scene scene the new render target should be created for
  42966. */
  42967. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42968. /**
  42969. * Disposes of the session manager
  42970. */
  42971. dispose(): void;
  42972. }
  42973. }
  42974. declare module BABYLON {
  42975. /**
  42976. * Contains an array of blocks representing the octree
  42977. */
  42978. interface IOctreeContainer<T> {
  42979. /**
  42980. * Blocks within the octree
  42981. */
  42982. blocks: Array<OctreeBlock<T>>;
  42983. }
  42984. /**
  42985. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42987. */
  42988. class Octree<T> {
  42989. /** 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.) */
  42990. maxDepth: number;
  42991. /**
  42992. * Blocks within the octree containing objects
  42993. */
  42994. blocks: Array<OctreeBlock<T>>;
  42995. /**
  42996. * Content stored in the octree
  42997. */
  42998. dynamicContent: T[];
  42999. private _maxBlockCapacity;
  43000. private _selectionContent;
  43001. private _creationFunc;
  43002. /**
  43003. * Creates a octree
  43004. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43005. * @param creationFunc function to be used to instatiate the octree
  43006. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43007. * @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.)
  43008. */
  43009. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43010. /** 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.) */
  43011. maxDepth?: number);
  43012. /**
  43013. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43014. * @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);
  43015. * @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);
  43016. * @param entries meshes to be added to the octree blocks
  43017. */
  43018. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43019. /**
  43020. * Adds a mesh to the octree
  43021. * @param entry Mesh to add to the octree
  43022. */
  43023. addMesh(entry: T): void;
  43024. /**
  43025. * Selects an array of meshes within the frustum
  43026. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43027. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43028. * @returns array of meshes within the frustum
  43029. */
  43030. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43031. /**
  43032. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43033. * @param sphereCenter defines the bounding sphere center
  43034. * @param sphereRadius defines the bounding sphere radius
  43035. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43036. * @returns an array of objects that intersect the sphere
  43037. */
  43038. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43039. /**
  43040. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43041. * @param ray defines the ray to test with
  43042. * @returns array of intersected objects
  43043. */
  43044. intersectsRay(ray: Ray): SmartArray<T>;
  43045. /**
  43046. * @hidden
  43047. */
  43048. 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;
  43049. /**
  43050. * Adds a mesh into the octree block if it intersects the block
  43051. */
  43052. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43053. /**
  43054. * Adds a submesh into the octree block if it intersects the block
  43055. */
  43056. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43057. }
  43058. }
  43059. declare module BABYLON {
  43060. /**
  43061. * Class used to store a cell in an octree
  43062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43063. */
  43064. class OctreeBlock<T> {
  43065. /**
  43066. * Gets the content of the current block
  43067. */
  43068. entries: T[];
  43069. /**
  43070. * Gets the list of block children
  43071. */
  43072. blocks: Array<OctreeBlock<T>>;
  43073. private _depth;
  43074. private _maxDepth;
  43075. private _capacity;
  43076. private _minPoint;
  43077. private _maxPoint;
  43078. private _boundingVectors;
  43079. private _creationFunc;
  43080. /**
  43081. * Creates a new block
  43082. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43083. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43084. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43085. * @param depth defines the current depth of this block in the octree
  43086. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43087. * @param creationFunc defines a callback to call when an element is added to the block
  43088. */
  43089. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43090. /**
  43091. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43092. */
  43093. readonly capacity: number;
  43094. /**
  43095. * Gets the minimum vector (in world space) of the block's bounding box
  43096. */
  43097. readonly minPoint: Vector3;
  43098. /**
  43099. * Gets the maximum vector (in world space) of the block's bounding box
  43100. */
  43101. readonly maxPoint: Vector3;
  43102. /**
  43103. * Add a new element to this block
  43104. * @param entry defines the element to add
  43105. */
  43106. addEntry(entry: T): void;
  43107. /**
  43108. * Add an array of elements to this block
  43109. * @param entries defines the array of elements to add
  43110. */
  43111. addEntries(entries: T[]): void;
  43112. /**
  43113. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43114. * @param frustumPlanes defines the frustum planes to test
  43115. * @param selection defines the array to store current content if selection is positive
  43116. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43117. */
  43118. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43119. /**
  43120. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43121. * @param sphereCenter defines the bounding sphere center
  43122. * @param sphereRadius defines the bounding sphere radius
  43123. * @param selection defines the array to store current content if selection is positive
  43124. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43125. */
  43126. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43127. /**
  43128. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43129. * @param ray defines the ray to test with
  43130. * @param selection defines the array to store current content if selection is positive
  43131. */
  43132. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43133. /**
  43134. * Subdivide the content into child blocks (this block will then be empty)
  43135. */
  43136. createInnerBlocks(): void;
  43137. }
  43138. }
  43139. declare module BABYLON {
  43140. interface Scene {
  43141. /**
  43142. * @hidden
  43143. * Backing Filed
  43144. */
  43145. _selectionOctree: Octree<AbstractMesh>;
  43146. /**
  43147. * Gets the octree used to boost mesh selection (picking)
  43148. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43149. */
  43150. selectionOctree: Octree<AbstractMesh>;
  43151. /**
  43152. * Creates or updates the octree used to boost selection (picking)
  43153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43154. * @param maxCapacity defines the maximum capacity per leaf
  43155. * @param maxDepth defines the maximum depth of the octree
  43156. * @returns an octree of AbstractMesh
  43157. */
  43158. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43159. }
  43160. interface AbstractMesh {
  43161. /**
  43162. * @hidden
  43163. * Backing Field
  43164. */
  43165. _submeshesOctree: Octree<SubMesh>;
  43166. /**
  43167. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43168. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43169. * @param maxCapacity defines the maximum size of each block (64 by default)
  43170. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43171. * @returns the new octree
  43172. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43174. */
  43175. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43176. }
  43177. /**
  43178. * Defines the octree scene component responsible to manage any octrees
  43179. * in a given scene.
  43180. */
  43181. class OctreeSceneComponent {
  43182. /**
  43183. * The component name helpfull to identify the component in the list of scene components.
  43184. */
  43185. readonly name: string;
  43186. /**
  43187. * The scene the component belongs to.
  43188. */
  43189. scene: Scene;
  43190. /**
  43191. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43192. */
  43193. readonly checksIsEnabled: boolean;
  43194. /**
  43195. * Creates a new instance of the component for the given scene
  43196. * @param scene Defines the scene to register the component in
  43197. */
  43198. constructor(scene: Scene);
  43199. /**
  43200. * Registers the component in a given scene
  43201. */
  43202. register(): void;
  43203. /**
  43204. * Return the list of active meshes
  43205. * @returns the list of active meshes
  43206. */
  43207. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43208. /**
  43209. * Return the list of active sub meshes
  43210. * @param mesh The mesh to get the candidates sub meshes from
  43211. * @returns the list of active sub meshes
  43212. */
  43213. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43214. private _tempRay;
  43215. /**
  43216. * Return the list of sub meshes intersecting with a given local ray
  43217. * @param mesh defines the mesh to find the submesh for
  43218. * @param localRay defines the ray in local space
  43219. * @returns the list of intersecting sub meshes
  43220. */
  43221. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43222. /**
  43223. * Return the list of sub meshes colliding with a collider
  43224. * @param mesh defines the mesh to find the submesh for
  43225. * @param collider defines the collider to evaluate the collision against
  43226. * @returns the list of colliding sub meshes
  43227. */
  43228. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43229. /**
  43230. * Rebuilds the elements related to this component in case of
  43231. * context lost for instance.
  43232. */
  43233. rebuild(): void;
  43234. /**
  43235. * Disposes the component and the associated ressources.
  43236. */
  43237. dispose(): void;
  43238. }
  43239. }
  43240. declare module BABYLON {
  43241. /** @hidden */
  43242. class _OcclusionDataStorage {
  43243. /** @hidden */
  43244. occlusionInternalRetryCounter: number;
  43245. /** @hidden */
  43246. isOcclusionQueryInProgress: boolean;
  43247. /** @hidden */
  43248. isOccluded: boolean;
  43249. /** @hidden */
  43250. occlusionRetryCount: number;
  43251. /** @hidden */
  43252. occlusionType: number;
  43253. /** @hidden */
  43254. occlusionQueryAlgorithmType: number;
  43255. }
  43256. interface Engine {
  43257. /**
  43258. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43259. * @return the new query
  43260. */
  43261. createQuery(): WebGLQuery;
  43262. /**
  43263. * Delete and release a webGL query
  43264. * @param query defines the query to delete
  43265. * @return the current engine
  43266. */
  43267. deleteQuery(query: WebGLQuery): Engine;
  43268. /**
  43269. * Check if a given query has resolved and got its value
  43270. * @param query defines the query to check
  43271. * @returns true if the query got its value
  43272. */
  43273. isQueryResultAvailable(query: WebGLQuery): boolean;
  43274. /**
  43275. * Gets the value of a given query
  43276. * @param query defines the query to check
  43277. * @returns the value of the query
  43278. */
  43279. getQueryResult(query: WebGLQuery): number;
  43280. /**
  43281. * Initiates an occlusion query
  43282. * @param algorithmType defines the algorithm to use
  43283. * @param query defines the query to use
  43284. * @returns the current engine
  43285. * @see http://doc.babylonjs.com/features/occlusionquery
  43286. */
  43287. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43288. /**
  43289. * Ends an occlusion query
  43290. * @see http://doc.babylonjs.com/features/occlusionquery
  43291. * @param algorithmType defines the algorithm to use
  43292. * @returns the current engine
  43293. */
  43294. endOcclusionQuery(algorithmType: number): Engine;
  43295. /**
  43296. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43297. * Please note that only one query can be issued at a time
  43298. * @returns a time token used to track the time span
  43299. */
  43300. startTimeQuery(): Nullable<_TimeToken>;
  43301. /**
  43302. * Ends a time query
  43303. * @param token defines the token used to measure the time span
  43304. * @returns the time spent (in ns)
  43305. */
  43306. endTimeQuery(token: _TimeToken): int;
  43307. /** @hidden */
  43308. _currentNonTimestampToken: Nullable<_TimeToken>;
  43309. /** @hidden */
  43310. _createTimeQuery(): WebGLQuery;
  43311. /** @hidden */
  43312. _deleteTimeQuery(query: WebGLQuery): void;
  43313. /** @hidden */
  43314. _getGlAlgorithmType(algorithmType: number): number;
  43315. /** @hidden */
  43316. _getTimeQueryResult(query: WebGLQuery): any;
  43317. /** @hidden */
  43318. _getTimeQueryAvailability(query: WebGLQuery): any;
  43319. }
  43320. interface AbstractMesh {
  43321. /**
  43322. * Backing filed
  43323. * @hidden
  43324. */
  43325. __occlusionDataStorage: _OcclusionDataStorage;
  43326. /**
  43327. * Access property
  43328. * @hidden
  43329. */
  43330. _occlusionDataStorage: _OcclusionDataStorage;
  43331. /**
  43332. * 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.
  43333. * The default value is -1 which means don't break the query and wait till the result
  43334. * @see http://doc.babylonjs.com/features/occlusionquery
  43335. */
  43336. occlusionRetryCount: number;
  43337. /**
  43338. * 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:
  43339. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43340. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43341. * * 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.
  43342. * @see http://doc.babylonjs.com/features/occlusionquery
  43343. */
  43344. occlusionType: number;
  43345. /**
  43346. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43347. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43348. * * 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.
  43349. * @see http://doc.babylonjs.com/features/occlusionquery
  43350. */
  43351. occlusionQueryAlgorithmType: number;
  43352. /**
  43353. * 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
  43354. * @see http://doc.babylonjs.com/features/occlusionquery
  43355. */
  43356. isOccluded: boolean;
  43357. /**
  43358. * Flag to check the progress status of the query
  43359. * @see http://doc.babylonjs.com/features/occlusionquery
  43360. */
  43361. isOcclusionQueryInProgress: boolean;
  43362. }
  43363. }
  43364. declare module BABYLON {
  43365. interface Engine {
  43366. /**
  43367. * Creates a webGL transform feedback object
  43368. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43369. * @returns the webGL transform feedback object
  43370. */
  43371. createTransformFeedback(): WebGLTransformFeedback;
  43372. /**
  43373. * Delete a webGL transform feedback object
  43374. * @param value defines the webGL transform feedback object to delete
  43375. */
  43376. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43377. /**
  43378. * Bind a webGL transform feedback object to the webgl context
  43379. * @param value defines the webGL transform feedback object to bind
  43380. */
  43381. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43382. /**
  43383. * Begins a transform feedback operation
  43384. * @param usePoints defines if points or triangles must be used
  43385. */
  43386. beginTransformFeedback(usePoints: boolean): void;
  43387. /**
  43388. * Ends a transform feedback operation
  43389. */
  43390. endTransformFeedback(): void;
  43391. /**
  43392. * Specify the varyings to use with transform feedback
  43393. * @param program defines the associated webGL program
  43394. * @param value defines the list of strings representing the varying names
  43395. */
  43396. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43397. /**
  43398. * Bind a webGL buffer for a transform feedback operation
  43399. * @param value defines the webGL buffer to bind
  43400. */
  43401. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43402. }
  43403. }
  43404. declare module BABYLON {
  43405. /**
  43406. * Google Daydream controller
  43407. */
  43408. class DaydreamController extends WebVRController {
  43409. /**
  43410. * Base Url for the controller model.
  43411. */
  43412. static MODEL_BASE_URL: string;
  43413. /**
  43414. * File name for the controller model.
  43415. */
  43416. static MODEL_FILENAME: string;
  43417. /**
  43418. * Gamepad Id prefix used to identify Daydream Controller.
  43419. */
  43420. static readonly GAMEPAD_ID_PREFIX: string;
  43421. /**
  43422. * Creates a new DaydreamController from a gamepad
  43423. * @param vrGamepad the gamepad that the controller should be created from
  43424. */
  43425. constructor(vrGamepad: any);
  43426. /**
  43427. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43428. * @param scene scene in which to add meshes
  43429. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43430. */
  43431. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43432. /**
  43433. * Called once for each button that changed state since the last frame
  43434. * @param buttonIdx Which button index changed
  43435. * @param state New state of the button
  43436. * @param changes Which properties on the state changed since last frame
  43437. */
  43438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43439. }
  43440. }
  43441. declare module BABYLON {
  43442. /**
  43443. * Gear VR Controller
  43444. */
  43445. class GearVRController extends WebVRController {
  43446. /**
  43447. * Base Url for the controller model.
  43448. */
  43449. static MODEL_BASE_URL: string;
  43450. /**
  43451. * File name for the controller model.
  43452. */
  43453. static MODEL_FILENAME: string;
  43454. /**
  43455. * Gamepad Id prefix used to identify this controller.
  43456. */
  43457. static readonly GAMEPAD_ID_PREFIX: string;
  43458. private readonly _buttonIndexToObservableNameMap;
  43459. /**
  43460. * Creates a new GearVRController from a gamepad
  43461. * @param vrGamepad the gamepad that the controller should be created from
  43462. */
  43463. constructor(vrGamepad: any);
  43464. /**
  43465. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43466. * @param scene scene in which to add meshes
  43467. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43468. */
  43469. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43470. /**
  43471. * Called once for each button that changed state since the last frame
  43472. * @param buttonIdx Which button index changed
  43473. * @param state New state of the button
  43474. * @param changes Which properties on the state changed since last frame
  43475. */
  43476. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43477. }
  43478. }
  43479. declare module BABYLON {
  43480. /**
  43481. * Generic Controller
  43482. */
  43483. class GenericController extends WebVRController {
  43484. /**
  43485. * Base Url for the controller model.
  43486. */
  43487. static readonly MODEL_BASE_URL: string;
  43488. /**
  43489. * File name for the controller model.
  43490. */
  43491. static readonly MODEL_FILENAME: string;
  43492. /**
  43493. * Creates a new GenericController from a gamepad
  43494. * @param vrGamepad the gamepad that the controller should be created from
  43495. */
  43496. constructor(vrGamepad: any);
  43497. /**
  43498. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43499. * @param scene scene in which to add meshes
  43500. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43501. */
  43502. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43503. /**
  43504. * Called once for each button that changed state since the last frame
  43505. * @param buttonIdx Which button index changed
  43506. * @param state New state of the button
  43507. * @param changes Which properties on the state changed since last frame
  43508. */
  43509. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43510. }
  43511. }
  43512. declare module BABYLON {
  43513. /**
  43514. * Oculus Touch Controller
  43515. */
  43516. class OculusTouchController extends WebVRController {
  43517. /**
  43518. * Base Url for the controller model.
  43519. */
  43520. static MODEL_BASE_URL: string;
  43521. /**
  43522. * File name for the left controller model.
  43523. */
  43524. static MODEL_LEFT_FILENAME: string;
  43525. /**
  43526. * File name for the right controller model.
  43527. */
  43528. static MODEL_RIGHT_FILENAME: string;
  43529. /**
  43530. * Fired when the secondary trigger on this controller is modified
  43531. */
  43532. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43533. /**
  43534. * Fired when the thumb rest on this controller is modified
  43535. */
  43536. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43537. /**
  43538. * Creates a new OculusTouchController from a gamepad
  43539. * @param vrGamepad the gamepad that the controller should be created from
  43540. */
  43541. constructor(vrGamepad: any);
  43542. /**
  43543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43544. * @param scene scene in which to add meshes
  43545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43546. */
  43547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43548. /**
  43549. * Fired when the A button on this controller is modified
  43550. */
  43551. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43552. /**
  43553. * Fired when the B button on this controller is modified
  43554. */
  43555. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43556. /**
  43557. * Fired when the X button on this controller is modified
  43558. */
  43559. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43560. /**
  43561. * Fired when the Y button on this controller is modified
  43562. */
  43563. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43564. /**
  43565. * Called once for each button that changed state since the last frame
  43566. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43567. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43568. * 2) secondary trigger (same)
  43569. * 3) A (right) X (left), touch, pressed = value
  43570. * 4) B / Y
  43571. * 5) thumb rest
  43572. * @param buttonIdx Which button index changed
  43573. * @param state New state of the button
  43574. * @param changes Which properties on the state changed since last frame
  43575. */
  43576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43577. }
  43578. }
  43579. declare module BABYLON {
  43580. /**
  43581. * Defines the types of pose enabled controllers that are supported
  43582. */
  43583. enum PoseEnabledControllerType {
  43584. /**
  43585. * HTC Vive
  43586. */
  43587. VIVE = 0,
  43588. /**
  43589. * Oculus Rift
  43590. */
  43591. OCULUS = 1,
  43592. /**
  43593. * Windows mixed reality
  43594. */
  43595. WINDOWS = 2,
  43596. /**
  43597. * Samsung gear VR
  43598. */
  43599. GEAR_VR = 3,
  43600. /**
  43601. * Google Daydream
  43602. */
  43603. DAYDREAM = 4,
  43604. /**
  43605. * Generic
  43606. */
  43607. GENERIC = 5
  43608. }
  43609. /**
  43610. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43611. */
  43612. interface MutableGamepadButton {
  43613. /**
  43614. * Value of the button/trigger
  43615. */
  43616. value: number;
  43617. /**
  43618. * If the button/trigger is currently touched
  43619. */
  43620. touched: boolean;
  43621. /**
  43622. * If the button/trigger is currently pressed
  43623. */
  43624. pressed: boolean;
  43625. }
  43626. /**
  43627. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43628. * @hidden
  43629. */
  43630. interface ExtendedGamepadButton extends GamepadButton {
  43631. /**
  43632. * If the button/trigger is currently pressed
  43633. */
  43634. readonly pressed: boolean;
  43635. /**
  43636. * If the button/trigger is currently touched
  43637. */
  43638. readonly touched: boolean;
  43639. /**
  43640. * Value of the button/trigger
  43641. */
  43642. readonly value: number;
  43643. }
  43644. /**
  43645. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43646. */
  43647. class PoseEnabledControllerHelper {
  43648. /**
  43649. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43650. * @param vrGamepad the gamepad to initialized
  43651. * @returns a vr controller of the type the gamepad identified as
  43652. */
  43653. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43654. }
  43655. /**
  43656. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43657. */
  43658. class PoseEnabledController extends Gamepad implements PoseControlled {
  43659. private _deviceRoomPosition;
  43660. private _deviceRoomRotationQuaternion;
  43661. /**
  43662. * The device position in babylon space
  43663. */
  43664. devicePosition: Vector3;
  43665. /**
  43666. * The device rotation in babylon space
  43667. */
  43668. deviceRotationQuaternion: Quaternion;
  43669. /**
  43670. * The scale factor of the device in babylon space
  43671. */
  43672. deviceScaleFactor: number;
  43673. /**
  43674. * (Likely devicePosition should be used instead) The device position in its room space
  43675. */
  43676. position: Vector3;
  43677. /**
  43678. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43679. */
  43680. rotationQuaternion: Quaternion;
  43681. /**
  43682. * The type of controller (Eg. Windows mixed reality)
  43683. */
  43684. controllerType: PoseEnabledControllerType;
  43685. protected _calculatedPosition: Vector3;
  43686. private _calculatedRotation;
  43687. /**
  43688. * The raw pose from the device
  43689. */
  43690. rawPose: DevicePose;
  43691. private _trackPosition;
  43692. private _maxRotationDistFromHeadset;
  43693. private _draggedRoomRotation;
  43694. /**
  43695. * @hidden
  43696. */
  43697. _disableTrackPosition(fixedPosition: Vector3): void;
  43698. /**
  43699. * Internal, the mesh attached to the controller
  43700. * @hidden
  43701. */
  43702. _mesh: Nullable<AbstractMesh>;
  43703. private _poseControlledCamera;
  43704. private _leftHandSystemQuaternion;
  43705. /**
  43706. * Internal, matrix used to convert room space to babylon space
  43707. * @hidden
  43708. */
  43709. _deviceToWorld: Matrix;
  43710. /**
  43711. * Node to be used when casting a ray from the controller
  43712. * @hidden
  43713. */
  43714. _pointingPoseNode: Nullable<TransformNode>;
  43715. /**
  43716. * Name of the child mesh that can be used to cast a ray from the controller
  43717. */
  43718. static readonly POINTING_POSE: string;
  43719. /**
  43720. * Creates a new PoseEnabledController from a gamepad
  43721. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43722. */
  43723. constructor(browserGamepad: any);
  43724. private _workingMatrix;
  43725. /**
  43726. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43727. */
  43728. update(): void;
  43729. /**
  43730. * Updates only the pose device and mesh without doing any button event checking
  43731. */
  43732. protected _updatePoseAndMesh(): void;
  43733. /**
  43734. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43735. * @param poseData raw pose fromthe device
  43736. */
  43737. updateFromDevice(poseData: DevicePose): void;
  43738. /**
  43739. * @hidden
  43740. */
  43741. _meshAttachedObservable: Observable<AbstractMesh>;
  43742. /**
  43743. * Attaches a mesh to the controller
  43744. * @param mesh the mesh to be attached
  43745. */
  43746. attachToMesh(mesh: AbstractMesh): void;
  43747. /**
  43748. * Attaches the controllers mesh to a camera
  43749. * @param camera the camera the mesh should be attached to
  43750. */
  43751. attachToPoseControlledCamera(camera: TargetCamera): void;
  43752. /**
  43753. * Disposes of the controller
  43754. */
  43755. dispose(): void;
  43756. /**
  43757. * The mesh that is attached to the controller
  43758. */
  43759. readonly mesh: Nullable<AbstractMesh>;
  43760. /**
  43761. * Gets the ray of the controller in the direction the controller is pointing
  43762. * @param length the length the resulting ray should be
  43763. * @returns a ray in the direction the controller is pointing
  43764. */
  43765. getForwardRay(length?: number): Ray;
  43766. }
  43767. }
  43768. declare module BABYLON {
  43769. /**
  43770. * Vive Controller
  43771. */
  43772. class ViveController extends WebVRController {
  43773. /**
  43774. * Base Url for the controller model.
  43775. */
  43776. static MODEL_BASE_URL: string;
  43777. /**
  43778. * File name for the controller model.
  43779. */
  43780. static MODEL_FILENAME: string;
  43781. /**
  43782. * Creates a new ViveController from a gamepad
  43783. * @param vrGamepad the gamepad that the controller should be created from
  43784. */
  43785. constructor(vrGamepad: any);
  43786. /**
  43787. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43788. * @param scene scene in which to add meshes
  43789. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43790. */
  43791. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43792. /**
  43793. * Fired when the left button on this controller is modified
  43794. */
  43795. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43796. /**
  43797. * Fired when the right button on this controller is modified
  43798. */
  43799. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43800. /**
  43801. * Fired when the menu button on this controller is modified
  43802. */
  43803. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43804. /**
  43805. * Called once for each button that changed state since the last frame
  43806. * Vive mapping:
  43807. * 0: touchpad
  43808. * 1: trigger
  43809. * 2: left AND right buttons
  43810. * 3: menu button
  43811. * @param buttonIdx Which button index changed
  43812. * @param state New state of the button
  43813. * @param changes Which properties on the state changed since last frame
  43814. */
  43815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43816. }
  43817. }
  43818. declare module BABYLON {
  43819. /**
  43820. * Defines the WebVRController object that represents controllers tracked in 3D space
  43821. */
  43822. abstract class WebVRController extends PoseEnabledController {
  43823. /**
  43824. * Internal, the default controller model for the controller
  43825. */
  43826. protected _defaultModel: AbstractMesh;
  43827. /**
  43828. * Fired when the trigger state has changed
  43829. */
  43830. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43831. /**
  43832. * Fired when the main button state has changed
  43833. */
  43834. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43835. /**
  43836. * Fired when the secondary button state has changed
  43837. */
  43838. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43839. /**
  43840. * Fired when the pad state has changed
  43841. */
  43842. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43843. /**
  43844. * Fired when controllers stick values have changed
  43845. */
  43846. onPadValuesChangedObservable: Observable<StickValues>;
  43847. /**
  43848. * Array of button availible on the controller
  43849. */
  43850. protected _buttons: Array<MutableGamepadButton>;
  43851. private _onButtonStateChange;
  43852. /**
  43853. * Fired when a controller button's state has changed
  43854. * @param callback the callback containing the button that was modified
  43855. */
  43856. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43857. /**
  43858. * X and Y axis corrisponding to the controllers joystick
  43859. */
  43860. pad: StickValues;
  43861. /**
  43862. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43863. */
  43864. hand: string;
  43865. /**
  43866. * The default controller model for the controller
  43867. */
  43868. readonly defaultModel: AbstractMesh;
  43869. /**
  43870. * Creates a new WebVRController from a gamepad
  43871. * @param vrGamepad the gamepad that the WebVRController should be created from
  43872. */
  43873. constructor(vrGamepad: any);
  43874. /**
  43875. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43876. */
  43877. update(): void;
  43878. /**
  43879. * Function to be called when a button is modified
  43880. */
  43881. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43882. /**
  43883. * Loads a mesh and attaches it to the controller
  43884. * @param scene the scene the mesh should be added to
  43885. * @param meshLoaded callback for when the mesh has been loaded
  43886. */
  43887. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43888. private _setButtonValue;
  43889. private _changes;
  43890. private _checkChanges;
  43891. /**
  43892. * Disposes of th webVRCOntroller
  43893. */
  43894. dispose(): void;
  43895. }
  43896. }
  43897. declare module BABYLON {
  43898. /**
  43899. * Defines the WindowsMotionController object that the state of the windows motion controller
  43900. */
  43901. class WindowsMotionController extends WebVRController {
  43902. /**
  43903. * The base url used to load the left and right controller models
  43904. */
  43905. static MODEL_BASE_URL: string;
  43906. /**
  43907. * The name of the left controller model file
  43908. */
  43909. static MODEL_LEFT_FILENAME: string;
  43910. /**
  43911. * The name of the right controller model file
  43912. */
  43913. static MODEL_RIGHT_FILENAME: string;
  43914. /**
  43915. * The controller name prefix for this controller type
  43916. */
  43917. static readonly GAMEPAD_ID_PREFIX: string;
  43918. /**
  43919. * The controller id pattern for this controller type
  43920. */
  43921. private static readonly GAMEPAD_ID_PATTERN;
  43922. private _loadedMeshInfo;
  43923. private readonly _mapping;
  43924. /**
  43925. * Fired when the trackpad on this controller is clicked
  43926. */
  43927. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43928. /**
  43929. * Fired when the trackpad on this controller is modified
  43930. */
  43931. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43932. /**
  43933. * The current x and y values of this controller's trackpad
  43934. */
  43935. trackpad: StickValues;
  43936. /**
  43937. * Creates a new WindowsMotionController from a gamepad
  43938. * @param vrGamepad the gamepad that the controller should be created from
  43939. */
  43940. constructor(vrGamepad: any);
  43941. /**
  43942. * Fired when the trigger on this controller is modified
  43943. */
  43944. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43945. /**
  43946. * Fired when the menu button on this controller is modified
  43947. */
  43948. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43949. /**
  43950. * Fired when the grip button on this controller is modified
  43951. */
  43952. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43953. /**
  43954. * Fired when the thumbstick button on this controller is modified
  43955. */
  43956. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43957. /**
  43958. * Fired when the touchpad button on this controller is modified
  43959. */
  43960. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43961. /**
  43962. * Fired when the touchpad values on this controller are modified
  43963. */
  43964. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43965. private _updateTrackpad;
  43966. /**
  43967. * Called once per frame by the engine.
  43968. */
  43969. update(): void;
  43970. /**
  43971. * Called once for each button that changed state since the last frame
  43972. * @param buttonIdx Which button index changed
  43973. * @param state New state of the button
  43974. * @param changes Which properties on the state changed since last frame
  43975. */
  43976. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43977. /**
  43978. * Moves the buttons on the controller mesh based on their current state
  43979. * @param buttonName the name of the button to move
  43980. * @param buttonValue the value of the button which determines the buttons new position
  43981. */
  43982. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43983. /**
  43984. * Moves the axis on the controller mesh based on its current state
  43985. * @param axis the index of the axis
  43986. * @param axisValue the value of the axis which determines the meshes new position
  43987. * @hidden
  43988. */
  43989. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43990. /**
  43991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43992. * @param scene scene in which to add meshes
  43993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43994. */
  43995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43996. /**
  43997. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43998. * can be transformed by button presses and axes values, based on this._mapping.
  43999. *
  44000. * @param scene scene in which the meshes exist
  44001. * @param meshes list of meshes that make up the controller model to process
  44002. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44003. */
  44004. private processModel;
  44005. private createMeshInfo;
  44006. /**
  44007. * Gets the ray of the controller in the direction the controller is pointing
  44008. * @param length the length the resulting ray should be
  44009. * @returns a ray in the direction the controller is pointing
  44010. */
  44011. getForwardRay(length?: number): Ray;
  44012. /**
  44013. * Disposes of the controller
  44014. */
  44015. dispose(): void;
  44016. }
  44017. }
  44018. declare module BABYLON {
  44019. /**
  44020. * Interface to implement to create a shadow generator compatible with BJS.
  44021. */
  44022. interface IShadowGenerator {
  44023. /**
  44024. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44025. * @returns The render target texture if present otherwise, null
  44026. */
  44027. getShadowMap(): Nullable<RenderTargetTexture>;
  44028. /**
  44029. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44030. * @returns The render target texture if the shadow map is present otherwise, null
  44031. */
  44032. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44033. /**
  44034. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44035. * @param subMesh The submesh we want to render in the shadow map
  44036. * @param useInstances Defines wether will draw in the map using instances
  44037. * @returns true if ready otherwise, false
  44038. */
  44039. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44040. /**
  44041. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44042. * @param defines Defines of the material we want to update
  44043. * @param lightIndex Index of the light in the enabled light list of the material
  44044. */
  44045. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44046. /**
  44047. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44048. * defined in the generator but impacting the effect).
  44049. * It implies the unifroms available on the materials are the standard BJS ones.
  44050. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44051. * @param effect The effect we are binfing the information for
  44052. */
  44053. bindShadowLight(lightIndex: string, effect: Effect): void;
  44054. /**
  44055. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44056. * (eq to shadow prjection matrix * light transform matrix)
  44057. * @returns The transform matrix used to create the shadow map
  44058. */
  44059. getTransformMatrix(): Matrix;
  44060. /**
  44061. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44062. * Cube and 2D textures for instance.
  44063. */
  44064. recreateShadowMap(): void;
  44065. /**
  44066. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44067. * @param onCompiled Callback triggered at the and of the effects compilation
  44068. * @param options Sets of optional options forcing the compilation with different modes
  44069. */
  44070. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44071. useInstances: boolean;
  44072. }>): void;
  44073. /**
  44074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44075. * @param options Sets of optional options forcing the compilation with different modes
  44076. * @returns A promise that resolves when the compilation completes
  44077. */
  44078. forceCompilationAsync(options?: Partial<{
  44079. useInstances: boolean;
  44080. }>): Promise<void>;
  44081. /**
  44082. * Serializes the shadow generator setup to a json object.
  44083. * @returns The serialized JSON object
  44084. */
  44085. serialize(): any;
  44086. /**
  44087. * Disposes the Shadow map and related Textures and effects.
  44088. */
  44089. dispose(): void;
  44090. }
  44091. /**
  44092. * Default implementation IShadowGenerator.
  44093. * This is the main object responsible of generating shadows in the framework.
  44094. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44095. */
  44096. class ShadowGenerator implements IShadowGenerator {
  44097. /**
  44098. * Shadow generator mode None: no filtering applied.
  44099. */
  44100. static readonly FILTER_NONE: number;
  44101. /**
  44102. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44103. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44104. */
  44105. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44106. /**
  44107. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44108. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44109. */
  44110. static readonly FILTER_POISSONSAMPLING: number;
  44111. /**
  44112. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44113. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44114. */
  44115. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44116. /**
  44117. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44118. * edge artifacts on steep falloff.
  44119. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44120. */
  44121. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44122. /**
  44123. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44124. * edge artifacts on steep falloff.
  44125. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44126. */
  44127. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44128. /**
  44129. * Shadow generator mode PCF: Percentage Closer Filtering
  44130. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44131. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44132. */
  44133. static readonly FILTER_PCF: number;
  44134. /**
  44135. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44136. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44137. * Contact Hardening
  44138. */
  44139. static readonly FILTER_PCSS: number;
  44140. /**
  44141. * Reserved for PCF and PCSS
  44142. * Highest Quality.
  44143. *
  44144. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44145. *
  44146. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44147. */
  44148. static readonly QUALITY_HIGH: number;
  44149. /**
  44150. * Reserved for PCF and PCSS
  44151. * Good tradeoff for quality/perf cross devices
  44152. *
  44153. * Execute PCF on a 3*3 kernel.
  44154. *
  44155. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44156. */
  44157. static readonly QUALITY_MEDIUM: number;
  44158. /**
  44159. * Reserved for PCF and PCSS
  44160. * The lowest quality but the fastest.
  44161. *
  44162. * Execute PCF on a 1*1 kernel.
  44163. *
  44164. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44165. */
  44166. static readonly QUALITY_LOW: number;
  44167. private _bias;
  44168. /**
  44169. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44170. */
  44171. /**
  44172. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44173. */
  44174. bias: number;
  44175. private _normalBias;
  44176. /**
  44177. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44178. */
  44179. /**
  44180. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44181. */
  44182. normalBias: number;
  44183. private _blurBoxOffset;
  44184. /**
  44185. * Gets the blur box offset: offset applied during the blur pass.
  44186. * Only usefull if useKernelBlur = false
  44187. */
  44188. /**
  44189. * Sets the blur box offset: offset applied during the blur pass.
  44190. * Only usefull if useKernelBlur = false
  44191. */
  44192. blurBoxOffset: number;
  44193. private _blurScale;
  44194. /**
  44195. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44196. * 2 means half of the size.
  44197. */
  44198. /**
  44199. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44200. * 2 means half of the size.
  44201. */
  44202. blurScale: number;
  44203. private _blurKernel;
  44204. /**
  44205. * Gets the blur kernel: kernel size of the blur pass.
  44206. * Only usefull if useKernelBlur = true
  44207. */
  44208. /**
  44209. * Sets the blur kernel: kernel size of the blur pass.
  44210. * Only usefull if useKernelBlur = true
  44211. */
  44212. blurKernel: number;
  44213. private _useKernelBlur;
  44214. /**
  44215. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44216. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44217. */
  44218. /**
  44219. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44220. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44221. */
  44222. useKernelBlur: boolean;
  44223. private _depthScale;
  44224. /**
  44225. * Gets the depth scale used in ESM mode.
  44226. */
  44227. /**
  44228. * Sets the depth scale used in ESM mode.
  44229. * This can override the scale stored on the light.
  44230. */
  44231. depthScale: number;
  44232. private _filter;
  44233. /**
  44234. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44235. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44236. */
  44237. /**
  44238. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44239. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44240. */
  44241. filter: number;
  44242. /**
  44243. * Gets if the current filter is set to Poisson Sampling.
  44244. */
  44245. /**
  44246. * Sets the current filter to Poisson Sampling.
  44247. */
  44248. usePoissonSampling: boolean;
  44249. /**
  44250. * Gets if the current filter is set to ESM.
  44251. */
  44252. /**
  44253. * Sets the current filter is to ESM.
  44254. */
  44255. useExponentialShadowMap: boolean;
  44256. /**
  44257. * Gets if the current filter is set to filtered ESM.
  44258. */
  44259. /**
  44260. * Gets if the current filter is set to filtered ESM.
  44261. */
  44262. useBlurExponentialShadowMap: boolean;
  44263. /**
  44264. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44265. * exponential to prevent steep falloff artifacts).
  44266. */
  44267. /**
  44268. * Sets the current filter to "close ESM" (using the inverse of the
  44269. * exponential to prevent steep falloff artifacts).
  44270. */
  44271. useCloseExponentialShadowMap: boolean;
  44272. /**
  44273. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44274. * exponential to prevent steep falloff artifacts).
  44275. */
  44276. /**
  44277. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44278. * exponential to prevent steep falloff artifacts).
  44279. */
  44280. useBlurCloseExponentialShadowMap: boolean;
  44281. /**
  44282. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44283. */
  44284. /**
  44285. * Sets the current filter to "PCF" (percentage closer filtering).
  44286. */
  44287. usePercentageCloserFiltering: boolean;
  44288. private _filteringQuality;
  44289. /**
  44290. * Gets the PCF or PCSS Quality.
  44291. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44292. */
  44293. /**
  44294. * Sets the PCF or PCSS Quality.
  44295. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44296. */
  44297. filteringQuality: number;
  44298. /**
  44299. * Gets if the current filter is set to "PCSS" (contact hardening).
  44300. */
  44301. /**
  44302. * Sets the current filter to "PCSS" (contact hardening).
  44303. */
  44304. useContactHardeningShadow: boolean;
  44305. private _contactHardeningLightSizeUVRatio;
  44306. /**
  44307. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44308. * Using a ratio helps keeping shape stability independently of the map size.
  44309. *
  44310. * It does not account for the light projection as it was having too much
  44311. * instability during the light setup or during light position changes.
  44312. *
  44313. * Only valid if useContactHardeningShadow is true.
  44314. */
  44315. /**
  44316. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44317. * Using a ratio helps keeping shape stability independently of the map size.
  44318. *
  44319. * It does not account for the light projection as it was having too much
  44320. * instability during the light setup or during light position changes.
  44321. *
  44322. * Only valid if useContactHardeningShadow is true.
  44323. */
  44324. contactHardeningLightSizeUVRatio: number;
  44325. private _darkness;
  44326. /**
  44327. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44328. * 0 means strongest and 1 would means no shadow.
  44329. * @returns the darkness.
  44330. */
  44331. getDarkness(): number;
  44332. /**
  44333. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44334. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44335. * @returns the shadow generator allowing fluent coding.
  44336. */
  44337. setDarkness(darkness: number): ShadowGenerator;
  44338. private _transparencyShadow;
  44339. /**
  44340. * Sets the ability to have transparent shadow (boolean).
  44341. * @param transparent True if transparent else False
  44342. * @returns the shadow generator allowing fluent coding
  44343. */
  44344. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44345. private _shadowMap;
  44346. private _shadowMap2;
  44347. /**
  44348. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44349. * @returns The render target texture if present otherwise, null
  44350. */
  44351. getShadowMap(): Nullable<RenderTargetTexture>;
  44352. /**
  44353. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44354. * @returns The render target texture if the shadow map is present otherwise, null
  44355. */
  44356. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44357. /**
  44358. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44359. * @param mesh Mesh to add
  44360. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44361. * @returns the Shadow Generator itself
  44362. */
  44363. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44364. /**
  44365. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44366. * @param mesh Mesh to remove
  44367. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44368. * @returns the Shadow Generator itself
  44369. */
  44370. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44371. /**
  44372. * Controls the extent to which the shadows fade out at the edge of the frustum
  44373. * Used only by directionals and spots
  44374. */
  44375. frustumEdgeFalloff: number;
  44376. private _light;
  44377. /**
  44378. * Returns the associated light object.
  44379. * @returns the light generating the shadow
  44380. */
  44381. getLight(): IShadowLight;
  44382. /**
  44383. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44384. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44385. * It might on the other hand introduce peter panning.
  44386. */
  44387. forceBackFacesOnly: boolean;
  44388. private _scene;
  44389. private _lightDirection;
  44390. private _effect;
  44391. private _viewMatrix;
  44392. private _projectionMatrix;
  44393. private _transformMatrix;
  44394. private _cachedPosition;
  44395. private _cachedDirection;
  44396. private _cachedDefines;
  44397. private _currentRenderID;
  44398. private _boxBlurPostprocess;
  44399. private _kernelBlurXPostprocess;
  44400. private _kernelBlurYPostprocess;
  44401. private _blurPostProcesses;
  44402. private _mapSize;
  44403. private _currentFaceIndex;
  44404. private _currentFaceIndexCache;
  44405. private _textureType;
  44406. private _defaultTextureMatrix;
  44407. /**
  44408. * Creates a ShadowGenerator object.
  44409. * A ShadowGenerator is the required tool to use the shadows.
  44410. * Each light casting shadows needs to use its own ShadowGenerator.
  44411. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  44412. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44413. * @param light The light object generating the shadows.
  44414. * @param useFullFloatFirst 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.
  44415. */
  44416. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44417. private _initializeGenerator;
  44418. private _initializeShadowMap;
  44419. private _initializeBlurRTTAndPostProcesses;
  44420. private _renderForShadowMap;
  44421. private _renderSubMeshForShadowMap;
  44422. private _applyFilterValues;
  44423. /**
  44424. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44425. * @param onCompiled Callback triggered at the and of the effects compilation
  44426. * @param options Sets of optional options forcing the compilation with different modes
  44427. */
  44428. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44429. useInstances: boolean;
  44430. }>): void;
  44431. /**
  44432. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44433. * @param options Sets of optional options forcing the compilation with different modes
  44434. * @returns A promise that resolves when the compilation completes
  44435. */
  44436. forceCompilationAsync(options?: Partial<{
  44437. useInstances: boolean;
  44438. }>): Promise<void>;
  44439. /**
  44440. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44441. * @param subMesh The submesh we want to render in the shadow map
  44442. * @param useInstances Defines wether will draw in the map using instances
  44443. * @returns true if ready otherwise, false
  44444. */
  44445. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44446. /**
  44447. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44448. * @param defines Defines of the material we want to update
  44449. * @param lightIndex Index of the light in the enabled light list of the material
  44450. */
  44451. prepareDefines(defines: any, lightIndex: number): void;
  44452. /**
  44453. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44454. * defined in the generator but impacting the effect).
  44455. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44456. * @param effect The effect we are binfing the information for
  44457. */
  44458. bindShadowLight(lightIndex: string, effect: Effect): void;
  44459. /**
  44460. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44461. * (eq to shadow prjection matrix * light transform matrix)
  44462. * @returns The transform matrix used to create the shadow map
  44463. */
  44464. getTransformMatrix(): Matrix;
  44465. /**
  44466. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44467. * Cube and 2D textures for instance.
  44468. */
  44469. recreateShadowMap(): void;
  44470. private _disposeBlurPostProcesses;
  44471. private _disposeRTTandPostProcesses;
  44472. /**
  44473. * Disposes the ShadowGenerator.
  44474. * Returns nothing.
  44475. */
  44476. dispose(): void;
  44477. /**
  44478. * Serializes the shadow generator setup to a json object.
  44479. * @returns The serialized JSON object
  44480. */
  44481. serialize(): any;
  44482. /**
  44483. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44484. * @param parsedShadowGenerator The JSON object to parse
  44485. * @param scene The scene to create the shadow map for
  44486. * @returns The parsed shadow generator
  44487. */
  44488. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44489. }
  44490. }
  44491. declare module BABYLON {
  44492. /**
  44493. * Defines the shadow generator component responsible to manage any shadow generators
  44494. * in a given scene.
  44495. */
  44496. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44497. /**
  44498. * The component name helpfull to identify the component in the list of scene components.
  44499. */
  44500. readonly name: string;
  44501. /**
  44502. * The scene the component belongs to.
  44503. */
  44504. scene: Scene;
  44505. /**
  44506. * Creates a new instance of the component for the given scene
  44507. * @param scene Defines the scene to register the component in
  44508. */
  44509. constructor(scene: Scene);
  44510. /**
  44511. * Registers the component in a given scene
  44512. */
  44513. register(): void;
  44514. /**
  44515. * Rebuilds the elements related to this component in case of
  44516. * context lost for instance.
  44517. */
  44518. rebuild(): void;
  44519. /**
  44520. * Serializes the component data to the specified json object
  44521. * @param serializationObject The object to serialize to
  44522. */
  44523. serialize(serializationObject: any): void;
  44524. /**
  44525. * Adds all the element from the container to the scene
  44526. * @param container the container holding the elements
  44527. */
  44528. addFromContainer(container: AbstractScene): void;
  44529. /**
  44530. * Removes all the elements in the container from the scene
  44531. * @param container contains the elements to remove
  44532. */
  44533. removeFromContainer(container: AbstractScene): void;
  44534. /**
  44535. * Rebuilds the elements related to this component in case of
  44536. * context lost for instance.
  44537. */
  44538. dispose(): void;
  44539. private _gatherRenderTargets;
  44540. }
  44541. }
  44542. declare module BABYLON {
  44543. }
  44544. declare module BABYLON {
  44545. /**
  44546. * Background material used to create an efficient environement around your scene.
  44547. */
  44548. class BackgroundMaterial extends PushMaterial {
  44549. /**
  44550. * Standard reflectance value at parallel view angle.
  44551. */
  44552. static StandardReflectance0: number;
  44553. /**
  44554. * Standard reflectance value at grazing angle.
  44555. */
  44556. static StandardReflectance90: number;
  44557. protected _primaryColor: Color3;
  44558. /**
  44559. * Key light Color (multiply against the environement texture)
  44560. */
  44561. primaryColor: Color3;
  44562. protected __perceptualColor: Nullable<Color3>;
  44563. /**
  44564. * Experimental Internal Use Only.
  44565. *
  44566. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44567. * This acts as a helper to set the primary color to a more "human friendly" value.
  44568. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44569. * output color as close as possible from the chosen value.
  44570. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44571. * part of lighting setup.)
  44572. */
  44573. _perceptualColor: Nullable<Color3>;
  44574. protected _primaryColorShadowLevel: float;
  44575. /**
  44576. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44577. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44578. */
  44579. primaryColorShadowLevel: float;
  44580. protected _primaryColorHighlightLevel: float;
  44581. /**
  44582. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44583. * The primary color is used at the level chosen to define what the white area would look.
  44584. */
  44585. primaryColorHighlightLevel: float;
  44586. protected _reflectionTexture: Nullable<BaseTexture>;
  44587. /**
  44588. * Reflection Texture used in the material.
  44589. * Should be author in a specific way for the best result (refer to the documentation).
  44590. */
  44591. reflectionTexture: Nullable<BaseTexture>;
  44592. protected _reflectionBlur: float;
  44593. /**
  44594. * Reflection Texture level of blur.
  44595. *
  44596. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44597. * texture twice.
  44598. */
  44599. reflectionBlur: float;
  44600. protected _diffuseTexture: Nullable<BaseTexture>;
  44601. /**
  44602. * Diffuse Texture used in the material.
  44603. * Should be author in a specific way for the best result (refer to the documentation).
  44604. */
  44605. diffuseTexture: Nullable<BaseTexture>;
  44606. protected _shadowLights: Nullable<IShadowLight[]>;
  44607. /**
  44608. * Specify the list of lights casting shadow on the material.
  44609. * All scene shadow lights will be included if null.
  44610. */
  44611. shadowLights: Nullable<IShadowLight[]>;
  44612. protected _shadowLevel: float;
  44613. /**
  44614. * Helps adjusting the shadow to a softer level if required.
  44615. * 0 means black shadows and 1 means no shadows.
  44616. */
  44617. shadowLevel: float;
  44618. protected _sceneCenter: Vector3;
  44619. /**
  44620. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44621. * It is usually zero but might be interesting to modify according to your setup.
  44622. */
  44623. sceneCenter: Vector3;
  44624. protected _opacityFresnel: boolean;
  44625. /**
  44626. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44627. * This helps ensuring a nice transition when the camera goes under the ground.
  44628. */
  44629. opacityFresnel: boolean;
  44630. protected _reflectionFresnel: boolean;
  44631. /**
  44632. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44633. * This helps adding a mirror texture on the ground.
  44634. */
  44635. reflectionFresnel: boolean;
  44636. protected _reflectionFalloffDistance: number;
  44637. /**
  44638. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44639. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44640. */
  44641. reflectionFalloffDistance: number;
  44642. protected _reflectionAmount: number;
  44643. /**
  44644. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44645. */
  44646. reflectionAmount: number;
  44647. protected _reflectionReflectance0: number;
  44648. /**
  44649. * This specifies the weight of the reflection at grazing angle.
  44650. */
  44651. reflectionReflectance0: number;
  44652. protected _reflectionReflectance90: number;
  44653. /**
  44654. * This specifies the weight of the reflection at a perpendicular point of view.
  44655. */
  44656. reflectionReflectance90: number;
  44657. /**
  44658. * Sets the reflection reflectance fresnel values according to the default standard
  44659. * empirically know to work well :-)
  44660. */
  44661. reflectionStandardFresnelWeight: number;
  44662. protected _useRGBColor: boolean;
  44663. /**
  44664. * Helps to directly use the maps channels instead of their level.
  44665. */
  44666. useRGBColor: boolean;
  44667. protected _enableNoise: boolean;
  44668. /**
  44669. * This helps reducing the banding effect that could occur on the background.
  44670. */
  44671. enableNoise: boolean;
  44672. /**
  44673. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44674. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44675. * Recommended to be keep at 1.0 except for special cases.
  44676. */
  44677. fovMultiplier: number;
  44678. private _fovMultiplier;
  44679. /**
  44680. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44681. */
  44682. useEquirectangularFOV: boolean;
  44683. private _maxSimultaneousLights;
  44684. /**
  44685. * Number of Simultaneous lights allowed on the material.
  44686. */
  44687. maxSimultaneousLights: int;
  44688. /**
  44689. * Default configuration related to image processing available in the Background Material.
  44690. */
  44691. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44692. /**
  44693. * Keep track of the image processing observer to allow dispose and replace.
  44694. */
  44695. private _imageProcessingObserver;
  44696. /**
  44697. * Attaches a new image processing configuration to the PBR Material.
  44698. * @param configuration (if null the scene configuration will be use)
  44699. */
  44700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44701. /**
  44702. * Gets the image processing configuration used either in this material.
  44703. */
  44704. /**
  44705. * Sets the Default image processing configuration used either in the this material.
  44706. *
  44707. * If sets to null, the scene one is in use.
  44708. */
  44709. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44710. /**
  44711. * Gets wether the color curves effect is enabled.
  44712. */
  44713. /**
  44714. * Sets wether the color curves effect is enabled.
  44715. */
  44716. cameraColorCurvesEnabled: boolean;
  44717. /**
  44718. * Gets wether the color grading effect is enabled.
  44719. */
  44720. /**
  44721. * Gets wether the color grading effect is enabled.
  44722. */
  44723. cameraColorGradingEnabled: boolean;
  44724. /**
  44725. * Gets wether tonemapping is enabled or not.
  44726. */
  44727. /**
  44728. * Sets wether tonemapping is enabled or not
  44729. */
  44730. cameraToneMappingEnabled: boolean;
  44731. /**
  44732. * The camera exposure used on this material.
  44733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44734. * This corresponds to a photographic exposure.
  44735. */
  44736. /**
  44737. * The camera exposure used on this material.
  44738. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44739. * This corresponds to a photographic exposure.
  44740. */
  44741. cameraExposure: float;
  44742. /**
  44743. * Gets The camera contrast used on this material.
  44744. */
  44745. /**
  44746. * Sets The camera contrast used on this material.
  44747. */
  44748. cameraContrast: float;
  44749. /**
  44750. * Gets the Color Grading 2D Lookup Texture.
  44751. */
  44752. /**
  44753. * Sets the Color Grading 2D Lookup Texture.
  44754. */
  44755. cameraColorGradingTexture: Nullable<BaseTexture>;
  44756. /**
  44757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44759. * 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;
  44760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44761. */
  44762. /**
  44763. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44764. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44765. * 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;
  44766. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44767. */
  44768. cameraColorCurves: Nullable<ColorCurves>;
  44769. /**
  44770. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44771. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44772. */
  44773. switchToBGR: boolean;
  44774. private _renderTargets;
  44775. private _reflectionControls;
  44776. private _white;
  44777. private _primaryShadowColor;
  44778. private _primaryHighlightColor;
  44779. /**
  44780. * Instantiates a Background Material in the given scene
  44781. * @param name The friendly name of the material
  44782. * @param scene The scene to add the material to
  44783. */
  44784. constructor(name: string, scene: Scene);
  44785. /**
  44786. * Gets a boolean indicating that current material needs to register RTT
  44787. */
  44788. readonly hasRenderTargetTextures: boolean;
  44789. /**
  44790. * The entire material has been created in order to prevent overdraw.
  44791. * @returns false
  44792. */
  44793. needAlphaTesting(): boolean;
  44794. /**
  44795. * The entire material has been created in order to prevent overdraw.
  44796. * @returns true if blending is enable
  44797. */
  44798. needAlphaBlending(): boolean;
  44799. /**
  44800. * Checks wether the material is ready to be rendered for a given mesh.
  44801. * @param mesh The mesh to render
  44802. * @param subMesh The submesh to check against
  44803. * @param useInstances Specify wether or not the material is used with instances
  44804. * @returns true if all the dependencies are ready (Textures, Effects...)
  44805. */
  44806. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44807. /**
  44808. * Compute the primary color according to the chosen perceptual color.
  44809. */
  44810. private _computePrimaryColorFromPerceptualColor;
  44811. /**
  44812. * Compute the highlights and shadow colors according to their chosen levels.
  44813. */
  44814. private _computePrimaryColors;
  44815. /**
  44816. * Build the uniform buffer used in the material.
  44817. */
  44818. buildUniformLayout(): void;
  44819. /**
  44820. * Unbind the material.
  44821. */
  44822. unbind(): void;
  44823. /**
  44824. * Bind only the world matrix to the material.
  44825. * @param world The world matrix to bind.
  44826. */
  44827. bindOnlyWorldMatrix(world: Matrix): void;
  44828. /**
  44829. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44830. * @param world The world matrix to bind.
  44831. * @param subMesh The submesh to bind for.
  44832. */
  44833. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44834. /**
  44835. * Dispose the material.
  44836. * @param forceDisposeEffect Force disposal of the associated effect.
  44837. * @param forceDisposeTextures Force disposal of the associated textures.
  44838. */
  44839. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44840. /**
  44841. * Clones the material.
  44842. * @param name The cloned name.
  44843. * @returns The cloned material.
  44844. */
  44845. clone(name: string): BackgroundMaterial;
  44846. /**
  44847. * Serializes the current material to its JSON representation.
  44848. * @returns The JSON representation.
  44849. */
  44850. serialize(): any;
  44851. /**
  44852. * Gets the class name of the material
  44853. * @returns "BackgroundMaterial"
  44854. */
  44855. getClassName(): string;
  44856. /**
  44857. * Parse a JSON input to create back a background material.
  44858. * @param source The JSON data to parse
  44859. * @param scene The scene to create the parsed material in
  44860. * @param rootUrl The root url of the assets the material depends upon
  44861. * @returns the instantiated BackgroundMaterial.
  44862. */
  44863. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44864. }
  44865. }
  44866. declare module BABYLON {
  44867. /**
  44868. * The Physically based material base class of BJS.
  44869. *
  44870. * This offers the main features of a standard PBR material.
  44871. * For more information, please refer to the documentation :
  44872. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44873. */
  44874. abstract class PBRBaseMaterial extends PushMaterial {
  44875. /**
  44876. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44877. */
  44878. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44879. /**
  44880. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44881. * to enhance interoperability with other engines.
  44882. */
  44883. static readonly LIGHTFALLOFF_GLTF: number;
  44884. /**
  44885. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44886. * to enhance interoperability with other materials.
  44887. */
  44888. static readonly LIGHTFALLOFF_STANDARD: number;
  44889. /**
  44890. * Intensity of the direct lights e.g. the four lights available in your scene.
  44891. * This impacts both the direct diffuse and specular highlights.
  44892. */
  44893. protected _directIntensity: number;
  44894. /**
  44895. * Intensity of the emissive part of the material.
  44896. * This helps controlling the emissive effect without modifying the emissive color.
  44897. */
  44898. protected _emissiveIntensity: number;
  44899. /**
  44900. * Intensity of the environment e.g. how much the environment will light the object
  44901. * either through harmonics for rough material or through the refelction for shiny ones.
  44902. */
  44903. protected _environmentIntensity: number;
  44904. /**
  44905. * This is a special control allowing the reduction of the specular highlights coming from the
  44906. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44907. */
  44908. protected _specularIntensity: number;
  44909. /**
  44910. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44911. */
  44912. private _lightingInfos;
  44913. /**
  44914. * Debug Control allowing disabling the bump map on this material.
  44915. */
  44916. protected _disableBumpMap: boolean;
  44917. /**
  44918. * AKA Diffuse Texture in standard nomenclature.
  44919. */
  44920. protected _albedoTexture: BaseTexture;
  44921. /**
  44922. * AKA Occlusion Texture in other nomenclature.
  44923. */
  44924. protected _ambientTexture: BaseTexture;
  44925. /**
  44926. * AKA Occlusion Texture Intensity in other nomenclature.
  44927. */
  44928. protected _ambientTextureStrength: number;
  44929. /**
  44930. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44931. * 1 means it completely occludes it
  44932. * 0 mean it has no impact
  44933. */
  44934. protected _ambientTextureImpactOnAnalyticalLights: number;
  44935. /**
  44936. * Stores the alpha values in a texture.
  44937. */
  44938. protected _opacityTexture: BaseTexture;
  44939. /**
  44940. * Stores the reflection values in a texture.
  44941. */
  44942. protected _reflectionTexture: BaseTexture;
  44943. /**
  44944. * Stores the refraction values in a texture.
  44945. */
  44946. protected _refractionTexture: BaseTexture;
  44947. /**
  44948. * Stores the emissive values in a texture.
  44949. */
  44950. protected _emissiveTexture: BaseTexture;
  44951. /**
  44952. * AKA Specular texture in other nomenclature.
  44953. */
  44954. protected _reflectivityTexture: BaseTexture;
  44955. /**
  44956. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44957. */
  44958. protected _metallicTexture: BaseTexture;
  44959. /**
  44960. * Specifies the metallic scalar of the metallic/roughness workflow.
  44961. * Can also be used to scale the metalness values of the metallic texture.
  44962. */
  44963. protected _metallic: Nullable<number>;
  44964. /**
  44965. * Specifies the roughness scalar of the metallic/roughness workflow.
  44966. * Can also be used to scale the roughness values of the metallic texture.
  44967. */
  44968. protected _roughness: Nullable<number>;
  44969. /**
  44970. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44971. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44972. */
  44973. protected _microSurfaceTexture: BaseTexture;
  44974. /**
  44975. * Stores surface normal data used to displace a mesh in a texture.
  44976. */
  44977. protected _bumpTexture: BaseTexture;
  44978. /**
  44979. * Stores the pre-calculated light information of a mesh in a texture.
  44980. */
  44981. protected _lightmapTexture: BaseTexture;
  44982. /**
  44983. * The color of a material in ambient lighting.
  44984. */
  44985. protected _ambientColor: Color3;
  44986. /**
  44987. * AKA Diffuse Color in other nomenclature.
  44988. */
  44989. protected _albedoColor: Color3;
  44990. /**
  44991. * AKA Specular Color in other nomenclature.
  44992. */
  44993. protected _reflectivityColor: Color3;
  44994. /**
  44995. * The color applied when light is reflected from a material.
  44996. */
  44997. protected _reflectionColor: Color3;
  44998. /**
  44999. * The color applied when light is emitted from a material.
  45000. */
  45001. protected _emissiveColor: Color3;
  45002. /**
  45003. * AKA Glossiness in other nomenclature.
  45004. */
  45005. protected _microSurface: number;
  45006. /**
  45007. * source material index of refraction (IOR)' / 'destination material IOR.
  45008. */
  45009. protected _indexOfRefraction: number;
  45010. /**
  45011. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45012. */
  45013. protected _invertRefractionY: boolean;
  45014. /**
  45015. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45016. * Materials half opaque for instance using refraction could benefit from this control.
  45017. */
  45018. protected _linkRefractionWithTransparency: boolean;
  45019. /**
  45020. * Specifies that the material will use the light map as a show map.
  45021. */
  45022. protected _useLightmapAsShadowmap: boolean;
  45023. /**
  45024. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45025. * makes the reflect vector face the model (under horizon).
  45026. */
  45027. protected _useHorizonOcclusion: boolean;
  45028. /**
  45029. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45030. * too much the area relying on ambient texture to define their ambient occlusion.
  45031. */
  45032. protected _useRadianceOcclusion: boolean;
  45033. /**
  45034. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45035. */
  45036. protected _useAlphaFromAlbedoTexture: boolean;
  45037. /**
  45038. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45039. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45040. */
  45041. protected _useSpecularOverAlpha: boolean;
  45042. /**
  45043. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45044. */
  45045. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45046. /**
  45047. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45048. */
  45049. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45050. /**
  45051. * Specifies if the metallic texture contains the roughness information in its green channel.
  45052. */
  45053. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45054. /**
  45055. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45056. */
  45057. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45058. /**
  45059. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45060. */
  45061. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45062. /**
  45063. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45064. */
  45065. protected _useAmbientInGrayScale: boolean;
  45066. /**
  45067. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45068. * The material will try to infer what glossiness each pixel should be.
  45069. */
  45070. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45071. /**
  45072. * Defines the falloff type used in this material.
  45073. * It by default is Physical.
  45074. */
  45075. protected _lightFalloff: number;
  45076. /**
  45077. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45078. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45079. */
  45080. protected _useRadianceOverAlpha: boolean;
  45081. /**
  45082. * Allows using an object space normal map (instead of tangent space).
  45083. */
  45084. protected _useObjectSpaceNormalMap: boolean;
  45085. /**
  45086. * Allows using the bump map in parallax mode.
  45087. */
  45088. protected _useParallax: boolean;
  45089. /**
  45090. * Allows using the bump map in parallax occlusion mode.
  45091. */
  45092. protected _useParallaxOcclusion: boolean;
  45093. /**
  45094. * Controls the scale bias of the parallax mode.
  45095. */
  45096. protected _parallaxScaleBias: number;
  45097. /**
  45098. * If sets to true, disables all the lights affecting the material.
  45099. */
  45100. protected _disableLighting: boolean;
  45101. /**
  45102. * Number of Simultaneous lights allowed on the material.
  45103. */
  45104. protected _maxSimultaneousLights: number;
  45105. /**
  45106. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45107. */
  45108. protected _invertNormalMapX: boolean;
  45109. /**
  45110. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45111. */
  45112. protected _invertNormalMapY: boolean;
  45113. /**
  45114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45115. */
  45116. protected _twoSidedLighting: boolean;
  45117. /**
  45118. * Defines the alpha limits in alpha test mode.
  45119. */
  45120. protected _alphaCutOff: number;
  45121. /**
  45122. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45123. */
  45124. protected _forceAlphaTest: boolean;
  45125. /**
  45126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45127. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45128. */
  45129. protected _useAlphaFresnel: boolean;
  45130. /**
  45131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45132. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45133. */
  45134. protected _useLinearAlphaFresnel: boolean;
  45135. /**
  45136. * The transparency mode of the material.
  45137. */
  45138. protected _transparencyMode: Nullable<number>;
  45139. /**
  45140. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45141. * from cos thetav and roughness:
  45142. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45143. */
  45144. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45145. /**
  45146. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45147. */
  45148. protected _forceIrradianceInFragment: boolean;
  45149. /**
  45150. * Force normal to face away from face.
  45151. */
  45152. protected _forceNormalForward: boolean;
  45153. /**
  45154. * Enables specular anti aliasing in the PBR shader.
  45155. * It will both interacts on the Geometry for analytical and IBL lighting.
  45156. * It also prefilter the roughness map based on the bump values.
  45157. */
  45158. protected _enableSpecularAntiAliasing: boolean;
  45159. /**
  45160. * Default configuration related to image processing available in the PBR Material.
  45161. */
  45162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45163. /**
  45164. * Keep track of the image processing observer to allow dispose and replace.
  45165. */
  45166. private _imageProcessingObserver;
  45167. /**
  45168. * Attaches a new image processing configuration to the PBR Material.
  45169. * @param configuration
  45170. */
  45171. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45172. /**
  45173. * Stores the available render targets.
  45174. */
  45175. private _renderTargets;
  45176. /**
  45177. * Sets the global ambient color for the material used in lighting calculations.
  45178. */
  45179. private _globalAmbientColor;
  45180. /**
  45181. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45182. */
  45183. private _useLogarithmicDepth;
  45184. /**
  45185. * If set to true, no lighting calculations will be applied.
  45186. */
  45187. private _unlit;
  45188. /**
  45189. * Instantiates a new PBRMaterial instance.
  45190. *
  45191. * @param name The material name
  45192. * @param scene The scene the material will be use in.
  45193. */
  45194. constructor(name: string, scene: Scene);
  45195. /**
  45196. * Gets a boolean indicating that current material needs to register RTT
  45197. */
  45198. readonly hasRenderTargetTextures: boolean;
  45199. /**
  45200. * Gets the name of the material class.
  45201. */
  45202. getClassName(): string;
  45203. /**
  45204. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45205. */
  45206. /**
  45207. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45208. */
  45209. useLogarithmicDepth: boolean;
  45210. /**
  45211. * Gets the current transparency mode.
  45212. */
  45213. /**
  45214. * Sets the transparency mode of the material.
  45215. *
  45216. * | Value | Type | Description |
  45217. * | ----- | ----------------------------------- | ----------- |
  45218. * | 0 | OPAQUE | |
  45219. * | 1 | ALPHATEST | |
  45220. * | 2 | ALPHABLEND | |
  45221. * | 3 | ALPHATESTANDBLEND | |
  45222. *
  45223. */
  45224. transparencyMode: Nullable<number>;
  45225. /**
  45226. * Returns true if alpha blending should be disabled.
  45227. */
  45228. private readonly _disableAlphaBlending;
  45229. /**
  45230. * Specifies whether or not this material should be rendered in alpha blend mode.
  45231. */
  45232. needAlphaBlending(): boolean;
  45233. /**
  45234. * Specifies if the mesh will require alpha blending.
  45235. * @param mesh - BJS mesh.
  45236. */
  45237. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45238. /**
  45239. * Specifies whether or not this material should be rendered in alpha test mode.
  45240. */
  45241. needAlphaTesting(): boolean;
  45242. /**
  45243. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45244. */
  45245. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45246. /**
  45247. * Gets the texture used for the alpha test.
  45248. */
  45249. getAlphaTestTexture(): BaseTexture;
  45250. /**
  45251. * Stores the reflectivity values based on metallic roughness workflow.
  45252. */
  45253. private static _scaledReflectivity;
  45254. /**
  45255. * Specifies that the submesh is ready to be used.
  45256. * @param mesh - BJS mesh.
  45257. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45258. * @param useInstances - Specifies that instances should be used.
  45259. * @returns - boolean indicating that the submesh is ready or not.
  45260. */
  45261. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45262. /**
  45263. * Specifies if the material uses metallic roughness workflow.
  45264. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45265. */
  45266. isMetallicWorkflow(): boolean;
  45267. private _prepareEffect;
  45268. private _prepareDefines;
  45269. /**
  45270. * Force shader compilation
  45271. */
  45272. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45273. clipPlane: boolean;
  45274. }>): void;
  45275. /**
  45276. * Initializes the uniform buffer layout for the shader.
  45277. */
  45278. buildUniformLayout(): void;
  45279. /**
  45280. * Unbinds the textures.
  45281. */
  45282. unbind(): void;
  45283. /**
  45284. * Binds the submesh data.
  45285. * @param world - The world matrix.
  45286. * @param mesh - The BJS mesh.
  45287. * @param subMesh - A submesh of the BJS mesh.
  45288. */
  45289. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45290. /**
  45291. * Returns the animatable textures.
  45292. * @returns - Array of animatable textures.
  45293. */
  45294. getAnimatables(): IAnimatable[];
  45295. /**
  45296. * Returns the texture used for reflections.
  45297. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45298. */
  45299. private _getReflectionTexture;
  45300. /**
  45301. * Returns the texture used for refraction or null if none is used.
  45302. * @returns - Refection texture if present. If no refraction texture and refraction
  45303. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45304. */
  45305. private _getRefractionTexture;
  45306. /**
  45307. * Disposes the resources of the material.
  45308. * @param forceDisposeEffect - Forces the disposal of effects.
  45309. * @param forceDisposeTextures - Forces the disposal of all textures.
  45310. */
  45311. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45312. }
  45313. }
  45314. declare module BABYLON {
  45315. /**
  45316. * The Physically based simple base material of BJS.
  45317. *
  45318. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45319. * It is used as the base class for both the specGloss and metalRough conventions.
  45320. */
  45321. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45322. /**
  45323. * Number of Simultaneous lights allowed on the material.
  45324. */
  45325. maxSimultaneousLights: number;
  45326. /**
  45327. * If sets to true, disables all the lights affecting the material.
  45328. */
  45329. disableLighting: boolean;
  45330. /**
  45331. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45332. */
  45333. environmentTexture: BaseTexture;
  45334. /**
  45335. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45336. */
  45337. invertNormalMapX: boolean;
  45338. /**
  45339. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45340. */
  45341. invertNormalMapY: boolean;
  45342. /**
  45343. * Normal map used in the model.
  45344. */
  45345. normalTexture: BaseTexture;
  45346. /**
  45347. * Emissivie color used to self-illuminate the model.
  45348. */
  45349. emissiveColor: Color3;
  45350. /**
  45351. * Emissivie texture used to self-illuminate the model.
  45352. */
  45353. emissiveTexture: BaseTexture;
  45354. /**
  45355. * Occlusion Channel Strenght.
  45356. */
  45357. occlusionStrength: number;
  45358. /**
  45359. * Occlusion Texture of the material (adding extra occlusion effects).
  45360. */
  45361. occlusionTexture: BaseTexture;
  45362. /**
  45363. * Defines the alpha limits in alpha test mode.
  45364. */
  45365. alphaCutOff: number;
  45366. /**
  45367. * Gets the current double sided mode.
  45368. */
  45369. /**
  45370. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45371. */
  45372. doubleSided: boolean;
  45373. /**
  45374. * Stores the pre-calculated light information of a mesh in a texture.
  45375. */
  45376. lightmapTexture: BaseTexture;
  45377. /**
  45378. * If true, the light map contains occlusion information instead of lighting info.
  45379. */
  45380. useLightmapAsShadowmap: boolean;
  45381. /**
  45382. * Return the active textures of the material.
  45383. */
  45384. getActiveTextures(): BaseTexture[];
  45385. hasTexture(texture: BaseTexture): boolean;
  45386. /**
  45387. * Instantiates a new PBRMaterial instance.
  45388. *
  45389. * @param name The material name
  45390. * @param scene The scene the material will be use in.
  45391. */
  45392. constructor(name: string, scene: Scene);
  45393. getClassName(): string;
  45394. }
  45395. }
  45396. declare module BABYLON {
  45397. /**
  45398. * The Physically based material of BJS.
  45399. *
  45400. * This offers the main features of a standard PBR material.
  45401. * For more information, please refer to the documentation :
  45402. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45403. */
  45404. class PBRMaterial extends PBRBaseMaterial {
  45405. /**
  45406. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45407. */
  45408. static readonly PBRMATERIAL_OPAQUE: number;
  45409. /**
  45410. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45411. */
  45412. static readonly PBRMATERIAL_ALPHATEST: number;
  45413. /**
  45414. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45415. */
  45416. static readonly PBRMATERIAL_ALPHABLEND: number;
  45417. /**
  45418. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45419. * They are also discarded below the alpha cutoff threshold to improve performances.
  45420. */
  45421. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45422. /**
  45423. * Defines the default value of how much AO map is occluding the analytical lights
  45424. * (point spot...).
  45425. */
  45426. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45427. /**
  45428. * Intensity of the direct lights e.g. the four lights available in your scene.
  45429. * This impacts both the direct diffuse and specular highlights.
  45430. */
  45431. directIntensity: number;
  45432. /**
  45433. * Intensity of the emissive part of the material.
  45434. * This helps controlling the emissive effect without modifying the emissive color.
  45435. */
  45436. emissiveIntensity: number;
  45437. /**
  45438. * Intensity of the environment e.g. how much the environment will light the object
  45439. * either through harmonics for rough material or through the refelction for shiny ones.
  45440. */
  45441. environmentIntensity: number;
  45442. /**
  45443. * This is a special control allowing the reduction of the specular highlights coming from the
  45444. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45445. */
  45446. specularIntensity: number;
  45447. /**
  45448. * Debug Control allowing disabling the bump map on this material.
  45449. */
  45450. disableBumpMap: boolean;
  45451. /**
  45452. * AKA Diffuse Texture in standard nomenclature.
  45453. */
  45454. albedoTexture: BaseTexture;
  45455. /**
  45456. * AKA Occlusion Texture in other nomenclature.
  45457. */
  45458. ambientTexture: BaseTexture;
  45459. /**
  45460. * AKA Occlusion Texture Intensity in other nomenclature.
  45461. */
  45462. ambientTextureStrength: number;
  45463. /**
  45464. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45465. * 1 means it completely occludes it
  45466. * 0 mean it has no impact
  45467. */
  45468. ambientTextureImpactOnAnalyticalLights: number;
  45469. /**
  45470. * Stores the alpha values in a texture.
  45471. */
  45472. opacityTexture: BaseTexture;
  45473. /**
  45474. * Stores the reflection values in a texture.
  45475. */
  45476. reflectionTexture: Nullable<BaseTexture>;
  45477. /**
  45478. * Stores the emissive values in a texture.
  45479. */
  45480. emissiveTexture: BaseTexture;
  45481. /**
  45482. * AKA Specular texture in other nomenclature.
  45483. */
  45484. reflectivityTexture: BaseTexture;
  45485. /**
  45486. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45487. */
  45488. metallicTexture: BaseTexture;
  45489. /**
  45490. * Specifies the metallic scalar of the metallic/roughness workflow.
  45491. * Can also be used to scale the metalness values of the metallic texture.
  45492. */
  45493. metallic: Nullable<number>;
  45494. /**
  45495. * Specifies the roughness scalar of the metallic/roughness workflow.
  45496. * Can also be used to scale the roughness values of the metallic texture.
  45497. */
  45498. roughness: Nullable<number>;
  45499. /**
  45500. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45501. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45502. */
  45503. microSurfaceTexture: BaseTexture;
  45504. /**
  45505. * Stores surface normal data used to displace a mesh in a texture.
  45506. */
  45507. bumpTexture: BaseTexture;
  45508. /**
  45509. * Stores the pre-calculated light information of a mesh in a texture.
  45510. */
  45511. lightmapTexture: BaseTexture;
  45512. /**
  45513. * Stores the refracted light information in a texture.
  45514. */
  45515. refractionTexture: BaseTexture;
  45516. /**
  45517. * The color of a material in ambient lighting.
  45518. */
  45519. ambientColor: Color3;
  45520. /**
  45521. * AKA Diffuse Color in other nomenclature.
  45522. */
  45523. albedoColor: Color3;
  45524. /**
  45525. * AKA Specular Color in other nomenclature.
  45526. */
  45527. reflectivityColor: Color3;
  45528. /**
  45529. * The color reflected from the material.
  45530. */
  45531. reflectionColor: Color3;
  45532. /**
  45533. * The color emitted from the material.
  45534. */
  45535. emissiveColor: Color3;
  45536. /**
  45537. * AKA Glossiness in other nomenclature.
  45538. */
  45539. microSurface: number;
  45540. /**
  45541. * source material index of refraction (IOR)' / 'destination material IOR.
  45542. */
  45543. indexOfRefraction: number;
  45544. /**
  45545. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45546. */
  45547. invertRefractionY: boolean;
  45548. /**
  45549. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45550. * Materials half opaque for instance using refraction could benefit from this control.
  45551. */
  45552. linkRefractionWithTransparency: boolean;
  45553. /**
  45554. * If true, the light map contains occlusion information instead of lighting info.
  45555. */
  45556. useLightmapAsShadowmap: boolean;
  45557. /**
  45558. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45559. */
  45560. useAlphaFromAlbedoTexture: boolean;
  45561. /**
  45562. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45563. */
  45564. forceAlphaTest: boolean;
  45565. /**
  45566. * Defines the alpha limits in alpha test mode.
  45567. */
  45568. alphaCutOff: number;
  45569. /**
  45570. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45571. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45572. */
  45573. useSpecularOverAlpha: boolean;
  45574. /**
  45575. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45576. */
  45577. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45578. /**
  45579. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45580. */
  45581. useRoughnessFromMetallicTextureAlpha: boolean;
  45582. /**
  45583. * Specifies if the metallic texture contains the roughness information in its green channel.
  45584. */
  45585. useRoughnessFromMetallicTextureGreen: boolean;
  45586. /**
  45587. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45588. */
  45589. useMetallnessFromMetallicTextureBlue: boolean;
  45590. /**
  45591. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45592. */
  45593. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45594. /**
  45595. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45596. */
  45597. useAmbientInGrayScale: boolean;
  45598. /**
  45599. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45600. * The material will try to infer what glossiness each pixel should be.
  45601. */
  45602. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45603. /**
  45604. * BJS is using an harcoded light falloff based on a manually sets up range.
  45605. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45606. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45607. */
  45608. /**
  45609. * BJS is using an harcoded light falloff based on a manually sets up range.
  45610. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45611. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45612. */
  45613. usePhysicalLightFalloff: boolean;
  45614. /**
  45615. * In order to support the falloff compatibility with gltf, a special mode has been added
  45616. * to reproduce the gltf light falloff.
  45617. */
  45618. /**
  45619. * In order to support the falloff compatibility with gltf, a special mode has been added
  45620. * to reproduce the gltf light falloff.
  45621. */
  45622. useGLTFLightFalloff: boolean;
  45623. /**
  45624. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45625. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45626. */
  45627. useRadianceOverAlpha: boolean;
  45628. /**
  45629. * Allows using an object space normal map (instead of tangent space).
  45630. */
  45631. useObjectSpaceNormalMap: boolean;
  45632. /**
  45633. * Allows using the bump map in parallax mode.
  45634. */
  45635. useParallax: boolean;
  45636. /**
  45637. * Allows using the bump map in parallax occlusion mode.
  45638. */
  45639. useParallaxOcclusion: boolean;
  45640. /**
  45641. * Controls the scale bias of the parallax mode.
  45642. */
  45643. parallaxScaleBias: number;
  45644. /**
  45645. * If sets to true, disables all the lights affecting the material.
  45646. */
  45647. disableLighting: boolean;
  45648. /**
  45649. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45650. */
  45651. forceIrradianceInFragment: boolean;
  45652. /**
  45653. * Number of Simultaneous lights allowed on the material.
  45654. */
  45655. maxSimultaneousLights: number;
  45656. /**
  45657. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45658. */
  45659. invertNormalMapX: boolean;
  45660. /**
  45661. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45662. */
  45663. invertNormalMapY: boolean;
  45664. /**
  45665. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45666. */
  45667. twoSidedLighting: boolean;
  45668. /**
  45669. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45670. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45671. */
  45672. useAlphaFresnel: boolean;
  45673. /**
  45674. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45675. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45676. */
  45677. useLinearAlphaFresnel: boolean;
  45678. /**
  45679. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45680. * And/Or occlude the blended part.
  45681. */
  45682. environmentBRDFTexture: Nullable<BaseTexture>;
  45683. /**
  45684. * Force normal to face away from face.
  45685. */
  45686. forceNormalForward: boolean;
  45687. /**
  45688. * Enables specular anti aliasing in the PBR shader.
  45689. * It will both interacts on the Geometry for analytical and IBL lighting.
  45690. * It also prefilter the roughness map based on the bump values.
  45691. */
  45692. enableSpecularAntiAliasing: boolean;
  45693. /**
  45694. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45695. * makes the reflect vector face the model (under horizon).
  45696. */
  45697. useHorizonOcclusion: boolean;
  45698. /**
  45699. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45700. * too much the area relying on ambient texture to define their ambient occlusion.
  45701. */
  45702. useRadianceOcclusion: boolean;
  45703. /**
  45704. * If set to true, no lighting calculations will be applied.
  45705. */
  45706. unlit: boolean;
  45707. /**
  45708. * Gets the image processing configuration used either in this material.
  45709. */
  45710. /**
  45711. * Sets the Default image processing configuration used either in the this material.
  45712. *
  45713. * If sets to null, the scene one is in use.
  45714. */
  45715. imageProcessingConfiguration: ImageProcessingConfiguration;
  45716. /**
  45717. * Gets wether the color curves effect is enabled.
  45718. */
  45719. /**
  45720. * Sets wether the color curves effect is enabled.
  45721. */
  45722. cameraColorCurvesEnabled: boolean;
  45723. /**
  45724. * Gets wether the color grading effect is enabled.
  45725. */
  45726. /**
  45727. * Gets wether the color grading effect is enabled.
  45728. */
  45729. cameraColorGradingEnabled: boolean;
  45730. /**
  45731. * Gets wether tonemapping is enabled or not.
  45732. */
  45733. /**
  45734. * Sets wether tonemapping is enabled or not
  45735. */
  45736. cameraToneMappingEnabled: boolean;
  45737. /**
  45738. * The camera exposure used on this material.
  45739. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45740. * This corresponds to a photographic exposure.
  45741. */
  45742. /**
  45743. * The camera exposure used on this material.
  45744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45745. * This corresponds to a photographic exposure.
  45746. */
  45747. cameraExposure: number;
  45748. /**
  45749. * Gets The camera contrast used on this material.
  45750. */
  45751. /**
  45752. * Sets The camera contrast used on this material.
  45753. */
  45754. cameraContrast: number;
  45755. /**
  45756. * Gets the Color Grading 2D Lookup Texture.
  45757. */
  45758. /**
  45759. * Sets the Color Grading 2D Lookup Texture.
  45760. */
  45761. cameraColorGradingTexture: Nullable<BaseTexture>;
  45762. /**
  45763. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45764. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45765. * 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;
  45766. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45767. */
  45768. /**
  45769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45771. * 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;
  45772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45773. */
  45774. cameraColorCurves: Nullable<ColorCurves>;
  45775. /**
  45776. * Instantiates a new PBRMaterial instance.
  45777. *
  45778. * @param name The material name
  45779. * @param scene The scene the material will be use in.
  45780. */
  45781. constructor(name: string, scene: Scene);
  45782. /**
  45783. * Returns the name of this material class.
  45784. */
  45785. getClassName(): string;
  45786. /**
  45787. * Returns an array of the actively used textures.
  45788. * @returns - Array of BaseTextures
  45789. */
  45790. getActiveTextures(): BaseTexture[];
  45791. /**
  45792. * Checks to see if a texture is used in the material.
  45793. * @param texture - Base texture to use.
  45794. * @returns - Boolean specifying if a texture is used in the material.
  45795. */
  45796. hasTexture(texture: BaseTexture): boolean;
  45797. /**
  45798. * Makes a duplicate of the current material.
  45799. * @param name - name to use for the new material.
  45800. */
  45801. clone(name: string): PBRMaterial;
  45802. /**
  45803. * Serializes this PBR Material.
  45804. * @returns - An object with the serialized material.
  45805. */
  45806. serialize(): any;
  45807. /**
  45808. * Parses a PBR Material from a serialized object.
  45809. * @param source - Serialized object.
  45810. * @param scene - BJS scene instance.
  45811. * @param rootUrl - url for the scene object
  45812. * @returns - PBRMaterial
  45813. */
  45814. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45815. }
  45816. }
  45817. declare module BABYLON {
  45818. /**
  45819. * The PBR material of BJS following the metal roughness convention.
  45820. *
  45821. * This fits to the PBR convention in the GLTF definition:
  45822. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45823. */
  45824. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45825. /**
  45826. * The base color has two different interpretations depending on the value of metalness.
  45827. * When the material is a metal, the base color is the specific measured reflectance value
  45828. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45829. * of the material.
  45830. */
  45831. baseColor: Color3;
  45832. /**
  45833. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45834. * well as opacity information in the alpha channel.
  45835. */
  45836. baseTexture: BaseTexture;
  45837. /**
  45838. * Specifies the metallic scalar value of the material.
  45839. * Can also be used to scale the metalness values of the metallic texture.
  45840. */
  45841. metallic: number;
  45842. /**
  45843. * Specifies the roughness scalar value of the material.
  45844. * Can also be used to scale the roughness values of the metallic texture.
  45845. */
  45846. roughness: number;
  45847. /**
  45848. * Texture containing both the metallic value in the B channel and the
  45849. * roughness value in the G channel to keep better precision.
  45850. */
  45851. metallicRoughnessTexture: BaseTexture;
  45852. /**
  45853. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45854. *
  45855. * @param name The material name
  45856. * @param scene The scene the material will be use in.
  45857. */
  45858. constructor(name: string, scene: Scene);
  45859. /**
  45860. * Return the currrent class name of the material.
  45861. */
  45862. getClassName(): string;
  45863. /**
  45864. * Return the active textures of the material.
  45865. */
  45866. getActiveTextures(): BaseTexture[];
  45867. /**
  45868. * Checks to see if a texture is used in the material.
  45869. * @param texture - Base texture to use.
  45870. * @returns - Boolean specifying if a texture is used in the material.
  45871. */
  45872. hasTexture(texture: BaseTexture): boolean;
  45873. /**
  45874. * Makes a duplicate of the current material.
  45875. * @param name - name to use for the new material.
  45876. */
  45877. clone(name: string): PBRMetallicRoughnessMaterial;
  45878. /**
  45879. * Serialize the material to a parsable JSON object.
  45880. */
  45881. serialize(): any;
  45882. /**
  45883. * Parses a JSON object correponding to the serialize function.
  45884. */
  45885. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45886. }
  45887. }
  45888. declare module BABYLON {
  45889. /**
  45890. * The PBR material of BJS following the specular glossiness convention.
  45891. *
  45892. * This fits to the PBR convention in the GLTF definition:
  45893. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45894. */
  45895. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45896. /**
  45897. * Specifies the diffuse color of the material.
  45898. */
  45899. diffuseColor: Color3;
  45900. /**
  45901. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45902. * channel.
  45903. */
  45904. diffuseTexture: BaseTexture;
  45905. /**
  45906. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45907. */
  45908. specularColor: Color3;
  45909. /**
  45910. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45911. */
  45912. glossiness: number;
  45913. /**
  45914. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45915. */
  45916. specularGlossinessTexture: BaseTexture;
  45917. /**
  45918. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45919. *
  45920. * @param name The material name
  45921. * @param scene The scene the material will be use in.
  45922. */
  45923. constructor(name: string, scene: Scene);
  45924. /**
  45925. * Return the currrent class name of the material.
  45926. */
  45927. getClassName(): string;
  45928. /**
  45929. * Return the active textures of the material.
  45930. */
  45931. getActiveTextures(): BaseTexture[];
  45932. /**
  45933. * Checks to see if a texture is used in the material.
  45934. * @param texture - Base texture to use.
  45935. * @returns - Boolean specifying if a texture is used in the material.
  45936. */
  45937. hasTexture(texture: BaseTexture): boolean;
  45938. /**
  45939. * Makes a duplicate of the current material.
  45940. * @param name - name to use for the new material.
  45941. */
  45942. clone(name: string): PBRSpecularGlossinessMaterial;
  45943. /**
  45944. * Serialize the material to a parsable JSON object.
  45945. */
  45946. serialize(): any;
  45947. /**
  45948. * Parses a JSON object correponding to the serialize function.
  45949. */
  45950. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45951. }
  45952. }
  45953. declare module BABYLON {
  45954. /**
  45955. * Base class of all the textures in babylon.
  45956. * It groups all the common properties the materials, post process, lights... might need
  45957. * in order to make a correct use of the texture.
  45958. */
  45959. class BaseTexture {
  45960. /**
  45961. * Default anisotropic filtering level for the application.
  45962. * It is set to 4 as a good tradeoff between perf and quality.
  45963. */
  45964. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45965. /**
  45966. * Gets or sets the unique id of the texture
  45967. */
  45968. uniqueId: number;
  45969. /**
  45970. * Define the name of the texture.
  45971. */
  45972. name: string;
  45973. private _hasAlpha;
  45974. /**
  45975. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45976. */
  45977. hasAlpha: boolean;
  45978. /**
  45979. * Defines if the alpha value should be determined via the rgb values.
  45980. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45981. */
  45982. getAlphaFromRGB: boolean;
  45983. /**
  45984. * Intensity or strength of the texture.
  45985. * It is commonly used by materials to fine tune the intensity of the texture
  45986. */
  45987. level: number;
  45988. /**
  45989. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45990. * This is part of the texture as textures usually maps to one uv set.
  45991. */
  45992. coordinatesIndex: number;
  45993. private _coordinatesMode;
  45994. /**
  45995. * How a texture is mapped.
  45996. *
  45997. * | Value | Type | Description |
  45998. * | ----- | ----------------------------------- | ----------- |
  45999. * | 0 | EXPLICIT_MODE | |
  46000. * | 1 | SPHERICAL_MODE | |
  46001. * | 2 | PLANAR_MODE | |
  46002. * | 3 | CUBIC_MODE | |
  46003. * | 4 | PROJECTION_MODE | |
  46004. * | 5 | SKYBOX_MODE | |
  46005. * | 6 | INVCUBIC_MODE | |
  46006. * | 7 | EQUIRECTANGULAR_MODE | |
  46007. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46008. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46009. */
  46010. coordinatesMode: number;
  46011. /**
  46012. * | Value | Type | Description |
  46013. * | ----- | ------------------ | ----------- |
  46014. * | 0 | CLAMP_ADDRESSMODE | |
  46015. * | 1 | WRAP_ADDRESSMODE | |
  46016. * | 2 | MIRROR_ADDRESSMODE | |
  46017. */
  46018. wrapU: number;
  46019. /**
  46020. * | Value | Type | Description |
  46021. * | ----- | ------------------ | ----------- |
  46022. * | 0 | CLAMP_ADDRESSMODE | |
  46023. * | 1 | WRAP_ADDRESSMODE | |
  46024. * | 2 | MIRROR_ADDRESSMODE | |
  46025. */
  46026. wrapV: number;
  46027. /**
  46028. * | Value | Type | Description |
  46029. * | ----- | ------------------ | ----------- |
  46030. * | 0 | CLAMP_ADDRESSMODE | |
  46031. * | 1 | WRAP_ADDRESSMODE | |
  46032. * | 2 | MIRROR_ADDRESSMODE | |
  46033. */
  46034. wrapR: number;
  46035. /**
  46036. * With compliant hardware and browser (supporting anisotropic filtering)
  46037. * this defines the level of anisotropic filtering in the texture.
  46038. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46039. */
  46040. anisotropicFilteringLevel: number;
  46041. /**
  46042. * Define if the texture is a cube texture or if false a 2d texture.
  46043. */
  46044. isCube: boolean;
  46045. /**
  46046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46047. */
  46048. is3D: boolean;
  46049. /**
  46050. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46051. * HDR texture are usually stored in linear space.
  46052. * This only impacts the PBR and Background materials
  46053. */
  46054. gammaSpace: boolean;
  46055. /**
  46056. * Gets whether or not the texture contains RGBD data.
  46057. */
  46058. readonly isRGBD: boolean;
  46059. /**
  46060. * Is Z inverted in the texture (useful in a cube texture).
  46061. */
  46062. invertZ: boolean;
  46063. /**
  46064. * @hidden
  46065. */
  46066. lodLevelInAlpha: boolean;
  46067. /**
  46068. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46069. */
  46070. lodGenerationOffset: number;
  46071. /**
  46072. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46073. */
  46074. lodGenerationScale: number;
  46075. /**
  46076. * Define if the texture is a render target.
  46077. */
  46078. isRenderTarget: boolean;
  46079. /**
  46080. * Define the unique id of the texture in the scene.
  46081. */
  46082. readonly uid: string;
  46083. /**
  46084. * Return a string representation of the texture.
  46085. * @returns the texture as a string
  46086. */
  46087. toString(): string;
  46088. /**
  46089. * Get the class name of the texture.
  46090. * @returns "BaseTexture"
  46091. */
  46092. getClassName(): string;
  46093. /**
  46094. * Define the list of animation attached to the texture.
  46095. */
  46096. animations: Animation[];
  46097. /**
  46098. * An event triggered when the texture is disposed.
  46099. */
  46100. onDisposeObservable: Observable<BaseTexture>;
  46101. private _onDisposeObserver;
  46102. /**
  46103. * Callback triggered when the texture has been disposed.
  46104. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46105. */
  46106. onDispose: () => void;
  46107. /**
  46108. * Define the current state of the loading sequence when in delayed load mode.
  46109. */
  46110. delayLoadState: number;
  46111. private _scene;
  46112. /** @hidden */
  46113. _texture: Nullable<InternalTexture>;
  46114. private _uid;
  46115. /**
  46116. * Define if the texture is preventinga material to render or not.
  46117. * If not and the texture is not ready, the engine will use a default black texture instead.
  46118. */
  46119. readonly isBlocking: boolean;
  46120. /**
  46121. * Instantiates a new BaseTexture.
  46122. * Base class of all the textures in babylon.
  46123. * It groups all the common properties the materials, post process, lights... might need
  46124. * in order to make a correct use of the texture.
  46125. * @param scene Define the scene the texture blongs to
  46126. */
  46127. constructor(scene: Nullable<Scene>);
  46128. /**
  46129. * Get the scene the texture belongs to.
  46130. * @returns the scene or null if undefined
  46131. */
  46132. getScene(): Nullable<Scene>;
  46133. /**
  46134. * Get the texture transform matrix used to offset tile the texture for istance.
  46135. * @returns the transformation matrix
  46136. */
  46137. getTextureMatrix(): Matrix;
  46138. /**
  46139. * Get the texture reflection matrix used to rotate/transform the reflection.
  46140. * @returns the reflection matrix
  46141. */
  46142. getReflectionTextureMatrix(): Matrix;
  46143. /**
  46144. * Get the underlying lower level texture from Babylon.
  46145. * @returns the insternal texture
  46146. */
  46147. getInternalTexture(): Nullable<InternalTexture>;
  46148. /**
  46149. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46150. * @returns true if ready or not blocking
  46151. */
  46152. isReadyOrNotBlocking(): boolean;
  46153. /**
  46154. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46155. * @returns true if fully ready
  46156. */
  46157. isReady(): boolean;
  46158. private _cachedSize;
  46159. /**
  46160. * Get the size of the texture.
  46161. * @returns the texture size.
  46162. */
  46163. getSize(): ISize;
  46164. /**
  46165. * Get the base size of the texture.
  46166. * It can be different from the size if the texture has been resized for POT for instance
  46167. * @returns the base size
  46168. */
  46169. getBaseSize(): ISize;
  46170. /**
  46171. * Scales the texture if is `canRescale()`
  46172. * @param ratio the resize factor we want to use to rescale
  46173. */
  46174. scale(ratio: number): void;
  46175. /**
  46176. * Get if the texture can rescale.
  46177. */
  46178. readonly canRescale: boolean;
  46179. /** @hidden */
  46180. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46181. /** @hidden */
  46182. _rebuild(): void;
  46183. /**
  46184. * Triggers the load sequence in delayed load mode.
  46185. */
  46186. delayLoad(): void;
  46187. /**
  46188. * Clones the texture.
  46189. * @returns the cloned texture
  46190. */
  46191. clone(): Nullable<BaseTexture>;
  46192. /**
  46193. * Get the texture underlying type (INT, FLOAT...)
  46194. */
  46195. readonly textureType: number;
  46196. /**
  46197. * Get the texture underlying format (RGB, RGBA...)
  46198. */
  46199. readonly textureFormat: number;
  46200. /**
  46201. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46202. * This will returns an RGBA array buffer containing either in values (0-255) or
  46203. * float values (0-1) depending of the underlying buffer type.
  46204. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46205. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46206. * @param buffer defines a user defined buffer to fill with data (can be null)
  46207. * @returns The Array buffer containing the pixels data.
  46208. */
  46209. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46210. /**
  46211. * Release and destroy the underlying lower level texture aka internalTexture.
  46212. */
  46213. releaseInternalTexture(): void;
  46214. /**
  46215. * Get the polynomial representation of the texture data.
  46216. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46217. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46218. */
  46219. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46220. /** @hidden */
  46221. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46222. /** @hidden */
  46223. readonly _lodTextureMid: Nullable<BaseTexture>;
  46224. /** @hidden */
  46225. readonly _lodTextureLow: Nullable<BaseTexture>;
  46226. /**
  46227. * Dispose the texture and release its associated resources.
  46228. */
  46229. dispose(): void;
  46230. /**
  46231. * Serialize the texture into a JSON representation that can be parsed later on.
  46232. * @returns the JSON representation of the texture
  46233. */
  46234. serialize(): any;
  46235. /**
  46236. * Helper function to be called back once a list of texture contains only ready textures.
  46237. * @param textures Define the list of textures to wait for
  46238. * @param callback Define the callback triggered once the entire list will be ready
  46239. */
  46240. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46241. }
  46242. }
  46243. declare module BABYLON {
  46244. /**
  46245. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46246. * It can help converting any input color in a desired output one. This can then be used to create effects
  46247. * from sepia, black and white to sixties or futuristic rendering...
  46248. *
  46249. * The only supported format is currently 3dl.
  46250. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46251. */
  46252. class ColorGradingTexture extends BaseTexture {
  46253. /**
  46254. * The current texture matrix. (will always be identity in color grading texture)
  46255. */
  46256. private _textureMatrix;
  46257. /**
  46258. * The texture URL.
  46259. */
  46260. url: string;
  46261. /**
  46262. * Empty line regex stored for GC.
  46263. */
  46264. private static _noneEmptyLineRegex;
  46265. private _engine;
  46266. /**
  46267. * Instantiates a ColorGradingTexture from the following parameters.
  46268. *
  46269. * @param url The location of the color gradind data (currently only supporting 3dl)
  46270. * @param scene The scene the texture will be used in
  46271. */
  46272. constructor(url: string, scene: Scene);
  46273. /**
  46274. * Returns the texture matrix used in most of the material.
  46275. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46276. */
  46277. getTextureMatrix(): Matrix;
  46278. /**
  46279. * Occurs when the file being loaded is a .3dl LUT file.
  46280. */
  46281. private load3dlTexture;
  46282. /**
  46283. * Starts the loading process of the texture.
  46284. */
  46285. private loadTexture;
  46286. /**
  46287. * Clones the color gradind texture.
  46288. */
  46289. clone(): ColorGradingTexture;
  46290. /**
  46291. * Called during delayed load for textures.
  46292. */
  46293. delayLoad(): void;
  46294. /**
  46295. * Parses a color grading texture serialized by Babylon.
  46296. * @param parsedTexture The texture information being parsedTexture
  46297. * @param scene The scene to load the texture in
  46298. * @param rootUrl The root url of the data assets to load
  46299. * @return A color gradind texture
  46300. */
  46301. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46302. /**
  46303. * Serializes the LUT texture to json format.
  46304. */
  46305. serialize(): any;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * Class for creating a cube texture
  46311. */
  46312. class CubeTexture extends BaseTexture {
  46313. /**
  46314. * The url of the texture
  46315. */
  46316. url: string;
  46317. /**
  46318. * Gets or sets the center of the bounding box associated with the cube texture.
  46319. * It must define where the camera used to render the texture was set
  46320. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46321. */
  46322. boundingBoxPosition: Vector3;
  46323. private _boundingBoxSize;
  46324. /**
  46325. * Gets or sets the size of the bounding box associated with the cube texture
  46326. * When defined, the cubemap will switch to local mode
  46327. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46328. * @example https://www.babylonjs-playground.com/#RNASML
  46329. */
  46330. /**
  46331. * Returns the bounding box size
  46332. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46333. */
  46334. boundingBoxSize: Vector3;
  46335. protected _rotationY: number;
  46336. /**
  46337. * Sets texture matrix rotation angle around Y axis in radians.
  46338. */
  46339. /**
  46340. * Gets texture matrix rotation angle around Y axis radians.
  46341. */
  46342. rotationY: number;
  46343. private _noMipmap;
  46344. private _files;
  46345. private _extensions;
  46346. private _textureMatrix;
  46347. private _format;
  46348. private _createPolynomials;
  46349. /** @hidden */
  46350. readonly _prefiltered: boolean;
  46351. /**
  46352. * Creates a cube texture from an array of image urls
  46353. * @param files defines an array of image urls
  46354. * @param scene defines the hosting scene
  46355. * @param noMipmap specifies if mip maps are not used
  46356. * @returns a cube texture
  46357. */
  46358. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46359. /**
  46360. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46361. * @param url defines the url of the prefiltered texture
  46362. * @param scene defines the scene the texture is attached to
  46363. * @param forcedExtension defines the extension of the file if different from the url
  46364. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46365. * @return the prefiltered texture
  46366. */
  46367. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46368. /**
  46369. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46370. * as prefiltered data.
  46371. * @param rootUrl defines the url of the texture or the root name of the six images
  46372. * @param scene defines the scene the texture is attached to
  46373. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46374. * @param noMipmap defines if mipmaps should be created or not
  46375. * @param files defines the six files to load for the different faces
  46376. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46377. * @param onError defines a callback triggered in case of error during load
  46378. * @param format defines the internal format to use for the texture once loaded
  46379. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46380. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46381. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46382. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46383. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46384. * @return the cube texture
  46385. */
  46386. 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);
  46387. /**
  46388. * Delays loading of the cube texture
  46389. */
  46390. delayLoad(): void;
  46391. /**
  46392. * Returns the reflection texture matrix
  46393. * @returns the reflection texture matrix
  46394. */
  46395. getReflectionTextureMatrix(): Matrix;
  46396. /**
  46397. * Sets the reflection texture matrix
  46398. * @param value Reflection texture matrix
  46399. */
  46400. setReflectionTextureMatrix(value: Matrix): void;
  46401. /**
  46402. * Parses text to create a cube texture
  46403. * @param parsedTexture define the serialized text to read from
  46404. * @param scene defines the hosting scene
  46405. * @param rootUrl defines the root url of the cube texture
  46406. * @returns a cube texture
  46407. */
  46408. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46409. /**
  46410. * Makes a clone, or deep copy, of the cube texture
  46411. * @returns a new cube texture
  46412. */
  46413. clone(): CubeTexture;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /**
  46418. * A class extending Texture allowing drawing on a texture
  46419. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46420. */
  46421. class DynamicTexture extends Texture {
  46422. private _generateMipMaps;
  46423. private _canvas;
  46424. private _context;
  46425. private _engine;
  46426. /**
  46427. * Creates a DynamicTexture
  46428. * @param name defines the name of the texture
  46429. * @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
  46430. * @param scene defines the scene where you want the texture
  46431. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46432. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46433. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46434. */
  46435. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46436. /**
  46437. * Gets the current state of canRescale
  46438. */
  46439. readonly canRescale: boolean;
  46440. private _recreate;
  46441. /**
  46442. * Scales the texture
  46443. * @param ratio the scale factor to apply to both width and height
  46444. */
  46445. scale(ratio: number): void;
  46446. /**
  46447. * Resizes the texture
  46448. * @param width the new width
  46449. * @param height the new height
  46450. */
  46451. scaleTo(width: number, height: number): void;
  46452. /**
  46453. * Gets the context of the canvas used by the texture
  46454. * @returns the canvas context of the dynamic texture
  46455. */
  46456. getContext(): CanvasRenderingContext2D;
  46457. /**
  46458. * Clears the texture
  46459. */
  46460. clear(): void;
  46461. /**
  46462. * Updates the texture
  46463. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46464. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46465. */
  46466. update(invertY?: boolean, premulAlpha?: boolean): void;
  46467. /**
  46468. * Draws text onto the texture
  46469. * @param text defines the text to be drawn
  46470. * @param x defines the placement of the text from the left
  46471. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46472. * @param font defines the font to be used with font-style, font-size, font-name
  46473. * @param color defines the color used for the text
  46474. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46475. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46476. * @param update defines whether texture is immediately update (default is true)
  46477. */
  46478. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46479. /**
  46480. * Clones the texture
  46481. * @returns the clone of the texture.
  46482. */
  46483. clone(): DynamicTexture;
  46484. /**
  46485. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46486. * @returns a serialized dynamic texture object
  46487. */
  46488. serialize(): any;
  46489. /** @hidden */
  46490. _rebuild(): void;
  46491. }
  46492. }
  46493. declare module BABYLON {
  46494. /**
  46495. * This represents a texture coming from an HDR input.
  46496. *
  46497. * The only supported format is currently panorama picture stored in RGBE format.
  46498. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46499. */
  46500. class HDRCubeTexture extends BaseTexture {
  46501. private static _facesMapping;
  46502. private _generateHarmonics;
  46503. private _noMipmap;
  46504. private _textureMatrix;
  46505. private _size;
  46506. private _onLoad;
  46507. private _onError;
  46508. /**
  46509. * The texture URL.
  46510. */
  46511. url: string;
  46512. /**
  46513. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46514. */
  46515. coordinatesMode: number;
  46516. protected _isBlocking: boolean;
  46517. /**
  46518. * Sets wether or not the texture is blocking during loading.
  46519. */
  46520. /**
  46521. * Gets wether or not the texture is blocking during loading.
  46522. */
  46523. isBlocking: boolean;
  46524. protected _rotationY: number;
  46525. /**
  46526. * Sets texture matrix rotation angle around Y axis in radians.
  46527. */
  46528. /**
  46529. * Gets texture matrix rotation angle around Y axis radians.
  46530. */
  46531. rotationY: number;
  46532. /**
  46533. * Gets or sets the center of the bounding box associated with the cube texture
  46534. * It must define where the camera used to render the texture was set
  46535. */
  46536. boundingBoxPosition: Vector3;
  46537. private _boundingBoxSize;
  46538. /**
  46539. * Gets or sets the size of the bounding box associated with the cube texture
  46540. * When defined, the cubemap will switch to local mode
  46541. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46542. * @example https://www.babylonjs-playground.com/#RNASML
  46543. */
  46544. boundingBoxSize: Vector3;
  46545. /**
  46546. * Instantiates an HDRTexture from the following parameters.
  46547. *
  46548. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46549. * @param scene The scene the texture will be used in
  46550. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46551. * @param noMipmap Forces to not generate the mipmap if true
  46552. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46553. * @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)
  46554. * @param reserved Reserved flag for internal use.
  46555. */
  46556. 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>);
  46557. /**
  46558. * Occurs when the file is raw .hdr file.
  46559. */
  46560. private loadTexture;
  46561. clone(): HDRCubeTexture;
  46562. delayLoad(): void;
  46563. /**
  46564. * Get the texture reflection matrix used to rotate/transform the reflection.
  46565. * @returns the reflection matrix
  46566. */
  46567. getReflectionTextureMatrix(): Matrix;
  46568. /**
  46569. * Set the texture reflection matrix used to rotate/transform the reflection.
  46570. * @param value Define the reflection matrix to set
  46571. */
  46572. setReflectionTextureMatrix(value: Matrix): void;
  46573. /**
  46574. * Parses a JSON representation of an HDR Texture in order to create the texture
  46575. * @param parsedTexture Define the JSON representation
  46576. * @param scene Define the scene the texture should be created in
  46577. * @param rootUrl Define the root url in case we need to load relative dependencies
  46578. * @returns the newly created texture after parsing
  46579. */
  46580. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46581. serialize(): any;
  46582. }
  46583. }
  46584. declare module BABYLON {
  46585. /**
  46586. * Class used to store data associated with WebGL texture data for the engine
  46587. * This class should not be used directly
  46588. */
  46589. class InternalTexture implements IInternalTextureTracker {
  46590. /**
  46591. * The source of the texture data is unknown
  46592. */
  46593. static DATASOURCE_UNKNOWN: number;
  46594. /**
  46595. * Texture data comes from an URL
  46596. */
  46597. static DATASOURCE_URL: number;
  46598. /**
  46599. * Texture data is only used for temporary storage
  46600. */
  46601. static DATASOURCE_TEMP: number;
  46602. /**
  46603. * Texture data comes from raw data (ArrayBuffer)
  46604. */
  46605. static DATASOURCE_RAW: number;
  46606. /**
  46607. * Texture content is dynamic (video or dynamic texture)
  46608. */
  46609. static DATASOURCE_DYNAMIC: number;
  46610. /**
  46611. * Texture content is generated by rendering to it
  46612. */
  46613. static DATASOURCE_RENDERTARGET: number;
  46614. /**
  46615. * Texture content is part of a multi render target process
  46616. */
  46617. static DATASOURCE_MULTIRENDERTARGET: number;
  46618. /**
  46619. * Texture data comes from a cube data file
  46620. */
  46621. static DATASOURCE_CUBE: number;
  46622. /**
  46623. * Texture data comes from a raw cube data
  46624. */
  46625. static DATASOURCE_CUBERAW: number;
  46626. /**
  46627. * Texture data come from a prefiltered cube data file
  46628. */
  46629. static DATASOURCE_CUBEPREFILTERED: number;
  46630. /**
  46631. * Texture content is raw 3D data
  46632. */
  46633. static DATASOURCE_RAW3D: number;
  46634. /**
  46635. * Texture content is a depth texture
  46636. */
  46637. static DATASOURCE_DEPTHTEXTURE: number;
  46638. /**
  46639. * Texture data comes from a raw cube data encoded with RGBD
  46640. */
  46641. static DATASOURCE_CUBERAW_RGBD: number;
  46642. /**
  46643. * Defines if the texture is ready
  46644. */
  46645. isReady: boolean;
  46646. /**
  46647. * Defines if the texture is a cube texture
  46648. */
  46649. isCube: boolean;
  46650. /**
  46651. * Defines if the texture contains 3D data
  46652. */
  46653. is3D: boolean;
  46654. /**
  46655. * Gets the URL used to load this texture
  46656. */
  46657. url: string;
  46658. /**
  46659. * Gets the sampling mode of the texture
  46660. */
  46661. samplingMode: number;
  46662. /**
  46663. * Gets a boolean indicating if the texture needs mipmaps generation
  46664. */
  46665. generateMipMaps: boolean;
  46666. /**
  46667. * Gets the number of samples used by the texture (WebGL2+ only)
  46668. */
  46669. samples: number;
  46670. /**
  46671. * Gets the type of the texture (int, float...)
  46672. */
  46673. type: number;
  46674. /**
  46675. * Gets the format of the texture (RGB, RGBA...)
  46676. */
  46677. format: number;
  46678. /**
  46679. * Observable called when the texture is loaded
  46680. */
  46681. onLoadedObservable: Observable<InternalTexture>;
  46682. /**
  46683. * Gets the width of the texture
  46684. */
  46685. width: number;
  46686. /**
  46687. * Gets the height of the texture
  46688. */
  46689. height: number;
  46690. /**
  46691. * Gets the depth of the texture
  46692. */
  46693. depth: number;
  46694. /**
  46695. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46696. */
  46697. baseWidth: number;
  46698. /**
  46699. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46700. */
  46701. baseHeight: number;
  46702. /**
  46703. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46704. */
  46705. baseDepth: number;
  46706. /**
  46707. * Gets a boolean indicating if the texture is inverted on Y axis
  46708. */
  46709. invertY: boolean;
  46710. /**
  46711. * Gets or set the previous tracker in the list
  46712. */
  46713. previous: Nullable<IInternalTextureTracker>;
  46714. /**
  46715. * Gets or set the next tracker in the list
  46716. */
  46717. next: Nullable<IInternalTextureTracker>;
  46718. /** @hidden */
  46719. _initialSlot: number;
  46720. /** @hidden */
  46721. _designatedSlot: number;
  46722. /** @hidden */
  46723. _dataSource: number;
  46724. /** @hidden */
  46725. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46726. /** @hidden */
  46727. _bufferView: Nullable<ArrayBufferView>;
  46728. /** @hidden */
  46729. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46730. /** @hidden */
  46731. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46732. /** @hidden */
  46733. _size: number;
  46734. /** @hidden */
  46735. _extension: string;
  46736. /** @hidden */
  46737. _files: Nullable<string[]>;
  46738. /** @hidden */
  46739. _workingCanvas: HTMLCanvasElement;
  46740. /** @hidden */
  46741. _workingContext: CanvasRenderingContext2D;
  46742. /** @hidden */
  46743. _framebuffer: Nullable<WebGLFramebuffer>;
  46744. /** @hidden */
  46745. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46746. /** @hidden */
  46747. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46748. /** @hidden */
  46749. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46750. /** @hidden */
  46751. _attachments: Nullable<number[]>;
  46752. /** @hidden */
  46753. _cachedCoordinatesMode: Nullable<number>;
  46754. /** @hidden */
  46755. _cachedWrapU: Nullable<number>;
  46756. /** @hidden */
  46757. _cachedWrapV: Nullable<number>;
  46758. /** @hidden */
  46759. _cachedWrapR: Nullable<number>;
  46760. /** @hidden */
  46761. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46762. /** @hidden */
  46763. _isDisabled: boolean;
  46764. /** @hidden */
  46765. _compression: Nullable<string>;
  46766. /** @hidden */
  46767. _generateStencilBuffer: boolean;
  46768. /** @hidden */
  46769. _generateDepthBuffer: boolean;
  46770. /** @hidden */
  46771. _comparisonFunction: number;
  46772. /** @hidden */
  46773. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46774. /** @hidden */
  46775. _lodGenerationScale: number;
  46776. /** @hidden */
  46777. _lodGenerationOffset: number;
  46778. /** @hidden */
  46779. _lodTextureHigh: BaseTexture;
  46780. /** @hidden */
  46781. _lodTextureMid: BaseTexture;
  46782. /** @hidden */
  46783. _lodTextureLow: BaseTexture;
  46784. /** @hidden */
  46785. _isRGBD: boolean;
  46786. /** @hidden */
  46787. _webGLTexture: Nullable<WebGLTexture>;
  46788. /** @hidden */
  46789. _references: number;
  46790. private _engine;
  46791. /**
  46792. * Gets the Engine the texture belongs to.
  46793. * @returns The babylon engine
  46794. */
  46795. getEngine(): Engine;
  46796. /**
  46797. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46798. */
  46799. readonly dataSource: number;
  46800. /**
  46801. * Creates a new InternalTexture
  46802. * @param engine defines the engine to use
  46803. * @param dataSource defines the type of data that will be used
  46804. * @param delayAllocation if the texture allocation should be delayed (default: false)
  46805. */
  46806. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  46807. /**
  46808. * Increments the number of references (ie. the number of Texture that point to it)
  46809. */
  46810. incrementReferences(): void;
  46811. /**
  46812. * Change the size of the texture (not the size of the content)
  46813. * @param width defines the new width
  46814. * @param height defines the new height
  46815. * @param depth defines the new depth (1 by default)
  46816. */
  46817. updateSize(width: int, height: int, depth?: int): void;
  46818. /** @hidden */
  46819. _rebuild(): void;
  46820. /** @hidden */
  46821. _swapAndDie(target: InternalTexture): void;
  46822. /**
  46823. * Dispose the current allocated resources
  46824. */
  46825. dispose(): void;
  46826. }
  46827. }
  46828. declare module BABYLON {
  46829. /**
  46830. * This represents the required contract to create a new type of texture loader.
  46831. */
  46832. interface IInternalTextureLoader {
  46833. /**
  46834. * Defines wether the loader supports cascade loading the different faces.
  46835. */
  46836. supportCascades: boolean;
  46837. /**
  46838. * This returns if the loader support the current file information.
  46839. * @param extension defines the file extension of the file being loaded
  46840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46841. * @param fallback defines the fallback internal texture if any
  46842. * @param isBase64 defines whether the texture is encoded as a base64
  46843. * @param isBuffer defines whether the texture data are stored as a buffer
  46844. * @returns true if the loader can load the specified file
  46845. */
  46846. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46847. /**
  46848. * Transform the url before loading if required.
  46849. * @param rootUrl the url of the texture
  46850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46851. * @returns the transformed texture
  46852. */
  46853. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46854. /**
  46855. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46856. * @param rootUrl the url of the texture
  46857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46858. * @returns the fallback texture
  46859. */
  46860. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46861. /**
  46862. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46863. * @param data contains the texture data
  46864. * @param texture defines the BabylonJS internal texture
  46865. * @param createPolynomials will be true if polynomials have been requested
  46866. * @param onLoad defines the callback to trigger once the texture is ready
  46867. * @param onError defines the callback to trigger in case of error
  46868. */
  46869. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46870. /**
  46871. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46872. * @param data contains the texture data
  46873. * @param texture defines the BabylonJS internal texture
  46874. * @param callback defines the method to call once ready to upload
  46875. */
  46876. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46877. }
  46878. }
  46879. declare module BABYLON {
  46880. /**
  46881. * Internal interface used to track InternalTexture already bound to the GL context
  46882. */
  46883. interface IInternalTextureTracker {
  46884. /**
  46885. * Gets or set the previous tracker in the list
  46886. */
  46887. previous: Nullable<IInternalTextureTracker>;
  46888. /**
  46889. * Gets or set the next tracker in the list
  46890. */
  46891. next: Nullable<IInternalTextureTracker>;
  46892. }
  46893. /**
  46894. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46895. */
  46896. class DummyInternalTextureTracker {
  46897. /**
  46898. * Gets or set the previous tracker in the list
  46899. */
  46900. previous: Nullable<IInternalTextureTracker>;
  46901. /**
  46902. * Gets or set the next tracker in the list
  46903. */
  46904. next: Nullable<IInternalTextureTracker>;
  46905. }
  46906. }
  46907. declare module BABYLON {
  46908. /**
  46909. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46910. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46911. * You can then easily use it as a reflectionTexture on a flat surface.
  46912. * In case the surface is not a plane, please consider relying on reflection probes.
  46913. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46914. */
  46915. class MirrorTexture extends RenderTargetTexture {
  46916. private scene;
  46917. /**
  46918. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46919. * It is possible to directly set the mirrorPlane by directly using a BABYLON.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.
  46920. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46921. */
  46922. mirrorPlane: Plane;
  46923. /**
  46924. * Define the blur ratio used to blur the reflection if needed.
  46925. */
  46926. blurRatio: number;
  46927. /**
  46928. * Define the adaptive blur kernel used to blur the reflection if needed.
  46929. * This will autocompute the closest best match for the `blurKernel`
  46930. */
  46931. adaptiveBlurKernel: number;
  46932. /**
  46933. * Define the blur kernel used to blur the reflection if needed.
  46934. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46935. */
  46936. blurKernel: number;
  46937. /**
  46938. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46939. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46940. */
  46941. blurKernelX: number;
  46942. /**
  46943. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46944. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46945. */
  46946. blurKernelY: number;
  46947. private _autoComputeBlurKernel;
  46948. protected _onRatioRescale(): void;
  46949. private _updateGammaSpace;
  46950. private _imageProcessingConfigChangeObserver;
  46951. private _transformMatrix;
  46952. private _mirrorMatrix;
  46953. private _savedViewMatrix;
  46954. private _blurX;
  46955. private _blurY;
  46956. private _adaptiveBlurKernel;
  46957. private _blurKernelX;
  46958. private _blurKernelY;
  46959. private _blurRatio;
  46960. /**
  46961. * Instantiates a Mirror Texture.
  46962. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46963. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46964. * You can then easily use it as a reflectionTexture on a flat surface.
  46965. * In case the surface is not a plane, please consider relying on reflection probes.
  46966. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46967. * @param name
  46968. * @param size
  46969. * @param scene
  46970. * @param generateMipMaps
  46971. * @param type
  46972. * @param samplingMode
  46973. * @param generateDepthBuffer
  46974. */
  46975. constructor(name: string, size: number | {
  46976. width: number;
  46977. height: number;
  46978. } | {
  46979. ratio: number;
  46980. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46981. private _preparePostProcesses;
  46982. /**
  46983. * Clone the mirror texture.
  46984. * @returns the cloned texture
  46985. */
  46986. clone(): MirrorTexture;
  46987. /**
  46988. * Serialize the texture to a JSON representation you could use in Parse later on
  46989. * @returns the serialized JSON representation
  46990. */
  46991. serialize(): any;
  46992. /**
  46993. * Dispose the texture and release its associated resources.
  46994. */
  46995. dispose(): void;
  46996. }
  46997. }
  46998. declare module BABYLON {
  46999. /**
  47000. * Creation options of the multi render target texture.
  47001. */
  47002. interface IMultiRenderTargetOptions {
  47003. /**
  47004. * Define if the texture needs to create mip maps after render.
  47005. */
  47006. generateMipMaps?: boolean;
  47007. /**
  47008. * Define the types of all the draw buffers we want to create
  47009. */
  47010. types?: number[];
  47011. /**
  47012. * Define the sampling modes of all the draw buffers we want to create
  47013. */
  47014. samplingModes?: number[];
  47015. /**
  47016. * Define if a depth buffer is required
  47017. */
  47018. generateDepthBuffer?: boolean;
  47019. /**
  47020. * Define if a stencil buffer is required
  47021. */
  47022. generateStencilBuffer?: boolean;
  47023. /**
  47024. * Define if a depth texture is required instead of a depth buffer
  47025. */
  47026. generateDepthTexture?: boolean;
  47027. /**
  47028. * Define the number of desired draw buffers
  47029. */
  47030. textureCount?: number;
  47031. /**
  47032. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47033. */
  47034. doNotChangeAspectRatio?: boolean;
  47035. /**
  47036. * Define the default type of the buffers we are creating
  47037. */
  47038. defaultType?: number;
  47039. }
  47040. /**
  47041. * A multi render target, like a render target provides the ability to render to a texture.
  47042. * Unlike the render target, it can render to several draw buffers in one draw.
  47043. * This is specially interesting in deferred rendering or for any effects requiring more than
  47044. * just one color from a single pass.
  47045. */
  47046. class MultiRenderTarget extends RenderTargetTexture {
  47047. private _internalTextures;
  47048. private _textures;
  47049. private _multiRenderTargetOptions;
  47050. /**
  47051. * Get if draw buffers are currently supported by the used hardware and browser.
  47052. */
  47053. readonly isSupported: boolean;
  47054. /**
  47055. * Get the list of textures generated by the multi render target.
  47056. */
  47057. readonly textures: Texture[];
  47058. /**
  47059. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47060. */
  47061. readonly depthTexture: Texture;
  47062. /**
  47063. * Set the wrapping mode on U of all the textures we are rendering to.
  47064. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47065. */
  47066. wrapU: number;
  47067. /**
  47068. * Set the wrapping mode on V of all the textures we are rendering to.
  47069. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47070. */
  47071. wrapV: number;
  47072. /**
  47073. * Instantiate a new multi render target texture.
  47074. * A multi render target, like a render target provides the ability to render to a texture.
  47075. * Unlike the render target, it can render to several draw buffers in one draw.
  47076. * This is specially interesting in deferred rendering or for any effects requiring more than
  47077. * just one color from a single pass.
  47078. * @param name Define the name of the texture
  47079. * @param size Define the size of the buffers to render to
  47080. * @param count Define the number of target we are rendering into
  47081. * @param scene Define the scene the texture belongs to
  47082. * @param options Define the options used to create the multi render target
  47083. */
  47084. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47085. /** @hidden */
  47086. _rebuild(): void;
  47087. private _createInternalTextures;
  47088. private _createTextures;
  47089. /**
  47090. * Define the number of samples used if MSAA is enabled.
  47091. */
  47092. samples: number;
  47093. /**
  47094. * Resize all the textures in the multi render target.
  47095. * Be carrefull as it will recreate all the data in the new texture.
  47096. * @param size Define the new size
  47097. */
  47098. resize(size: any): void;
  47099. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47100. /**
  47101. * Dispose the render targets and their associated resources
  47102. */
  47103. dispose(): void;
  47104. /**
  47105. * Release all the underlying texture used as draw buffers.
  47106. */
  47107. releaseInternalTextures(): void;
  47108. }
  47109. }
  47110. declare module BABYLON {
  47111. /**
  47112. * Raw cube texture where the raw buffers are passed in
  47113. */
  47114. class RawCubeTexture extends CubeTexture {
  47115. /**
  47116. * Creates a cube texture where the raw buffers are passed in.
  47117. * @param scene defines the scene the texture is attached to
  47118. * @param data defines the array of data to use to create each face
  47119. * @param size defines the size of the textures
  47120. * @param format defines the format of the data
  47121. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47122. * @param generateMipMaps defines if the engine should generate the mip levels
  47123. * @param invertY defines if data must be stored with Y axis inverted
  47124. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47125. * @param compression defines the compression used (null by default)
  47126. */
  47127. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47128. /**
  47129. * Updates the raw cube texture.
  47130. * @param data defines the data to store
  47131. * @param format defines the data format
  47132. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47133. * @param invertY defines if data must be stored with Y axis inverted
  47134. * @param compression defines the compression used (null by default)
  47135. * @param level defines which level of the texture to update
  47136. */
  47137. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47138. /**
  47139. * Updates a raw cube texture with RGBD encoded data.
  47140. * @param data defines the array of data [mipmap][face] to use to create each face
  47141. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47142. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47143. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47144. * @returns a promsie that resolves when the operation is complete
  47145. */
  47146. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47147. /**
  47148. * Clones the raw cube texture.
  47149. * @return a new cube texture
  47150. */
  47151. clone(): CubeTexture;
  47152. /** @hidden */
  47153. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47154. }
  47155. }
  47156. declare module BABYLON {
  47157. /**
  47158. * Raw texture can help creating a texture directly from an array of data.
  47159. * This can be super useful if you either get the data from an uncompressed source or
  47160. * if you wish to create your texture pixel by pixel.
  47161. */
  47162. class RawTexture extends Texture {
  47163. /**
  47164. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47165. */
  47166. format: number;
  47167. private _engine;
  47168. /**
  47169. * Instantiates a new RawTexture.
  47170. * Raw texture can help creating a texture directly from an array of data.
  47171. * This can be super useful if you either get the data from an uncompressed source or
  47172. * if you wish to create your texture pixel by pixel.
  47173. * @param data define the array of data to use to create the texture
  47174. * @param width define the width of the texture
  47175. * @param height define the height of the texture
  47176. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47177. * @param scene define the scene the texture belongs to
  47178. * @param generateMipMaps define whether mip maps should be generated or not
  47179. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47180. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47181. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47182. */
  47183. constructor(data: ArrayBufferView, width: number, height: number,
  47184. /**
  47185. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47186. */
  47187. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47188. /**
  47189. * Updates the texture underlying data.
  47190. * @param data Define the new data of the texture
  47191. */
  47192. update(data: ArrayBufferView): void;
  47193. /**
  47194. * Creates a luminance texture from some data.
  47195. * @param data Define the texture data
  47196. * @param width Define the width of the texture
  47197. * @param height Define the height of the texture
  47198. * @param scene Define the scene the texture belongs to
  47199. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47200. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47201. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47202. * @returns the luminance texture
  47203. */
  47204. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47205. /**
  47206. * Creates a luminance alpha texture from some data.
  47207. * @param data Define the texture data
  47208. * @param width Define the width of the texture
  47209. * @param height Define the height of the texture
  47210. * @param scene Define the scene the texture belongs to
  47211. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47212. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47213. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47214. * @returns the luminance alpha texture
  47215. */
  47216. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47217. /**
  47218. * Creates an alpha texture from some data.
  47219. * @param data Define the texture data
  47220. * @param width Define the width of the texture
  47221. * @param height Define the height of the texture
  47222. * @param scene Define the scene the texture belongs to
  47223. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47224. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47225. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47226. * @returns the alpha texture
  47227. */
  47228. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47229. /**
  47230. * Creates a RGB texture from some data.
  47231. * @param data Define the texture data
  47232. * @param width Define the width of the texture
  47233. * @param height Define the height of the texture
  47234. * @param scene Define the scene the texture belongs to
  47235. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47236. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47237. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47238. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47239. * @returns the RGB alpha texture
  47240. */
  47241. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47242. /**
  47243. * Creates a RGBA texture from some data.
  47244. * @param data Define the texture data
  47245. * @param width Define the width of the texture
  47246. * @param height Define the height of the texture
  47247. * @param scene Define the scene the texture belongs to
  47248. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47249. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47250. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47251. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47252. * @returns the RGBA texture
  47253. */
  47254. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47255. /**
  47256. * Creates a R texture from some data.
  47257. * @param data Define the texture data
  47258. * @param width Define the width of the texture
  47259. * @param height Define the height of the texture
  47260. * @param scene Define the scene the texture belongs to
  47261. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47262. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47263. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47264. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47265. * @returns the R texture
  47266. */
  47267. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47268. }
  47269. }
  47270. declare module BABYLON {
  47271. /**
  47272. * Class used to store 3D textures containing user data
  47273. */
  47274. class RawTexture3D extends Texture {
  47275. /** Gets or sets the texture format to use */
  47276. format: number;
  47277. private _engine;
  47278. /**
  47279. * Create a new RawTexture3D
  47280. * @param data defines the data of the texture
  47281. * @param width defines the width of the texture
  47282. * @param height defines the height of the texture
  47283. * @param depth defines the depth of the texture
  47284. * @param format defines the texture format to use
  47285. * @param scene defines the hosting scene
  47286. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47287. * @param invertY defines if texture must be stored with Y axis inverted
  47288. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47289. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47290. */
  47291. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47292. /** Gets or sets the texture format to use */
  47293. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47294. /**
  47295. * Update the texture with new data
  47296. * @param data defines the data to store in the texture
  47297. */
  47298. update(data: ArrayBufferView): void;
  47299. }
  47300. }
  47301. declare module BABYLON {
  47302. /**
  47303. * Creates a refraction texture used by refraction channel of the standard material.
  47304. * It is like a mirror but to see through a material.
  47305. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47306. */
  47307. class RefractionTexture extends RenderTargetTexture {
  47308. /**
  47309. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47310. * It is possible to directly set the refractionPlane by directly using a BABYLON.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.
  47311. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47312. */
  47313. refractionPlane: Plane;
  47314. /**
  47315. * Define how deep under the surface we should see.
  47316. */
  47317. depth: number;
  47318. /**
  47319. * Creates a refraction texture used by refraction channel of the standard material.
  47320. * It is like a mirror but to see through a material.
  47321. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47322. * @param name Define the texture name
  47323. * @param size Define the size of the underlying texture
  47324. * @param scene Define the scene the refraction belongs to
  47325. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47326. */
  47327. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47328. /**
  47329. * Clone the refraction texture.
  47330. * @returns the cloned texture
  47331. */
  47332. clone(): RefractionTexture;
  47333. /**
  47334. * Serialize the texture to a JSON representation you could use in Parse later on
  47335. * @returns the serialized JSON representation
  47336. */
  47337. serialize(): any;
  47338. }
  47339. }
  47340. declare module BABYLON {
  47341. /**
  47342. * This Helps creating a texture that will be created from a camera in your scene.
  47343. * It is basically a dynamic texture that could be used to create special effects for instance.
  47344. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47345. */
  47346. class RenderTargetTexture extends Texture {
  47347. isCube: boolean;
  47348. /**
  47349. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47350. */
  47351. static readonly REFRESHRATE_RENDER_ONCE: number;
  47352. /**
  47353. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47354. */
  47355. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47356. /**
  47357. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47358. * the central point of your effect and can save a lot of performances.
  47359. */
  47360. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47361. /**
  47362. * Use this predicate to dynamically define the list of mesh you want to render.
  47363. * If set, the renderList property will be overwritten.
  47364. */
  47365. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47366. private _renderList;
  47367. /**
  47368. * Use this list to define the list of mesh you want to render.
  47369. */
  47370. renderList: Nullable<Array<AbstractMesh>>;
  47371. private _hookArray;
  47372. /**
  47373. * Define if particles should be rendered in your texture.
  47374. */
  47375. renderParticles: boolean;
  47376. /**
  47377. * Define if sprites should be rendered in your texture.
  47378. */
  47379. renderSprites: boolean;
  47380. /**
  47381. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47382. */
  47383. coordinatesMode: number;
  47384. /**
  47385. * Define the camera used to render the texture.
  47386. */
  47387. activeCamera: Nullable<Camera>;
  47388. /**
  47389. * Override the render function of the texture with your own one.
  47390. */
  47391. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47392. /**
  47393. * Define if camera post processes should be use while rendering the texture.
  47394. */
  47395. useCameraPostProcesses: boolean;
  47396. /**
  47397. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47398. */
  47399. ignoreCameraViewport: boolean;
  47400. private _postProcessManager;
  47401. private _postProcesses;
  47402. private _resizeObserver;
  47403. /**
  47404. * An event triggered when the texture is unbind.
  47405. */
  47406. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47407. /**
  47408. * An event triggered when the texture is unbind.
  47409. */
  47410. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47411. private _onAfterUnbindObserver;
  47412. /**
  47413. * Set a after unbind callback in the texture.
  47414. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47415. */
  47416. onAfterUnbind: () => void;
  47417. /**
  47418. * An event triggered before rendering the texture
  47419. */
  47420. onBeforeRenderObservable: Observable<number>;
  47421. private _onBeforeRenderObserver;
  47422. /**
  47423. * Set a before render callback in the texture.
  47424. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47425. */
  47426. onBeforeRender: (faceIndex: number) => void;
  47427. /**
  47428. * An event triggered after rendering the texture
  47429. */
  47430. onAfterRenderObservable: Observable<number>;
  47431. private _onAfterRenderObserver;
  47432. /**
  47433. * Set a after render callback in the texture.
  47434. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47435. */
  47436. onAfterRender: (faceIndex: number) => void;
  47437. /**
  47438. * An event triggered after the texture clear
  47439. */
  47440. onClearObservable: Observable<Engine>;
  47441. private _onClearObserver;
  47442. /**
  47443. * Set a clear callback in the texture.
  47444. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47445. */
  47446. onClear: (Engine: Engine) => void;
  47447. /**
  47448. * Define the clear color of the Render Target if it should be different from the scene.
  47449. */
  47450. clearColor: Color4;
  47451. protected _size: number | {
  47452. width: number;
  47453. height: number;
  47454. };
  47455. protected _initialSizeParameter: number | {
  47456. width: number;
  47457. height: number;
  47458. } | {
  47459. ratio: number;
  47460. };
  47461. protected _sizeRatio: Nullable<number>;
  47462. /** @hidden */
  47463. _generateMipMaps: boolean;
  47464. protected _renderingManager: RenderingManager;
  47465. /** @hidden */
  47466. _waitingRenderList: string[];
  47467. protected _doNotChangeAspectRatio: boolean;
  47468. protected _currentRefreshId: number;
  47469. protected _refreshRate: number;
  47470. protected _textureMatrix: Matrix;
  47471. protected _samples: number;
  47472. protected _renderTargetOptions: RenderTargetCreationOptions;
  47473. /**
  47474. * Gets render target creation options that were used.
  47475. */
  47476. readonly renderTargetOptions: RenderTargetCreationOptions;
  47477. protected _engine: Engine;
  47478. protected _onRatioRescale(): void;
  47479. /**
  47480. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47481. * It must define where the camera used to render the texture is set
  47482. */
  47483. boundingBoxPosition: Vector3;
  47484. private _boundingBoxSize;
  47485. /**
  47486. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47487. * When defined, the cubemap will switch to local mode
  47488. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47489. * @example https://www.babylonjs-playground.com/#RNASML
  47490. */
  47491. boundingBoxSize: Vector3;
  47492. /**
  47493. * In case the RTT has been created with a depth texture, get the associated
  47494. * depth texture.
  47495. * Otherwise, return null.
  47496. */
  47497. depthStencilTexture: Nullable<InternalTexture>;
  47498. /**
  47499. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47500. * or used a shadow, depth texture...
  47501. * @param name The friendly name of the texture
  47502. * @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)
  47503. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47504. * @param generateMipMaps True if mip maps need to be generated after render.
  47505. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47506. * @param type The type of the buffer in the RTT (int, half float, float...)
  47507. * @param isCube True if a cube texture needs to be created
  47508. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47509. * @param generateDepthBuffer True to generate a depth buffer
  47510. * @param generateStencilBuffer True to generate a stencil buffer
  47511. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47512. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47513. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47514. */
  47515. constructor(name: string, size: number | {
  47516. width: number;
  47517. height: number;
  47518. } | {
  47519. ratio: number;
  47520. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47521. /**
  47522. * Creates a depth stencil texture.
  47523. * This is only available in WebGL 2 or with the depth texture extension available.
  47524. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47525. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47526. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47527. */
  47528. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47529. private _processSizeParameter;
  47530. /**
  47531. * Define the number of samples to use in case of MSAA.
  47532. * It defaults to one meaning no MSAA has been enabled.
  47533. */
  47534. samples: number;
  47535. /**
  47536. * Resets the refresh counter of the texture and start bak from scratch.
  47537. * Could be usefull to regenerate the texture if it is setup to render only once.
  47538. */
  47539. resetRefreshCounter(): void;
  47540. /**
  47541. * Define the refresh rate of the texture or the rendering frequency.
  47542. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47543. */
  47544. refreshRate: number;
  47545. /**
  47546. * Adds a post process to the render target rendering passes.
  47547. * @param postProcess define the post process to add
  47548. */
  47549. addPostProcess(postProcess: PostProcess): void;
  47550. /**
  47551. * Clear all the post processes attached to the render target
  47552. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47553. */
  47554. clearPostProcesses(dispose?: boolean): void;
  47555. /**
  47556. * Remove one of the post process from the list of attached post processes to the texture
  47557. * @param postProcess define the post process to remove from the list
  47558. */
  47559. removePostProcess(postProcess: PostProcess): void;
  47560. /** @hidden */
  47561. _shouldRender(): boolean;
  47562. /**
  47563. * Gets the actual render size of the texture.
  47564. * @returns the width of the render size
  47565. */
  47566. getRenderSize(): number;
  47567. /**
  47568. * Gets the actual render width of the texture.
  47569. * @returns the width of the render size
  47570. */
  47571. getRenderWidth(): number;
  47572. /**
  47573. * Gets the actual render height of the texture.
  47574. * @returns the height of the render size
  47575. */
  47576. getRenderHeight(): number;
  47577. /**
  47578. * Get if the texture can be rescaled or not.
  47579. */
  47580. readonly canRescale: boolean;
  47581. /**
  47582. * Resize the texture using a ratio.
  47583. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47584. */
  47585. scale(ratio: number): void;
  47586. /**
  47587. * Get the texture reflection matrix used to rotate/transform the reflection.
  47588. * @returns the reflection matrix
  47589. */
  47590. getReflectionTextureMatrix(): Matrix;
  47591. /**
  47592. * Resize the texture to a new desired size.
  47593. * Be carrefull as it will recreate all the data in the new texture.
  47594. * @param size Define the new size. It can be:
  47595. * - a number for squared texture,
  47596. * - an object containing { width: number, height: number }
  47597. * - or an object containing a ratio { ratio: number }
  47598. */
  47599. resize(size: number | {
  47600. width: number;
  47601. height: number;
  47602. } | {
  47603. ratio: number;
  47604. }): void;
  47605. /**
  47606. * Renders all the objects from the render list into the texture.
  47607. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47608. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47609. */
  47610. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47611. private _bestReflectionRenderTargetDimension;
  47612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47613. private renderToTarget;
  47614. /**
  47615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47616. * This allowed control for front to back rendering or reversly depending of the special needs.
  47617. *
  47618. * @param renderingGroupId The rendering group id corresponding to its index
  47619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47622. */
  47623. 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;
  47624. /**
  47625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47626. *
  47627. * @param renderingGroupId The rendering group id corresponding to its index
  47628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47629. */
  47630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47631. /**
  47632. * Clones the texture.
  47633. * @returns the cloned texture
  47634. */
  47635. clone(): RenderTargetTexture;
  47636. /**
  47637. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47638. * @returns The JSON representation of the texture
  47639. */
  47640. serialize(): any;
  47641. /**
  47642. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47643. */
  47644. disposeFramebufferObjects(): void;
  47645. /**
  47646. * Dispose the texture and release its associated resources.
  47647. */
  47648. dispose(): void;
  47649. /** @hidden */
  47650. _rebuild(): void;
  47651. /**
  47652. * Clear the info related to rendering groups preventing retention point in material dispose.
  47653. */
  47654. freeRenderingGroups(): void;
  47655. }
  47656. }
  47657. declare module BABYLON {
  47658. /**
  47659. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47660. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47661. */
  47662. class Texture extends BaseTexture {
  47663. /** nearest is mag = nearest and min = nearest and mip = linear */
  47664. static readonly NEAREST_SAMPLINGMODE: number;
  47665. /** nearest is mag = nearest and min = nearest and mip = linear */
  47666. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47667. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47668. static readonly BILINEAR_SAMPLINGMODE: number;
  47669. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47670. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47671. /** Trilinear is mag = linear and min = linear and mip = linear */
  47672. static readonly TRILINEAR_SAMPLINGMODE: number;
  47673. /** Trilinear is mag = linear and min = linear and mip = linear */
  47674. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47675. /** mag = nearest and min = nearest and mip = nearest */
  47676. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47677. /** mag = nearest and min = linear and mip = nearest */
  47678. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47679. /** mag = nearest and min = linear and mip = linear */
  47680. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47681. /** mag = nearest and min = linear and mip = none */
  47682. static readonly NEAREST_LINEAR: number;
  47683. /** mag = nearest and min = nearest and mip = none */
  47684. static readonly NEAREST_NEAREST: number;
  47685. /** mag = linear and min = nearest and mip = nearest */
  47686. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47687. /** mag = linear and min = nearest and mip = linear */
  47688. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47689. /** mag = linear and min = linear and mip = none */
  47690. static readonly LINEAR_LINEAR: number;
  47691. /** mag = linear and min = nearest and mip = none */
  47692. static readonly LINEAR_NEAREST: number;
  47693. /** Explicit coordinates mode */
  47694. static readonly EXPLICIT_MODE: number;
  47695. /** Spherical coordinates mode */
  47696. static readonly SPHERICAL_MODE: number;
  47697. /** Planar coordinates mode */
  47698. static readonly PLANAR_MODE: number;
  47699. /** Cubic coordinates mode */
  47700. static readonly CUBIC_MODE: number;
  47701. /** Projection coordinates mode */
  47702. static readonly PROJECTION_MODE: number;
  47703. /** Inverse Cubic coordinates mode */
  47704. static readonly SKYBOX_MODE: number;
  47705. /** Inverse Cubic coordinates mode */
  47706. static readonly INVCUBIC_MODE: number;
  47707. /** Equirectangular coordinates mode */
  47708. static readonly EQUIRECTANGULAR_MODE: number;
  47709. /** Equirectangular Fixed coordinates mode */
  47710. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47711. /** Equirectangular Fixed Mirrored coordinates mode */
  47712. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47713. /** Texture is not repeating outside of 0..1 UVs */
  47714. static readonly CLAMP_ADDRESSMODE: number;
  47715. /** Texture is repeating outside of 0..1 UVs */
  47716. static readonly WRAP_ADDRESSMODE: number;
  47717. /** Texture is repeating and mirrored */
  47718. static readonly MIRROR_ADDRESSMODE: number;
  47719. /**
  47720. * 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
  47721. */
  47722. static UseSerializedUrlIfAny: boolean;
  47723. /**
  47724. * Define the url of the texture.
  47725. */
  47726. url: Nullable<string>;
  47727. /**
  47728. * Define an offset on the texture to offset the u coordinates of the UVs
  47729. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47730. */
  47731. uOffset: number;
  47732. /**
  47733. * Define an offset on the texture to offset the v coordinates of the UVs
  47734. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47735. */
  47736. vOffset: number;
  47737. /**
  47738. * Define an offset on the texture to scale the u coordinates of the UVs
  47739. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47740. */
  47741. uScale: number;
  47742. /**
  47743. * Define an offset on the texture to scale the v coordinates of the UVs
  47744. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47745. */
  47746. vScale: number;
  47747. /**
  47748. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47749. * @see http://doc.babylonjs.com/how_to/more_materials
  47750. */
  47751. uAng: number;
  47752. /**
  47753. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47754. * @see http://doc.babylonjs.com/how_to/more_materials
  47755. */
  47756. vAng: number;
  47757. /**
  47758. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47759. * @see http://doc.babylonjs.com/how_to/more_materials
  47760. */
  47761. wAng: number;
  47762. /**
  47763. * Defines the center of rotation (U)
  47764. */
  47765. uRotationCenter: number;
  47766. /**
  47767. * Defines the center of rotation (V)
  47768. */
  47769. vRotationCenter: number;
  47770. /**
  47771. * Defines the center of rotation (W)
  47772. */
  47773. wRotationCenter: number;
  47774. /**
  47775. * Are mip maps generated for this texture or not.
  47776. */
  47777. readonly noMipmap: boolean;
  47778. private _noMipmap;
  47779. /** @hidden */
  47780. _invertY: boolean;
  47781. private _rowGenerationMatrix;
  47782. private _cachedTextureMatrix;
  47783. private _projectionModeMatrix;
  47784. private _t0;
  47785. private _t1;
  47786. private _t2;
  47787. private _cachedUOffset;
  47788. private _cachedVOffset;
  47789. private _cachedUScale;
  47790. private _cachedVScale;
  47791. private _cachedUAng;
  47792. private _cachedVAng;
  47793. private _cachedWAng;
  47794. private _cachedProjectionMatrixId;
  47795. private _cachedCoordinatesMode;
  47796. /** @hidden */
  47797. _samplingMode: number;
  47798. /** @hidden */
  47799. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47800. private _deleteBuffer;
  47801. protected _format: Nullable<number>;
  47802. private _delayedOnLoad;
  47803. private _delayedOnError;
  47804. /**
  47805. * Observable triggered once the texture has been loaded.
  47806. */
  47807. onLoadObservable: Observable<Texture>;
  47808. protected _isBlocking: boolean;
  47809. /**
  47810. * Is the texture preventing material to render while loading.
  47811. * If false, a default texture will be used instead of the loading one during the preparation step.
  47812. */
  47813. isBlocking: boolean;
  47814. /**
  47815. * Get the current sampling mode associated with the texture.
  47816. */
  47817. readonly samplingMode: number;
  47818. /**
  47819. * Instantiates a new texture.
  47820. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47821. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47822. * @param url define the url of the picture to load as a texture
  47823. * @param scene define the scene the texture will belong to
  47824. * @param noMipmap define if the texture will require mip maps or not
  47825. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47826. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47827. * @param onLoad define a callback triggered when the texture has been loaded
  47828. * @param onError define a callback triggered when an error occurred during the loading session
  47829. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47830. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47831. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47832. */
  47833. 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);
  47834. /**
  47835. * Update the url (and optional buffer) of this texture if url was null during construction.
  47836. * @param url the url of the texture
  47837. * @param buffer the buffer of the texture (defaults to null)
  47838. */
  47839. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47840. /**
  47841. * Finish the loading sequence of a texture flagged as delayed load.
  47842. * @hidden
  47843. */
  47844. delayLoad(): void;
  47845. /**
  47846. * Update the sampling mode of the texture.
  47847. * Default is Trilinear mode.
  47848. *
  47849. * | Value | Type | Description |
  47850. * | ----- | ------------------ | ----------- |
  47851. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47852. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47853. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47854. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47855. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47856. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47857. * | 7 | NEAREST_LINEAR | |
  47858. * | 8 | NEAREST_NEAREST | |
  47859. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47860. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47861. * | 11 | LINEAR_LINEAR | |
  47862. * | 12 | LINEAR_NEAREST | |
  47863. *
  47864. * > _mag_: magnification filter (close to the viewer)
  47865. * > _min_: minification filter (far from the viewer)
  47866. * > _mip_: filter used between mip map levels
  47867. *@param samplingMode Define the new sampling mode of the texture
  47868. */
  47869. updateSamplingMode(samplingMode: number): void;
  47870. private _prepareRowForTextureGeneration;
  47871. /**
  47872. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47873. * @returns the transform matrix of the texture.
  47874. */
  47875. getTextureMatrix(): Matrix;
  47876. /**
  47877. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47878. * @returns The reflection texture transform
  47879. */
  47880. getReflectionTextureMatrix(): Matrix;
  47881. /**
  47882. * Clones the texture.
  47883. * @returns the cloned texture
  47884. */
  47885. clone(): Texture;
  47886. /**
  47887. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47888. * @returns The JSON representation of the texture
  47889. */
  47890. serialize(): any;
  47891. /**
  47892. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47893. * @returns "Texture"
  47894. */
  47895. getClassName(): string;
  47896. /**
  47897. * Dispose the texture and release its associated resources.
  47898. */
  47899. dispose(): void;
  47900. /**
  47901. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47902. * @param parsedTexture Define the JSON representation of the texture
  47903. * @param scene Define the scene the parsed texture should be instantiated in
  47904. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47905. * @returns The parsed texture if successful
  47906. */
  47907. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47908. /**
  47909. * Creates a texture from its base 64 representation.
  47910. * @param data Define the base64 payload without the data: prefix
  47911. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47912. * @param scene Define the scene the texture should belong to
  47913. * @param noMipmap Forces the texture to not create mip map information if true
  47914. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47915. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47916. * @param onLoad define a callback triggered when the texture has been loaded
  47917. * @param onError define a callback triggered when an error occurred during the loading session
  47918. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47919. * @returns the created texture
  47920. */
  47921. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47922. /**
  47923. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47924. * @param data Define the base64 payload without the data: prefix
  47925. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47926. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47927. * @param scene Define the scene the texture should belong to
  47928. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47929. * @param noMipmap Forces the texture to not create mip map information if true
  47930. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47931. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47932. * @param onLoad define a callback triggered when the texture has been loaded
  47933. * @param onError define a callback triggered when an error occurred during the loading session
  47934. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47935. * @returns the created texture
  47936. */
  47937. 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;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. /**
  47942. * Settings for finer control over video usage
  47943. */
  47944. interface VideoTextureSettings {
  47945. /**
  47946. * Applies `autoplay` to video, if specified
  47947. */
  47948. autoPlay?: boolean;
  47949. /**
  47950. * Applies `loop` to video, if specified
  47951. */
  47952. loop?: boolean;
  47953. /**
  47954. * Automatically updates internal texture from video at every frame in the render loop
  47955. */
  47956. autoUpdateTexture: boolean;
  47957. /**
  47958. * Image src displayed during the video loading or until the user interacts with the video.
  47959. */
  47960. poster?: string;
  47961. }
  47962. /**
  47963. * If you want to display a video in your scene, this is the special texture for that.
  47964. * This special texture works similar to other textures, with the exception of a few parameters.
  47965. * @see https://doc.babylonjs.com/how_to/video_texture
  47966. */
  47967. class VideoTexture extends Texture {
  47968. /**
  47969. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47970. */
  47971. readonly autoUpdateTexture: boolean;
  47972. /**
  47973. * The video instance used by the texture internally
  47974. */
  47975. readonly video: HTMLVideoElement;
  47976. private _onUserActionRequestedObservable;
  47977. /**
  47978. * Event triggerd when a dom action is required by the user to play the video.
  47979. * This happens due to recent changes in browser policies preventing video to auto start.
  47980. */
  47981. readonly onUserActionRequestedObservable: Observable<Texture>;
  47982. private _generateMipMaps;
  47983. private _engine;
  47984. private _stillImageCaptured;
  47985. private _poster;
  47986. /**
  47987. * Creates a video texture.
  47988. * If you want to display a video in your scene, this is the special texture for that.
  47989. * This special texture works similar to other textures, with the exception of a few parameters.
  47990. * @see https://doc.babylonjs.com/how_to/video_texture
  47991. * @param name optional name, will detect from video source, if not defined
  47992. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47993. * @param scene is obviously the current scene.
  47994. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47995. * @param invertY is false by default but can be used to invert video on Y axis
  47996. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47997. * @param settings allows finer control over video usage
  47998. */
  47999. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48000. private _getName;
  48001. private _getVideo;
  48002. private _createInternalTexture;
  48003. private reset;
  48004. /**
  48005. * @hidden Internal method to initiate `update`.
  48006. */
  48007. _rebuild(): void;
  48008. /**
  48009. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48010. */
  48011. update(): void;
  48012. /**
  48013. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48014. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48015. */
  48016. updateTexture(isVisible: boolean): void;
  48017. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48018. /**
  48019. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48020. * @param url New url.
  48021. */
  48022. updateURL(url: string): void;
  48023. /**
  48024. * Dispose the texture and release its associated resources.
  48025. */
  48026. dispose(): void;
  48027. /**
  48028. * Creates a video texture straight from your WebCam video feed.
  48029. * @param scene Define the scene the texture should be created in
  48030. * @param onReady Define a callback to triggered once the texture will be ready
  48031. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48032. */
  48033. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48034. minWidth: number;
  48035. maxWidth: number;
  48036. minHeight: number;
  48037. maxHeight: number;
  48038. deviceId: string;
  48039. }): void;
  48040. }
  48041. }
  48042. declare var DracoDecoderModule: any;
  48043. declare var WebAssembly: any;
  48044. declare module BABYLON {
  48045. /**
  48046. * Configuration for Draco compression
  48047. */
  48048. interface IDracoCompressionConfiguration {
  48049. /**
  48050. * Configuration for the decoder.
  48051. */
  48052. decoder?: {
  48053. /**
  48054. * The url to the WebAssembly module.
  48055. */
  48056. wasmUrl?: string;
  48057. /**
  48058. * The url to the WebAssembly binary.
  48059. */
  48060. wasmBinaryUrl?: string;
  48061. /**
  48062. * The url to the fallback JavaScript module.
  48063. */
  48064. fallbackUrl?: string;
  48065. };
  48066. }
  48067. /**
  48068. * Draco compression (https://google.github.io/draco/)
  48069. *
  48070. * This class wraps the Draco module.
  48071. *
  48072. * **Encoder**
  48073. *
  48074. * The encoder is not currently implemented.
  48075. *
  48076. * **Decoder**
  48077. *
  48078. * 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.
  48079. *
  48080. * To update the configuration, use the following code:
  48081. * ```javascript
  48082. * BABYLON.DracoCompression.Configuration = {
  48083. * decoder: {
  48084. * wasmUrl: "<url to the WebAssembly library>",
  48085. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48086. * fallbackUrl: "<url to the fallback JavaScript library>",
  48087. * }
  48088. * };
  48089. * ```
  48090. *
  48091. * 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.
  48092. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48093. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48094. *
  48095. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48096. * ```javascript
  48097. * var dracoCompression = new BABYLON.DracoCompression();
  48098. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48099. * [BABYLON.VertexBuffer.PositionKind]: 0
  48100. * });
  48101. * ```
  48102. *
  48103. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48104. */
  48105. class DracoCompression implements IDisposable {
  48106. private static _DecoderModulePromise;
  48107. /**
  48108. * The configuration. Defaults to the following urls:
  48109. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48110. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48111. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48112. */
  48113. static Configuration: IDracoCompressionConfiguration;
  48114. /**
  48115. * Returns true if the decoder is available.
  48116. */
  48117. static readonly DecoderAvailable: boolean;
  48118. /**
  48119. * Constructor
  48120. */
  48121. constructor();
  48122. /**
  48123. * Stop all async operations and release resources.
  48124. */
  48125. dispose(): void;
  48126. /**
  48127. * Decode Draco compressed mesh data to vertex data.
  48128. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48129. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48130. * @returns A promise that resolves with the decoded vertex data
  48131. */
  48132. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48133. [kind: string]: number;
  48134. }): Promise<VertexData>;
  48135. private static _GetDecoderModule;
  48136. private static _LoadScriptAsync;
  48137. private static _LoadFileAsync;
  48138. }
  48139. }
  48140. declare module BABYLON {
  48141. /**
  48142. * Particle emitter emitting particles from the inside of a box.
  48143. * It emits the particles randomly between 2 given directions.
  48144. */
  48145. class BoxParticleEmitter implements IParticleEmitterType {
  48146. /**
  48147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48148. */
  48149. direction1: Vector3;
  48150. /**
  48151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48152. */
  48153. direction2: Vector3;
  48154. /**
  48155. * 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.
  48156. */
  48157. minEmitBox: Vector3;
  48158. /**
  48159. * 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.
  48160. */
  48161. maxEmitBox: Vector3;
  48162. /**
  48163. * Creates a new instance BoxParticleEmitter
  48164. */
  48165. constructor();
  48166. /**
  48167. * Called by the particle System when the direction is computed for the created particle.
  48168. * @param worldMatrix is the world matrix of the particle system
  48169. * @param directionToUpdate is the direction vector to update with the result
  48170. * @param particle is the particle we are computed the direction for
  48171. */
  48172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48173. /**
  48174. * Called by the particle System when the position is computed for the created particle.
  48175. * @param worldMatrix is the world matrix of the particle system
  48176. * @param positionToUpdate is the position vector to update with the result
  48177. * @param particle is the particle we are computed the position for
  48178. */
  48179. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48180. /**
  48181. * Clones the current emitter and returns a copy of it
  48182. * @returns the new emitter
  48183. */
  48184. clone(): BoxParticleEmitter;
  48185. /**
  48186. * Called by the GPUParticleSystem to setup the update shader
  48187. * @param effect defines the update shader
  48188. */
  48189. applyToShader(effect: Effect): void;
  48190. /**
  48191. * Returns a string to use to update the GPU particles update shader
  48192. * @returns a string containng the defines string
  48193. */
  48194. getEffectDefines(): string;
  48195. /**
  48196. * Returns the string "BoxParticleEmitter"
  48197. * @returns a string containing the class name
  48198. */
  48199. getClassName(): string;
  48200. /**
  48201. * Serializes the particle system to a JSON object.
  48202. * @returns the JSON object
  48203. */
  48204. serialize(): any;
  48205. /**
  48206. * Parse properties from a JSON object
  48207. * @param serializationObject defines the JSON object
  48208. */
  48209. parse(serializationObject: any): void;
  48210. }
  48211. }
  48212. declare module BABYLON {
  48213. /**
  48214. * Particle emitter emitting particles from the inside of a cone.
  48215. * It emits the particles alongside the cone volume from the base to the particle.
  48216. * The emission direction might be randomized.
  48217. */
  48218. class ConeParticleEmitter implements IParticleEmitterType {
  48219. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48220. directionRandomizer: number;
  48221. private _radius;
  48222. private _angle;
  48223. private _height;
  48224. /**
  48225. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48226. */
  48227. radiusRange: number;
  48228. /**
  48229. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48230. */
  48231. heightRange: number;
  48232. /**
  48233. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48234. */
  48235. emitFromSpawnPointOnly: boolean;
  48236. /**
  48237. * Gets or sets the radius of the emission cone
  48238. */
  48239. radius: number;
  48240. /**
  48241. * Gets or sets the angle of the emission cone
  48242. */
  48243. angle: number;
  48244. private _buildHeight;
  48245. /**
  48246. * Creates a new instance ConeParticleEmitter
  48247. * @param radius the radius of the emission cone (1 by default)
  48248. * @param angles the cone base angle (PI by default)
  48249. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48250. */
  48251. constructor(radius?: number, angle?: number,
  48252. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48253. directionRandomizer?: number);
  48254. /**
  48255. * Called by the particle System when the direction is computed for the created particle.
  48256. * @param worldMatrix is the world matrix of the particle system
  48257. * @param directionToUpdate is the direction vector to update with the result
  48258. * @param particle is the particle we are computed the direction for
  48259. */
  48260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48261. /**
  48262. * Called by the particle System when the position is computed for the created particle.
  48263. * @param worldMatrix is the world matrix of the particle system
  48264. * @param positionToUpdate is the position vector to update with the result
  48265. * @param particle is the particle we are computed the position for
  48266. */
  48267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48268. /**
  48269. * Clones the current emitter and returns a copy of it
  48270. * @returns the new emitter
  48271. */
  48272. clone(): ConeParticleEmitter;
  48273. /**
  48274. * Called by the GPUParticleSystem to setup the update shader
  48275. * @param effect defines the update shader
  48276. */
  48277. applyToShader(effect: Effect): void;
  48278. /**
  48279. * Returns a string to use to update the GPU particles update shader
  48280. * @returns a string containng the defines string
  48281. */
  48282. getEffectDefines(): string;
  48283. /**
  48284. * Returns the string "ConeParticleEmitter"
  48285. * @returns a string containing the class name
  48286. */
  48287. getClassName(): string;
  48288. /**
  48289. * Serializes the particle system to a JSON object.
  48290. * @returns the JSON object
  48291. */
  48292. serialize(): any;
  48293. /**
  48294. * Parse properties from a JSON object
  48295. * @param serializationObject defines the JSON object
  48296. */
  48297. parse(serializationObject: any): void;
  48298. }
  48299. }
  48300. declare module BABYLON {
  48301. /**
  48302. * Particle emitter emitting particles from the inside of a cylinder.
  48303. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48304. */
  48305. class CylinderParticleEmitter implements IParticleEmitterType {
  48306. /**
  48307. * The radius of the emission cylinder.
  48308. */
  48309. radius: number;
  48310. /**
  48311. * The height of the emission cylinder.
  48312. */
  48313. height: number;
  48314. /**
  48315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48316. */
  48317. radiusRange: number;
  48318. /**
  48319. * How much to randomize the particle direction [0-1].
  48320. */
  48321. directionRandomizer: number;
  48322. /**
  48323. * Creates a new instance CylinderParticleEmitter
  48324. * @param radius the radius of the emission cylinder (1 by default)
  48325. * @param height the height of the emission cylinder (1 by default)
  48326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48327. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48328. */
  48329. constructor(
  48330. /**
  48331. * The radius of the emission cylinder.
  48332. */
  48333. radius?: number,
  48334. /**
  48335. * The height of the emission cylinder.
  48336. */
  48337. height?: number,
  48338. /**
  48339. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48340. */
  48341. radiusRange?: number,
  48342. /**
  48343. * How much to randomize the particle direction [0-1].
  48344. */
  48345. directionRandomizer?: number);
  48346. /**
  48347. * Called by the particle System when the direction is computed for the created particle.
  48348. * @param worldMatrix is the world matrix of the particle system
  48349. * @param directionToUpdate is the direction vector to update with the result
  48350. * @param particle is the particle we are computed the direction for
  48351. */
  48352. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48353. /**
  48354. * Called by the particle System when the position is computed for the created particle.
  48355. * @param worldMatrix is the world matrix of the particle system
  48356. * @param positionToUpdate is the position vector to update with the result
  48357. * @param particle is the particle we are computed the position for
  48358. */
  48359. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48360. /**
  48361. * Clones the current emitter and returns a copy of it
  48362. * @returns the new emitter
  48363. */
  48364. clone(): CylinderParticleEmitter;
  48365. /**
  48366. * Called by the GPUParticleSystem to setup the update shader
  48367. * @param effect defines the update shader
  48368. */
  48369. applyToShader(effect: Effect): void;
  48370. /**
  48371. * Returns a string to use to update the GPU particles update shader
  48372. * @returns a string containng the defines string
  48373. */
  48374. getEffectDefines(): string;
  48375. /**
  48376. * Returns the string "CylinderParticleEmitter"
  48377. * @returns a string containing the class name
  48378. */
  48379. getClassName(): string;
  48380. /**
  48381. * Serializes the particle system to a JSON object.
  48382. * @returns the JSON object
  48383. */
  48384. serialize(): any;
  48385. /**
  48386. * Parse properties from a JSON object
  48387. * @param serializationObject defines the JSON object
  48388. */
  48389. parse(serializationObject: any): void;
  48390. }
  48391. /**
  48392. * Particle emitter emitting particles from the inside of a cylinder.
  48393. * It emits the particles randomly between two vectors.
  48394. */
  48395. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48396. /**
  48397. * The min limit of the emission direction.
  48398. */
  48399. direction1: Vector3;
  48400. /**
  48401. * The max limit of the emission direction.
  48402. */
  48403. direction2: Vector3;
  48404. /**
  48405. * Creates a new instance CylinderDirectedParticleEmitter
  48406. * @param radius the radius of the emission cylinder (1 by default)
  48407. * @param height the height of the emission cylinder (1 by default)
  48408. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48409. * @param direction1 the min limit of the emission direction (up vector by default)
  48410. * @param direction2 the max limit of the emission direction (up vector by default)
  48411. */
  48412. constructor(radius?: number, height?: number, radiusRange?: number,
  48413. /**
  48414. * The min limit of the emission direction.
  48415. */
  48416. direction1?: Vector3,
  48417. /**
  48418. * The max limit of the emission direction.
  48419. */
  48420. direction2?: Vector3);
  48421. /**
  48422. * Called by the particle System when the direction is computed for the created particle.
  48423. * @param worldMatrix is the world matrix of the particle system
  48424. * @param directionToUpdate is the direction vector to update with the result
  48425. * @param particle is the particle we are computed the direction for
  48426. */
  48427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48428. /**
  48429. * Clones the current emitter and returns a copy of it
  48430. * @returns the new emitter
  48431. */
  48432. clone(): CylinderDirectedParticleEmitter;
  48433. /**
  48434. * Called by the GPUParticleSystem to setup the update shader
  48435. * @param effect defines the update shader
  48436. */
  48437. applyToShader(effect: Effect): void;
  48438. /**
  48439. * Returns a string to use to update the GPU particles update shader
  48440. * @returns a string containng the defines string
  48441. */
  48442. getEffectDefines(): string;
  48443. /**
  48444. * Returns the string "CylinderDirectedParticleEmitter"
  48445. * @returns a string containing the class name
  48446. */
  48447. getClassName(): string;
  48448. /**
  48449. * Serializes the particle system to a JSON object.
  48450. * @returns the JSON object
  48451. */
  48452. serialize(): any;
  48453. /**
  48454. * Parse properties from a JSON object
  48455. * @param serializationObject defines the JSON object
  48456. */
  48457. parse(serializationObject: any): void;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Particle emitter emitting particles from the inside of a hemisphere.
  48463. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48464. */
  48465. class HemisphericParticleEmitter implements IParticleEmitterType {
  48466. /**
  48467. * The radius of the emission hemisphere.
  48468. */
  48469. radius: number;
  48470. /**
  48471. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48472. */
  48473. radiusRange: number;
  48474. /**
  48475. * How much to randomize the particle direction [0-1].
  48476. */
  48477. directionRandomizer: number;
  48478. /**
  48479. * Creates a new instance HemisphericParticleEmitter
  48480. * @param radius the radius of the emission hemisphere (1 by default)
  48481. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48482. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48483. */
  48484. constructor(
  48485. /**
  48486. * The radius of the emission hemisphere.
  48487. */
  48488. radius?: number,
  48489. /**
  48490. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48491. */
  48492. radiusRange?: number,
  48493. /**
  48494. * How much to randomize the particle direction [0-1].
  48495. */
  48496. directionRandomizer?: number);
  48497. /**
  48498. * Called by the particle System when the direction is computed for the created particle.
  48499. * @param worldMatrix is the world matrix of the particle system
  48500. * @param directionToUpdate is the direction vector to update with the result
  48501. * @param particle is the particle we are computed the direction for
  48502. */
  48503. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48504. /**
  48505. * Called by the particle System when the position is computed for the created particle.
  48506. * @param worldMatrix is the world matrix of the particle system
  48507. * @param positionToUpdate is the position vector to update with the result
  48508. * @param particle is the particle we are computed the position for
  48509. */
  48510. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48511. /**
  48512. * Clones the current emitter and returns a copy of it
  48513. * @returns the new emitter
  48514. */
  48515. clone(): HemisphericParticleEmitter;
  48516. /**
  48517. * Called by the GPUParticleSystem to setup the update shader
  48518. * @param effect defines the update shader
  48519. */
  48520. applyToShader(effect: Effect): void;
  48521. /**
  48522. * Returns a string to use to update the GPU particles update shader
  48523. * @returns a string containng the defines string
  48524. */
  48525. getEffectDefines(): string;
  48526. /**
  48527. * Returns the string "HemisphericParticleEmitter"
  48528. * @returns a string containing the class name
  48529. */
  48530. getClassName(): string;
  48531. /**
  48532. * Serializes the particle system to a JSON object.
  48533. * @returns the JSON object
  48534. */
  48535. serialize(): any;
  48536. /**
  48537. * Parse properties from a JSON object
  48538. * @param serializationObject defines the JSON object
  48539. */
  48540. parse(serializationObject: any): void;
  48541. }
  48542. }
  48543. declare module BABYLON {
  48544. /**
  48545. * Particle emitter represents a volume emitting particles.
  48546. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48547. */
  48548. interface IParticleEmitterType {
  48549. /**
  48550. * Called by the particle System when the direction is computed for the created particle.
  48551. * @param worldMatrix is the world matrix of the particle system
  48552. * @param directionToUpdate is the direction vector to update with the result
  48553. * @param particle is the particle we are computed the direction for
  48554. */
  48555. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48556. /**
  48557. * Called by the particle System when the position is computed for the created particle.
  48558. * @param worldMatrix is the world matrix of the particle system
  48559. * @param positionToUpdate is the position vector to update with the result
  48560. * @param particle is the particle we are computed the position for
  48561. */
  48562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48563. /**
  48564. * Clones the current emitter and returns a copy of it
  48565. * @returns the new emitter
  48566. */
  48567. clone(): IParticleEmitterType;
  48568. /**
  48569. * Called by the GPUParticleSystem to setup the update shader
  48570. * @param effect defines the update shader
  48571. */
  48572. applyToShader(effect: Effect): void;
  48573. /**
  48574. * Returns a string to use to update the GPU particles update shader
  48575. * @returns the effect defines string
  48576. */
  48577. getEffectDefines(): string;
  48578. /**
  48579. * Returns a string representing the class name
  48580. * @returns a string containing the class name
  48581. */
  48582. getClassName(): string;
  48583. /**
  48584. * Serializes the particle system to a JSON object.
  48585. * @returns the JSON object
  48586. */
  48587. serialize(): any;
  48588. /**
  48589. * Parse properties from a JSON object
  48590. * @param serializationObject defines the JSON object
  48591. */
  48592. parse(serializationObject: any): void;
  48593. }
  48594. }
  48595. declare module BABYLON {
  48596. /**
  48597. * Particle emitter emitting particles from a point.
  48598. * It emits the particles randomly between 2 given directions.
  48599. */
  48600. class PointParticleEmitter implements IParticleEmitterType {
  48601. /**
  48602. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48603. */
  48604. direction1: Vector3;
  48605. /**
  48606. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48607. */
  48608. direction2: Vector3;
  48609. /**
  48610. * Creates a new instance PointParticleEmitter
  48611. */
  48612. constructor();
  48613. /**
  48614. * Called by the particle System when the direction is computed for the created particle.
  48615. * @param worldMatrix is the world matrix of the particle system
  48616. * @param directionToUpdate is the direction vector to update with the result
  48617. * @param particle is the particle we are computed the direction for
  48618. */
  48619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48620. /**
  48621. * Called by the particle System when the position is computed for the created particle.
  48622. * @param worldMatrix is the world matrix of the particle system
  48623. * @param positionToUpdate is the position vector to update with the result
  48624. * @param particle is the particle we are computed the position for
  48625. */
  48626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48627. /**
  48628. * Clones the current emitter and returns a copy of it
  48629. * @returns the new emitter
  48630. */
  48631. clone(): PointParticleEmitter;
  48632. /**
  48633. * Called by the GPUParticleSystem to setup the update shader
  48634. * @param effect defines the update shader
  48635. */
  48636. applyToShader(effect: Effect): void;
  48637. /**
  48638. * Returns a string to use to update the GPU particles update shader
  48639. * @returns a string containng the defines string
  48640. */
  48641. getEffectDefines(): string;
  48642. /**
  48643. * Returns the string "PointParticleEmitter"
  48644. * @returns a string containing the class name
  48645. */
  48646. getClassName(): string;
  48647. /**
  48648. * Serializes the particle system to a JSON object.
  48649. * @returns the JSON object
  48650. */
  48651. serialize(): any;
  48652. /**
  48653. * Parse properties from a JSON object
  48654. * @param serializationObject defines the JSON object
  48655. */
  48656. parse(serializationObject: any): void;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * Particle emitter emitting particles from the inside of a sphere.
  48662. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48663. */
  48664. class SphereParticleEmitter implements IParticleEmitterType {
  48665. /**
  48666. * The radius of the emission sphere.
  48667. */
  48668. radius: number;
  48669. /**
  48670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48671. */
  48672. radiusRange: number;
  48673. /**
  48674. * How much to randomize the particle direction [0-1].
  48675. */
  48676. directionRandomizer: number;
  48677. /**
  48678. * Creates a new instance SphereParticleEmitter
  48679. * @param radius the radius of the emission sphere (1 by default)
  48680. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48681. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48682. */
  48683. constructor(
  48684. /**
  48685. * The radius of the emission sphere.
  48686. */
  48687. radius?: number,
  48688. /**
  48689. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48690. */
  48691. radiusRange?: number,
  48692. /**
  48693. * How much to randomize the particle direction [0-1].
  48694. */
  48695. directionRandomizer?: number);
  48696. /**
  48697. * Called by the particle System when the direction is computed for the created particle.
  48698. * @param worldMatrix is the world matrix of the particle system
  48699. * @param directionToUpdate is the direction vector to update with the result
  48700. * @param particle is the particle we are computed the direction for
  48701. */
  48702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48703. /**
  48704. * Called by the particle System when the position is computed for the created particle.
  48705. * @param worldMatrix is the world matrix of the particle system
  48706. * @param positionToUpdate is the position vector to update with the result
  48707. * @param particle is the particle we are computed the position for
  48708. */
  48709. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48710. /**
  48711. * Clones the current emitter and returns a copy of it
  48712. * @returns the new emitter
  48713. */
  48714. clone(): SphereParticleEmitter;
  48715. /**
  48716. * Called by the GPUParticleSystem to setup the update shader
  48717. * @param effect defines the update shader
  48718. */
  48719. applyToShader(effect: Effect): void;
  48720. /**
  48721. * Returns a string to use to update the GPU particles update shader
  48722. * @returns a string containng the defines string
  48723. */
  48724. getEffectDefines(): string;
  48725. /**
  48726. * Returns the string "SphereParticleEmitter"
  48727. * @returns a string containing the class name
  48728. */
  48729. getClassName(): string;
  48730. /**
  48731. * Serializes the particle system to a JSON object.
  48732. * @returns the JSON object
  48733. */
  48734. serialize(): any;
  48735. /**
  48736. * Parse properties from a JSON object
  48737. * @param serializationObject defines the JSON object
  48738. */
  48739. parse(serializationObject: any): void;
  48740. }
  48741. /**
  48742. * Particle emitter emitting particles from the inside of a sphere.
  48743. * It emits the particles randomly between two vectors.
  48744. */
  48745. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48746. /**
  48747. * The min limit of the emission direction.
  48748. */
  48749. direction1: Vector3;
  48750. /**
  48751. * The max limit of the emission direction.
  48752. */
  48753. direction2: Vector3;
  48754. /**
  48755. * Creates a new instance SphereDirectedParticleEmitter
  48756. * @param radius the radius of the emission sphere (1 by default)
  48757. * @param direction1 the min limit of the emission direction (up vector by default)
  48758. * @param direction2 the max limit of the emission direction (up vector by default)
  48759. */
  48760. constructor(radius?: number,
  48761. /**
  48762. * The min limit of the emission direction.
  48763. */
  48764. direction1?: Vector3,
  48765. /**
  48766. * The max limit of the emission direction.
  48767. */
  48768. direction2?: Vector3);
  48769. /**
  48770. * Called by the particle System when the direction is computed for the created particle.
  48771. * @param worldMatrix is the world matrix of the particle system
  48772. * @param directionToUpdate is the direction vector to update with the result
  48773. * @param particle is the particle we are computed the direction for
  48774. */
  48775. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48776. /**
  48777. * Clones the current emitter and returns a copy of it
  48778. * @returns the new emitter
  48779. */
  48780. clone(): SphereDirectedParticleEmitter;
  48781. /**
  48782. * Called by the GPUParticleSystem to setup the update shader
  48783. * @param effect defines the update shader
  48784. */
  48785. applyToShader(effect: Effect): void;
  48786. /**
  48787. * Returns a string to use to update the GPU particles update shader
  48788. * @returns a string containng the defines string
  48789. */
  48790. getEffectDefines(): string;
  48791. /**
  48792. * Returns the string "SphereDirectedParticleEmitter"
  48793. * @returns a string containing the class name
  48794. */
  48795. getClassName(): string;
  48796. /**
  48797. * Serializes the particle system to a JSON object.
  48798. * @returns the JSON object
  48799. */
  48800. serialize(): any;
  48801. /**
  48802. * Parse properties from a JSON object
  48803. * @param serializationObject defines the JSON object
  48804. */
  48805. parse(serializationObject: any): void;
  48806. }
  48807. }
  48808. declare module BABYLON {
  48809. /** @hidden */
  48810. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48811. private _useDeltaForWorldStep;
  48812. world: any;
  48813. name: string;
  48814. private _physicsMaterials;
  48815. private _fixedTimeStep;
  48816. BJSCANNON: any;
  48817. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48818. setGravity(gravity: Vector3): void;
  48819. setTimeStep(timeStep: number): void;
  48820. getTimeStep(): number;
  48821. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48822. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48823. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48824. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48825. private _processChildMeshes;
  48826. removePhysicsBody(impostor: PhysicsImpostor): void;
  48827. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48828. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48829. private _addMaterial;
  48830. private _checkWithEpsilon;
  48831. private _createShape;
  48832. private _createHeightmap;
  48833. private _minus90X;
  48834. private _plus90X;
  48835. private _tmpPosition;
  48836. private _tmpDeltaPosition;
  48837. private _tmpUnityRotation;
  48838. private _updatePhysicsBodyTransformation;
  48839. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48840. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48841. isSupported(): boolean;
  48842. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48843. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48844. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48845. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48846. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48847. getBodyMass(impostor: PhysicsImpostor): number;
  48848. getBodyFriction(impostor: PhysicsImpostor): number;
  48849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48850. getBodyRestitution(impostor: PhysicsImpostor): number;
  48851. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48852. sleepBody(impostor: PhysicsImpostor): void;
  48853. wakeUpBody(impostor: PhysicsImpostor): void;
  48854. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48855. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48856. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48858. getRadius(impostor: PhysicsImpostor): number;
  48859. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48860. dispose(): void;
  48861. private _extendNamespace;
  48862. }
  48863. }
  48864. declare module BABYLON {
  48865. /** @hidden */
  48866. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48867. world: any;
  48868. name: string;
  48869. BJSOIMO: any;
  48870. constructor(iterations?: number);
  48871. setGravity(gravity: Vector3): void;
  48872. setTimeStep(timeStep: number): void;
  48873. getTimeStep(): number;
  48874. private _tmpImpostorsArray;
  48875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48879. private _tmpPositionVector;
  48880. removePhysicsBody(impostor: PhysicsImpostor): void;
  48881. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48882. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48883. isSupported(): boolean;
  48884. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48885. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48886. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48887. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48888. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48889. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48890. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48891. getBodyMass(impostor: PhysicsImpostor): number;
  48892. getBodyFriction(impostor: PhysicsImpostor): number;
  48893. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48894. getBodyRestitution(impostor: PhysicsImpostor): number;
  48895. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48896. sleepBody(impostor: PhysicsImpostor): void;
  48897. wakeUpBody(impostor: PhysicsImpostor): void;
  48898. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48899. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48900. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48901. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48902. getRadius(impostor: PhysicsImpostor): number;
  48903. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48904. dispose(): void;
  48905. }
  48906. }
  48907. declare module BABYLON {
  48908. /**
  48909. * This represents a set of one or more post processes in Babylon.
  48910. * A post process can be used to apply a shader to a texture after it is rendered.
  48911. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48912. */
  48913. class PostProcessRenderEffect {
  48914. private _postProcesses;
  48915. private _getPostProcesses;
  48916. private _singleInstance;
  48917. private _cameras;
  48918. private _indicesForCamera;
  48919. /**
  48920. * Name of the effect
  48921. * @hidden
  48922. */
  48923. _name: string;
  48924. /**
  48925. * Instantiates a post process render effect.
  48926. * A post process can be used to apply a shader to a texture after it is rendered.
  48927. * @param engine The engine the effect is tied to
  48928. * @param name The name of the effect
  48929. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48930. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48931. */
  48932. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48933. /**
  48934. * Checks if all the post processes in the effect are supported.
  48935. */
  48936. readonly isSupported: boolean;
  48937. /**
  48938. * Updates the current state of the effect
  48939. * @hidden
  48940. */
  48941. _update(): void;
  48942. /**
  48943. * Attaches the effect on cameras
  48944. * @param cameras The camera to attach to.
  48945. * @hidden
  48946. */
  48947. _attachCameras(cameras: Camera): void;
  48948. /**
  48949. * Attaches the effect on cameras
  48950. * @param cameras The camera to attach to.
  48951. * @hidden
  48952. */
  48953. _attachCameras(cameras: Camera[]): void;
  48954. /**
  48955. * Detatches the effect on cameras
  48956. * @param cameras The camera to detatch from.
  48957. * @hidden
  48958. */
  48959. _detachCameras(cameras: Camera): void;
  48960. /**
  48961. * Detatches the effect on cameras
  48962. * @param cameras The camera to detatch from.
  48963. * @hidden
  48964. */
  48965. _detachCameras(cameras: Camera[]): void;
  48966. /**
  48967. * Enables the effect on given cameras
  48968. * @param cameras The camera to enable.
  48969. * @hidden
  48970. */
  48971. _enable(cameras: Camera): void;
  48972. /**
  48973. * Enables the effect on given cameras
  48974. * @param cameras The camera to enable.
  48975. * @hidden
  48976. */
  48977. _enable(cameras: Nullable<Camera[]>): void;
  48978. /**
  48979. * Disables the effect on the given cameras
  48980. * @param cameras The camera to disable.
  48981. * @hidden
  48982. */
  48983. _disable(cameras: Camera): void;
  48984. /**
  48985. * Disables the effect on the given cameras
  48986. * @param cameras The camera to disable.
  48987. * @hidden
  48988. */
  48989. _disable(cameras: Nullable<Camera[]>): void;
  48990. /**
  48991. * Gets a list of the post processes contained in the effect.
  48992. * @param camera The camera to get the post processes on.
  48993. * @returns The list of the post processes in the effect.
  48994. */
  48995. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48996. }
  48997. }
  48998. declare module BABYLON {
  48999. /**
  49000. * PostProcessRenderPipeline
  49001. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49002. */
  49003. class PostProcessRenderPipeline {
  49004. private engine;
  49005. private _renderEffects;
  49006. private _renderEffectsForIsolatedPass;
  49007. /**
  49008. * @hidden
  49009. */
  49010. protected _cameras: Camera[];
  49011. /** @hidden */
  49012. _name: string;
  49013. /**
  49014. * Initializes a PostProcessRenderPipeline
  49015. * @param engine engine to add the pipeline to
  49016. * @param name name of the pipeline
  49017. */
  49018. constructor(engine: Engine, name: string);
  49019. /**
  49020. * "PostProcessRenderPipeline"
  49021. * @returns "PostProcessRenderPipeline"
  49022. */
  49023. getClassName(): string;
  49024. /**
  49025. * If all the render effects in the pipeline are support
  49026. */
  49027. readonly isSupported: boolean;
  49028. /**
  49029. * Adds an effect to the pipeline
  49030. * @param renderEffect the effect to add
  49031. */
  49032. addEffect(renderEffect: PostProcessRenderEffect): void;
  49033. /** @hidden */
  49034. _rebuild(): void;
  49035. /** @hidden */
  49036. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49037. /** @hidden */
  49038. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49039. /** @hidden */
  49040. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49041. /** @hidden */
  49042. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49043. /** @hidden */
  49044. _attachCameras(cameras: Camera, unique: boolean): void;
  49045. /** @hidden */
  49046. _attachCameras(cameras: Camera[], unique: boolean): void;
  49047. /** @hidden */
  49048. _detachCameras(cameras: Camera): void;
  49049. /** @hidden */
  49050. _detachCameras(cameras: Nullable<Camera[]>): void;
  49051. /** @hidden */
  49052. _update(): void;
  49053. /** @hidden */
  49054. _reset(): void;
  49055. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49056. /**
  49057. * Disposes of the pipeline
  49058. */
  49059. dispose(): void;
  49060. }
  49061. }
  49062. declare module BABYLON {
  49063. /**
  49064. * PostProcessRenderPipelineManager class
  49065. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49066. */
  49067. class PostProcessRenderPipelineManager {
  49068. private _renderPipelines;
  49069. /**
  49070. * Initializes a PostProcessRenderPipelineManager
  49071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49072. */
  49073. constructor();
  49074. /**
  49075. * Adds a pipeline to the manager
  49076. * @param renderPipeline The pipeline to add
  49077. */
  49078. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49079. /**
  49080. * Attaches a camera to the pipeline
  49081. * @param renderPipelineName The name of the pipeline to attach to
  49082. * @param cameras the camera to attach
  49083. * @param unique if the camera can be attached multiple times to the pipeline
  49084. */
  49085. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49086. /**
  49087. * Detaches a camera from the pipeline
  49088. * @param renderPipelineName The name of the pipeline to detach from
  49089. * @param cameras the camera to detach
  49090. */
  49091. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49092. /**
  49093. * Enables an effect by name on a pipeline
  49094. * @param renderPipelineName the name of the pipeline to enable the effect in
  49095. * @param renderEffectName the name of the effect to enable
  49096. * @param cameras the cameras that the effect should be enabled on
  49097. */
  49098. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49099. /**
  49100. * Disables an effect by name on a pipeline
  49101. * @param renderPipelineName the name of the pipeline to disable the effect in
  49102. * @param renderEffectName the name of the effect to disable
  49103. * @param cameras the cameras that the effect should be disabled on
  49104. */
  49105. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49106. /**
  49107. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49108. */
  49109. update(): void;
  49110. /** @hidden */
  49111. _rebuild(): void;
  49112. /**
  49113. * Disposes of the manager and pipelines
  49114. */
  49115. dispose(): void;
  49116. }
  49117. }
  49118. declare module BABYLON {
  49119. interface Scene {
  49120. /** @hidden (Backing field) */
  49121. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49122. /**
  49123. * Gets the postprocess render pipeline manager
  49124. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49125. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49126. */
  49127. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49128. }
  49129. /**
  49130. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49131. */
  49132. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49133. /**
  49134. * The component name helpfull to identify the component in the list of scene components.
  49135. */
  49136. readonly name: string;
  49137. /**
  49138. * The scene the component belongs to.
  49139. */
  49140. scene: Scene;
  49141. /**
  49142. * Creates a new instance of the component for the given scene
  49143. * @param scene Defines the scene to register the component in
  49144. */
  49145. constructor(scene: Scene);
  49146. /**
  49147. * Registers the component in a given scene
  49148. */
  49149. register(): void;
  49150. /**
  49151. * Rebuilds the elements related to this component in case of
  49152. * context lost for instance.
  49153. */
  49154. rebuild(): void;
  49155. /**
  49156. * Disposes the component and the associated ressources
  49157. */
  49158. dispose(): void;
  49159. private _gatherRenderTargets;
  49160. }
  49161. }
  49162. declare module BABYLON {
  49163. /**
  49164. * Helper class dealing with the extraction of spherical polynomial dataArray
  49165. * from a cube map.
  49166. */
  49167. class CubeMapToSphericalPolynomialTools {
  49168. private static FileFaces;
  49169. /**
  49170. * Converts a texture to the according Spherical Polynomial data.
  49171. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49172. *
  49173. * @param texture The texture to extract the information from.
  49174. * @return The Spherical Polynomial data.
  49175. */
  49176. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49177. /**
  49178. * Converts a cubemap to the according Spherical Polynomial data.
  49179. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49180. *
  49181. * @param cubeInfo The Cube map to extract the information from.
  49182. * @return The Spherical Polynomial data.
  49183. */
  49184. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49185. }
  49186. }
  49187. declare module BABYLON {
  49188. /**
  49189. * Header information of HDR texture files.
  49190. */
  49191. interface HDRInfo {
  49192. /**
  49193. * The height of the texture in pixels.
  49194. */
  49195. height: number;
  49196. /**
  49197. * The width of the texture in pixels.
  49198. */
  49199. width: number;
  49200. /**
  49201. * The index of the beginning of the data in the binary file.
  49202. */
  49203. dataPosition: number;
  49204. }
  49205. /**
  49206. * This groups tools to convert HDR texture to native colors array.
  49207. */
  49208. class HDRTools {
  49209. private static Ldexp;
  49210. private static Rgbe2float;
  49211. private static readStringLine;
  49212. /**
  49213. * Reads header information from an RGBE texture stored in a native array.
  49214. * More information on this format are available here:
  49215. * https://en.wikipedia.org/wiki/RGBE_image_format
  49216. *
  49217. * @param uint8array The binary file stored in native array.
  49218. * @return The header information.
  49219. */
  49220. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49221. /**
  49222. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49223. * This RGBE texture needs to store the information as a panorama.
  49224. *
  49225. * More information on this format are available here:
  49226. * https://en.wikipedia.org/wiki/RGBE_image_format
  49227. *
  49228. * @param buffer The binary file stored in an array buffer.
  49229. * @param size The expected size of the extracted cubemap.
  49230. * @return The Cube Map information.
  49231. */
  49232. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49233. /**
  49234. * Returns the pixels data extracted from an RGBE texture.
  49235. * This pixels will be stored left to right up to down in the R G B order in one array.
  49236. *
  49237. * More information on this format are available here:
  49238. * https://en.wikipedia.org/wiki/RGBE_image_format
  49239. *
  49240. * @param uint8array The binary file stored in an array buffer.
  49241. * @param hdrInfo The header information of the file.
  49242. * @return The pixels data in RGB right to left up to down order.
  49243. */
  49244. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49245. private static RGBE_ReadPixels_RLE;
  49246. }
  49247. }
  49248. declare module BABYLON {
  49249. /**
  49250. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49251. */
  49252. interface CubeMapInfo {
  49253. /**
  49254. * The pixel array for the front face.
  49255. * This is stored in format, left to right, up to down format.
  49256. */
  49257. front: Nullable<ArrayBufferView>;
  49258. /**
  49259. * The pixel array for the back face.
  49260. * This is stored in format, left to right, up to down format.
  49261. */
  49262. back: Nullable<ArrayBufferView>;
  49263. /**
  49264. * The pixel array for the left face.
  49265. * This is stored in format, left to right, up to down format.
  49266. */
  49267. left: Nullable<ArrayBufferView>;
  49268. /**
  49269. * The pixel array for the right face.
  49270. * This is stored in format, left to right, up to down format.
  49271. */
  49272. right: Nullable<ArrayBufferView>;
  49273. /**
  49274. * The pixel array for the up face.
  49275. * This is stored in format, left to right, up to down format.
  49276. */
  49277. up: Nullable<ArrayBufferView>;
  49278. /**
  49279. * The pixel array for the down face.
  49280. * This is stored in format, left to right, up to down format.
  49281. */
  49282. down: Nullable<ArrayBufferView>;
  49283. /**
  49284. * The size of the cubemap stored.
  49285. *
  49286. * Each faces will be size * size pixels.
  49287. */
  49288. size: number;
  49289. /**
  49290. * The format of the texture.
  49291. *
  49292. * RGBA, RGB.
  49293. */
  49294. format: number;
  49295. /**
  49296. * The type of the texture data.
  49297. *
  49298. * UNSIGNED_INT, FLOAT.
  49299. */
  49300. type: number;
  49301. /**
  49302. * Specifies whether the texture is in gamma space.
  49303. */
  49304. gammaSpace: boolean;
  49305. }
  49306. /**
  49307. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49308. */
  49309. class PanoramaToCubeMapTools {
  49310. private static FACE_FRONT;
  49311. private static FACE_BACK;
  49312. private static FACE_RIGHT;
  49313. private static FACE_LEFT;
  49314. private static FACE_DOWN;
  49315. private static FACE_UP;
  49316. /**
  49317. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49318. *
  49319. * @param float32Array The source data.
  49320. * @param inputWidth The width of the input panorama.
  49321. * @param inputHeight The height of the input panorama.
  49322. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49323. * @return The cubemap data
  49324. */
  49325. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49326. private static CreateCubemapTexture;
  49327. private static CalcProjectionSpherical;
  49328. }
  49329. }
  49330. declare module BABYLON {
  49331. }
  49332. declare module BABYLON {
  49333. }
  49334. declare module BABYLON {
  49335. }
  49336. declare module BABYLON {
  49337. }
  49338. declare module BABYLON {
  49339. /**
  49340. * 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.
  49341. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49342. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49343. */
  49344. class CustomProceduralTexture extends ProceduralTexture {
  49345. private _animate;
  49346. private _time;
  49347. private _config;
  49348. private _texturePath;
  49349. /**
  49350. * Instantiates a new Custom Procedural Texture.
  49351. * 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.
  49352. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49353. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49354. * @param name Define the name of the texture
  49355. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49356. * @param size Define the size of the texture to create
  49357. * @param scene Define the scene the texture belongs to
  49358. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49359. * @param generateMipMaps Define if the texture should creates mip maps or not
  49360. */
  49361. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49362. private _loadJson;
  49363. /**
  49364. * Is the texture ready to be used ? (rendered at least once)
  49365. * @returns true if ready, otherwise, false.
  49366. */
  49367. isReady(): boolean;
  49368. /**
  49369. * Render the texture to its associated render target.
  49370. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49371. */
  49372. render(useCameraPostProcess?: boolean): void;
  49373. /**
  49374. * Update the list of dependant textures samplers in the shader.
  49375. */
  49376. updateTextures(): void;
  49377. /**
  49378. * Update the uniform values of the procedural texture in the shader.
  49379. */
  49380. updateShaderUniforms(): void;
  49381. /**
  49382. * Define if the texture animates or not.
  49383. */
  49384. animate: boolean;
  49385. }
  49386. }
  49387. declare module BABYLON {
  49388. /**
  49389. * Class used to generate noise procedural textures
  49390. */
  49391. class NoiseProceduralTexture extends ProceduralTexture {
  49392. private _time;
  49393. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49394. brightness: number;
  49395. /** Defines the number of octaves to process */
  49396. octaves: number;
  49397. /** Defines the level of persistence (0.8 by default) */
  49398. persistence: number;
  49399. /** Gets or sets animation speed factor (default is 1) */
  49400. animationSpeedFactor: number;
  49401. /**
  49402. * Creates a new NoiseProceduralTexture
  49403. * @param name defines the name fo the texture
  49404. * @param size defines the size of the texture (default is 256)
  49405. * @param scene defines the hosting scene
  49406. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49407. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49408. */
  49409. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49410. private _updateShaderUniforms;
  49411. protected _getDefines(): string;
  49412. /** Generate the current state of the procedural texture */
  49413. render(useCameraPostProcess?: boolean): void;
  49414. /**
  49415. * Serializes this noise procedural texture
  49416. * @returns a serialized noise procedural texture object
  49417. */
  49418. serialize(): any;
  49419. /**
  49420. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49421. * @param parsedTexture defines parsed texture data
  49422. * @param scene defines the current scene
  49423. * @param rootUrl defines the root URL containing noise procedural texture information
  49424. * @returns a parsed NoiseProceduralTexture
  49425. */
  49426. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49427. }
  49428. }
  49429. declare module BABYLON {
  49430. /**
  49431. * 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.
  49432. * This is the base class of any Procedural texture and contains most of the shareable code.
  49433. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49434. */
  49435. class ProceduralTexture extends Texture {
  49436. isCube: boolean;
  49437. /**
  49438. * Define if the texture is enabled or not (disabled texture will not render)
  49439. */
  49440. isEnabled: boolean;
  49441. /**
  49442. * Define if the texture must be cleared before rendering (default is true)
  49443. */
  49444. autoClear: boolean;
  49445. /**
  49446. * Callback called when the texture is generated
  49447. */
  49448. onGenerated: () => void;
  49449. /**
  49450. * Event raised when the texture is generated
  49451. */
  49452. onGeneratedObservable: Observable<ProceduralTexture>;
  49453. /** @hidden */
  49454. _generateMipMaps: boolean;
  49455. /** @hidden **/
  49456. _effect: Effect;
  49457. /** @hidden */
  49458. _textures: {
  49459. [key: string]: Texture;
  49460. };
  49461. private _size;
  49462. private _currentRefreshId;
  49463. private _refreshRate;
  49464. private _vertexBuffers;
  49465. private _indexBuffer;
  49466. private _uniforms;
  49467. private _samplers;
  49468. private _fragment;
  49469. private _floats;
  49470. private _ints;
  49471. private _floatsArrays;
  49472. private _colors3;
  49473. private _colors4;
  49474. private _vectors2;
  49475. private _vectors3;
  49476. private _matrices;
  49477. private _fallbackTexture;
  49478. private _fallbackTextureUsed;
  49479. private _engine;
  49480. private _cachedDefines;
  49481. private _contentUpdateId;
  49482. private _contentData;
  49483. /**
  49484. * Instantiates a new procedural texture.
  49485. * 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.
  49486. * This is the base class of any Procedural texture and contains most of the shareable code.
  49487. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49488. * @param name Define the name of the texture
  49489. * @param size Define the size of the texture to create
  49490. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49491. * @param scene Define the scene the texture belongs to
  49492. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49493. * @param generateMipMaps Define if the texture should creates mip maps or not
  49494. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49495. */
  49496. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49497. /**
  49498. * The effect that is created when initializing the post process.
  49499. * @returns The created effect corrisponding the the postprocess.
  49500. */
  49501. getEffect(): Effect;
  49502. /**
  49503. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49504. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49505. */
  49506. getContent(): Nullable<ArrayBufferView>;
  49507. private _createIndexBuffer;
  49508. /** @hidden */
  49509. _rebuild(): void;
  49510. /**
  49511. * Resets the texture in order to recreate its associated resources.
  49512. * This can be called in case of context loss
  49513. */
  49514. reset(): void;
  49515. protected _getDefines(): string;
  49516. /**
  49517. * Is the texture ready to be used ? (rendered at least once)
  49518. * @returns true if ready, otherwise, false.
  49519. */
  49520. isReady(): boolean;
  49521. /**
  49522. * Resets the refresh counter of the texture and start bak from scratch.
  49523. * Could be usefull to regenerate the texture if it is setup to render only once.
  49524. */
  49525. resetRefreshCounter(): void;
  49526. /**
  49527. * Set the fragment shader to use in order to render the texture.
  49528. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49529. */
  49530. setFragment(fragment: any): void;
  49531. /**
  49532. * Define the refresh rate of the texture or the rendering frequency.
  49533. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49534. */
  49535. refreshRate: number;
  49536. /** @hidden */
  49537. _shouldRender(): boolean;
  49538. /**
  49539. * Get the size the texture is rendering at.
  49540. * @returns the size (texture is always squared)
  49541. */
  49542. getRenderSize(): number;
  49543. /**
  49544. * Resize the texture to new value.
  49545. * @param size Define the new size the texture should have
  49546. * @param generateMipMaps Define whether the new texture should create mip maps
  49547. */
  49548. resize(size: number, generateMipMaps: boolean): void;
  49549. private _checkUniform;
  49550. /**
  49551. * Set a texture in the shader program used to render.
  49552. * @param name Define the name of the uniform samplers as defined in the shader
  49553. * @param texture Define the texture to bind to this sampler
  49554. * @return the texture itself allowing "fluent" like uniform updates
  49555. */
  49556. setTexture(name: string, texture: Texture): ProceduralTexture;
  49557. /**
  49558. * Set a float in the shader.
  49559. * @param name Define the name of the uniform as defined in the shader
  49560. * @param value Define the value to give to the uniform
  49561. * @return the texture itself allowing "fluent" like uniform updates
  49562. */
  49563. setFloat(name: string, value: number): ProceduralTexture;
  49564. /**
  49565. * Set a int in the shader.
  49566. * @param name Define the name of the uniform as defined in the shader
  49567. * @param value Define the value to give to the uniform
  49568. * @return the texture itself allowing "fluent" like uniform updates
  49569. */
  49570. setInt(name: string, value: number): ProceduralTexture;
  49571. /**
  49572. * Set an array of floats in the shader.
  49573. * @param name Define the name of the uniform as defined in the shader
  49574. * @param value Define the value to give to the uniform
  49575. * @return the texture itself allowing "fluent" like uniform updates
  49576. */
  49577. setFloats(name: string, value: number[]): ProceduralTexture;
  49578. /**
  49579. * Set a vec3 in the shader from a Color3.
  49580. * @param name Define the name of the uniform as defined in the shader
  49581. * @param value Define the value to give to the uniform
  49582. * @return the texture itself allowing "fluent" like uniform updates
  49583. */
  49584. setColor3(name: string, value: Color3): ProceduralTexture;
  49585. /**
  49586. * Set a vec4 in the shader from a Color4.
  49587. * @param name Define the name of the uniform as defined in the shader
  49588. * @param value Define the value to give to the uniform
  49589. * @return the texture itself allowing "fluent" like uniform updates
  49590. */
  49591. setColor4(name: string, value: Color4): ProceduralTexture;
  49592. /**
  49593. * Set a vec2 in the shader from a Vector2.
  49594. * @param name Define the name of the uniform as defined in the shader
  49595. * @param value Define the value to give to the uniform
  49596. * @return the texture itself allowing "fluent" like uniform updates
  49597. */
  49598. setVector2(name: string, value: Vector2): ProceduralTexture;
  49599. /**
  49600. * Set a vec3 in the shader from a Vector3.
  49601. * @param name Define the name of the uniform as defined in the shader
  49602. * @param value Define the value to give to the uniform
  49603. * @return the texture itself allowing "fluent" like uniform updates
  49604. */
  49605. setVector3(name: string, value: Vector3): ProceduralTexture;
  49606. /**
  49607. * Set a mat4 in the shader from a MAtrix.
  49608. * @param name Define the name of the uniform as defined in the shader
  49609. * @param value Define the value to give to the uniform
  49610. * @return the texture itself allowing "fluent" like uniform updates
  49611. */
  49612. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49613. /**
  49614. * Render the texture to its associated render target.
  49615. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49616. */
  49617. render(useCameraPostProcess?: boolean): void;
  49618. /**
  49619. * Clone the texture.
  49620. * @returns the cloned texture
  49621. */
  49622. clone(): ProceduralTexture;
  49623. /**
  49624. * Dispose the texture and release its asoociated resources.
  49625. */
  49626. dispose(): void;
  49627. }
  49628. }
  49629. declare module BABYLON {
  49630. interface AbstractScene {
  49631. /**
  49632. * The list of procedural textures added to the scene
  49633. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49634. */
  49635. proceduralTextures: Array<ProceduralTexture>;
  49636. }
  49637. /**
  49638. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49639. * in a given scene.
  49640. */
  49641. class ProceduralTextureSceneComponent implements ISceneComponent {
  49642. /**
  49643. * The component name helpfull to identify the component in the list of scene components.
  49644. */
  49645. readonly name: string;
  49646. /**
  49647. * The scene the component belongs to.
  49648. */
  49649. scene: Scene;
  49650. /**
  49651. * Creates a new instance of the component for the given scene
  49652. * @param scene Defines the scene to register the component in
  49653. */
  49654. constructor(scene: Scene);
  49655. /**
  49656. * Registers the component in a given scene
  49657. */
  49658. register(): void;
  49659. /**
  49660. * Rebuilds the elements related to this component in case of
  49661. * context lost for instance.
  49662. */
  49663. rebuild(): void;
  49664. /**
  49665. * Disposes the component and the associated ressources.
  49666. */
  49667. dispose(): void;
  49668. private _beforeClear;
  49669. }
  49670. }
  49671. declare module BABYLON {
  49672. /**
  49673. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49674. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49675. */
  49676. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49677. private _scene;
  49678. private _camerasToBeAttached;
  49679. /**
  49680. * ID of the sharpen post process,
  49681. */
  49682. private readonly SharpenPostProcessId;
  49683. /**
  49684. * @ignore
  49685. * ID of the image processing post process;
  49686. */
  49687. readonly ImageProcessingPostProcessId: string;
  49688. /**
  49689. * @ignore
  49690. * ID of the Fast Approximate Anti-Aliasing post process;
  49691. */
  49692. readonly FxaaPostProcessId: string;
  49693. /**
  49694. * ID of the chromatic aberration post process,
  49695. */
  49696. private readonly ChromaticAberrationPostProcessId;
  49697. /**
  49698. * ID of the grain post process
  49699. */
  49700. private readonly GrainPostProcessId;
  49701. /**
  49702. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49703. */
  49704. sharpen: SharpenPostProcess;
  49705. private _sharpenEffect;
  49706. private bloom;
  49707. /**
  49708. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49709. */
  49710. depthOfField: DepthOfFieldEffect;
  49711. /**
  49712. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49713. */
  49714. fxaa: FxaaPostProcess;
  49715. /**
  49716. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49717. */
  49718. imageProcessing: ImageProcessingPostProcess;
  49719. /**
  49720. * Chromatic aberration post process which will shift rgb colors in the image
  49721. */
  49722. chromaticAberration: ChromaticAberrationPostProcess;
  49723. private _chromaticAberrationEffect;
  49724. /**
  49725. * Grain post process which add noise to the image
  49726. */
  49727. grain: GrainPostProcess;
  49728. private _grainEffect;
  49729. /**
  49730. * Glow post process which adds a glow to emmisive areas of the image
  49731. */
  49732. private _glowLayer;
  49733. /**
  49734. * Animations which can be used to tweak settings over a period of time
  49735. */
  49736. animations: Animation[];
  49737. private _imageProcessingConfigurationObserver;
  49738. private _sharpenEnabled;
  49739. private _bloomEnabled;
  49740. private _depthOfFieldEnabled;
  49741. private _depthOfFieldBlurLevel;
  49742. private _fxaaEnabled;
  49743. private _imageProcessingEnabled;
  49744. private _defaultPipelineTextureType;
  49745. private _bloomScale;
  49746. private _chromaticAberrationEnabled;
  49747. private _grainEnabled;
  49748. private _buildAllowed;
  49749. /**
  49750. * Enable or disable the sharpen process from the pipeline
  49751. */
  49752. sharpenEnabled: boolean;
  49753. private _resizeObserver;
  49754. private _hardwareScaleLevel;
  49755. private _bloomKernel;
  49756. /**
  49757. * Specifies the size of the bloom blur kernel, relative to the final output size
  49758. */
  49759. bloomKernel: number;
  49760. /**
  49761. * Specifies the weight of the bloom in the final rendering
  49762. */
  49763. private _bloomWeight;
  49764. /**
  49765. * Specifies the luma threshold for the area that will be blurred by the bloom
  49766. */
  49767. private _bloomThreshold;
  49768. private _hdr;
  49769. /**
  49770. * The strength of the bloom.
  49771. */
  49772. bloomWeight: number;
  49773. /**
  49774. * The strength of the bloom.
  49775. */
  49776. bloomThreshold: number;
  49777. /**
  49778. * The scale of the bloom, lower value will provide better performance.
  49779. */
  49780. bloomScale: number;
  49781. /**
  49782. * Enable or disable the bloom from the pipeline
  49783. */
  49784. bloomEnabled: boolean;
  49785. private _rebuildBloom;
  49786. /**
  49787. * If the depth of field is enabled.
  49788. */
  49789. depthOfFieldEnabled: boolean;
  49790. /**
  49791. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49792. */
  49793. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49794. /**
  49795. * If the anti aliasing is enabled.
  49796. */
  49797. fxaaEnabled: boolean;
  49798. private _samples;
  49799. /**
  49800. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49801. */
  49802. samples: number;
  49803. /**
  49804. * If image processing is enabled.
  49805. */
  49806. imageProcessingEnabled: boolean;
  49807. /**
  49808. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49809. */
  49810. glowLayerEnabled: boolean;
  49811. /**
  49812. * Enable or disable the chromaticAberration process from the pipeline
  49813. */
  49814. chromaticAberrationEnabled: boolean;
  49815. /**
  49816. * Enable or disable the grain process from the pipeline
  49817. */
  49818. grainEnabled: boolean;
  49819. /**
  49820. * @constructor
  49821. * @param name - The rendering pipeline name (default: "")
  49822. * @param hdr - If high dynamic range textures should be used (default: true)
  49823. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49824. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49825. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49826. */
  49827. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49828. /**
  49829. * Force the compilation of the entire pipeline.
  49830. */
  49831. prepare(): void;
  49832. private _hasCleared;
  49833. private _prevPostProcess;
  49834. private _prevPrevPostProcess;
  49835. private _setAutoClearAndTextureSharing;
  49836. private _depthOfFieldSceneObserver;
  49837. private _buildPipeline;
  49838. private _disposePostProcesses;
  49839. /**
  49840. * Adds a camera to the pipeline
  49841. * @param camera the camera to be added
  49842. */
  49843. addCamera(camera: Camera): void;
  49844. /**
  49845. * Removes a camera from the pipeline
  49846. * @param camera the camera to remove
  49847. */
  49848. removeCamera(camera: Camera): void;
  49849. /**
  49850. * Dispose of the pipeline and stop all post processes
  49851. */
  49852. dispose(): void;
  49853. /**
  49854. * Serialize the rendering pipeline (Used when exporting)
  49855. * @returns the serialized object
  49856. */
  49857. serialize(): any;
  49858. /**
  49859. * Parse the serialized pipeline
  49860. * @param source Source pipeline.
  49861. * @param scene The scene to load the pipeline to.
  49862. * @param rootUrl The URL of the serialized pipeline.
  49863. * @returns An instantiated pipeline from the serialized object.
  49864. */
  49865. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49866. }
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * BABYLON.JS Chromatic Aberration GLSL Shader
  49871. * Author: Olivier Guyot
  49872. * Separates very slightly R, G and B colors on the edges of the screen
  49873. * Inspired by Francois Tarlier & Martins Upitis
  49874. */
  49875. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49876. /**
  49877. * @ignore
  49878. * The chromatic aberration PostProcess id in the pipeline
  49879. */
  49880. LensChromaticAberrationEffect: string;
  49881. /**
  49882. * @ignore
  49883. * The highlights enhancing PostProcess id in the pipeline
  49884. */
  49885. HighlightsEnhancingEffect: string;
  49886. /**
  49887. * @ignore
  49888. * The depth-of-field PostProcess id in the pipeline
  49889. */
  49890. LensDepthOfFieldEffect: string;
  49891. private _scene;
  49892. private _depthTexture;
  49893. private _grainTexture;
  49894. private _chromaticAberrationPostProcess;
  49895. private _highlightsPostProcess;
  49896. private _depthOfFieldPostProcess;
  49897. private _edgeBlur;
  49898. private _grainAmount;
  49899. private _chromaticAberration;
  49900. private _distortion;
  49901. private _highlightsGain;
  49902. private _highlightsThreshold;
  49903. private _dofDistance;
  49904. private _dofAperture;
  49905. private _dofDarken;
  49906. private _dofPentagon;
  49907. private _blurNoise;
  49908. /**
  49909. * @constructor
  49910. *
  49911. * Effect parameters are as follow:
  49912. * {
  49913. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49914. * edge_blur: number; // from 0 to x (1 for realism)
  49915. * distortion: number; // from 0 to x (1 for realism)
  49916. * grain_amount: number; // from 0 to 1
  49917. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49918. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49919. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49920. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49921. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49922. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49923. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49924. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49925. * }
  49926. * Note: if an effect parameter is unset, effect is disabled
  49927. *
  49928. * @param name The rendering pipeline name
  49929. * @param parameters - An object containing all parameters (see above)
  49930. * @param scene The scene linked to this pipeline
  49931. * @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)
  49932. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49933. */
  49934. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49935. /**
  49936. * Sets the amount of blur at the edges
  49937. * @param amount blur amount
  49938. */
  49939. setEdgeBlur(amount: number): void;
  49940. /**
  49941. * Sets edge blur to 0
  49942. */
  49943. disableEdgeBlur(): void;
  49944. /**
  49945. * Sets the amout of grain
  49946. * @param amount Amount of grain
  49947. */
  49948. setGrainAmount(amount: number): void;
  49949. /**
  49950. * Set grain amount to 0
  49951. */
  49952. disableGrain(): void;
  49953. /**
  49954. * Sets the chromatic aberration amount
  49955. * @param amount amount of chromatic aberration
  49956. */
  49957. setChromaticAberration(amount: number): void;
  49958. /**
  49959. * Sets chromatic aberration amount to 0
  49960. */
  49961. disableChromaticAberration(): void;
  49962. /**
  49963. * Sets the EdgeDistortion amount
  49964. * @param amount amount of EdgeDistortion
  49965. */
  49966. setEdgeDistortion(amount: number): void;
  49967. /**
  49968. * Sets edge distortion to 0
  49969. */
  49970. disableEdgeDistortion(): void;
  49971. /**
  49972. * Sets the FocusDistance amount
  49973. * @param amount amount of FocusDistance
  49974. */
  49975. setFocusDistance(amount: number): void;
  49976. /**
  49977. * Disables depth of field
  49978. */
  49979. disableDepthOfField(): void;
  49980. /**
  49981. * Sets the Aperture amount
  49982. * @param amount amount of Aperture
  49983. */
  49984. setAperture(amount: number): void;
  49985. /**
  49986. * Sets the DarkenOutOfFocus amount
  49987. * @param amount amount of DarkenOutOfFocus
  49988. */
  49989. setDarkenOutOfFocus(amount: number): void;
  49990. /**
  49991. * Creates a pentagon bokeh effect
  49992. */
  49993. enablePentagonBokeh(): void;
  49994. /**
  49995. * Disables the pentagon bokeh effect
  49996. */
  49997. disablePentagonBokeh(): void;
  49998. /**
  49999. * Enables noise blur
  50000. */
  50001. enableNoiseBlur(): void;
  50002. /**
  50003. * Disables noise blur
  50004. */
  50005. disableNoiseBlur(): void;
  50006. /**
  50007. * Sets the HighlightsGain amount
  50008. * @param amount amount of HighlightsGain
  50009. */
  50010. setHighlightsGain(amount: number): void;
  50011. /**
  50012. * Sets the HighlightsThreshold amount
  50013. * @param amount amount of HighlightsThreshold
  50014. */
  50015. setHighlightsThreshold(amount: number): void;
  50016. /**
  50017. * Disables highlights
  50018. */
  50019. disableHighlights(): void;
  50020. /**
  50021. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50022. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50023. */
  50024. dispose(disableDepthRender?: boolean): void;
  50025. private _createChromaticAberrationPostProcess;
  50026. private _createHighlightsPostProcess;
  50027. private _createDepthOfFieldPostProcess;
  50028. private _createGrainTexture;
  50029. }
  50030. }
  50031. declare module BABYLON {
  50032. /**
  50033. * Render pipeline to produce ssao effect
  50034. */
  50035. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50036. /**
  50037. * @ignore
  50038. * The PassPostProcess id in the pipeline that contains the original scene color
  50039. */
  50040. SSAOOriginalSceneColorEffect: string;
  50041. /**
  50042. * @ignore
  50043. * The SSAO PostProcess id in the pipeline
  50044. */
  50045. SSAORenderEffect: string;
  50046. /**
  50047. * @ignore
  50048. * The horizontal blur PostProcess id in the pipeline
  50049. */
  50050. SSAOBlurHRenderEffect: string;
  50051. /**
  50052. * @ignore
  50053. * The vertical blur PostProcess id in the pipeline
  50054. */
  50055. SSAOBlurVRenderEffect: string;
  50056. /**
  50057. * @ignore
  50058. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50059. */
  50060. SSAOCombineRenderEffect: string;
  50061. /**
  50062. * The output strength of the SSAO post-process. Default value is 1.0.
  50063. */
  50064. totalStrength: number;
  50065. /**
  50066. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50067. */
  50068. maxZ: number;
  50069. /**
  50070. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50071. */
  50072. minZAspect: number;
  50073. private _samples;
  50074. /**
  50075. * Number of samples used for the SSAO calculations. Default value is 8
  50076. */
  50077. samples: number;
  50078. private _textureSamples;
  50079. /**
  50080. * Number of samples to use for antialiasing
  50081. */
  50082. textureSamples: number;
  50083. /**
  50084. * Ratio object used for SSAO ratio and blur ratio
  50085. */
  50086. private _ratio;
  50087. /**
  50088. * Dynamically generated sphere sampler.
  50089. */
  50090. private _sampleSphere;
  50091. /**
  50092. * Blur filter offsets
  50093. */
  50094. private _samplerOffsets;
  50095. private _expensiveBlur;
  50096. /**
  50097. * If bilateral blur should be used
  50098. */
  50099. expensiveBlur: boolean;
  50100. /**
  50101. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50102. */
  50103. radius: number;
  50104. /**
  50105. * The base color of the SSAO post-process
  50106. * The final result is "base + ssao" between [0, 1]
  50107. */
  50108. base: number;
  50109. /**
  50110. * Support test.
  50111. */
  50112. static readonly IsSupported: boolean;
  50113. private _scene;
  50114. private _depthTexture;
  50115. private _normalTexture;
  50116. private _randomTexture;
  50117. private _originalColorPostProcess;
  50118. private _ssaoPostProcess;
  50119. private _blurHPostProcess;
  50120. private _blurVPostProcess;
  50121. private _ssaoCombinePostProcess;
  50122. private _firstUpdate;
  50123. /**
  50124. * @constructor
  50125. * @param name The rendering pipeline name
  50126. * @param scene The scene linked to this pipeline
  50127. * @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 }
  50128. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50129. */
  50130. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50131. /**
  50132. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50133. */
  50134. dispose(disableGeometryBufferRenderer?: boolean): void;
  50135. private _createBlurPostProcess;
  50136. /** @hidden */
  50137. _rebuild(): void;
  50138. private _bits;
  50139. private _radicalInverse_VdC;
  50140. private _hammersley;
  50141. private _hemisphereSample_uniform;
  50142. private _generateHemisphere;
  50143. private _createSSAOPostProcess;
  50144. private _createSSAOCombinePostProcess;
  50145. private _createRandomTexture;
  50146. /**
  50147. * Serialize the rendering pipeline (Used when exporting)
  50148. * @returns the serialized object
  50149. */
  50150. serialize(): any;
  50151. /**
  50152. * Parse the serialized pipeline
  50153. * @param source Source pipeline.
  50154. * @param scene The scene to load the pipeline to.
  50155. * @param rootUrl The URL of the serialized pipeline.
  50156. * @returns An instantiated pipeline from the serialized object.
  50157. */
  50158. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50159. }
  50160. }
  50161. declare module BABYLON {
  50162. /**
  50163. * Render pipeline to produce ssao effect
  50164. */
  50165. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50166. /**
  50167. * @ignore
  50168. * The PassPostProcess id in the pipeline that contains the original scene color
  50169. */
  50170. SSAOOriginalSceneColorEffect: string;
  50171. /**
  50172. * @ignore
  50173. * The SSAO PostProcess id in the pipeline
  50174. */
  50175. SSAORenderEffect: string;
  50176. /**
  50177. * @ignore
  50178. * The horizontal blur PostProcess id in the pipeline
  50179. */
  50180. SSAOBlurHRenderEffect: string;
  50181. /**
  50182. * @ignore
  50183. * The vertical blur PostProcess id in the pipeline
  50184. */
  50185. SSAOBlurVRenderEffect: string;
  50186. /**
  50187. * @ignore
  50188. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50189. */
  50190. SSAOCombineRenderEffect: string;
  50191. /**
  50192. * The output strength of the SSAO post-process. Default value is 1.0.
  50193. */
  50194. totalStrength: number;
  50195. /**
  50196. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50197. */
  50198. radius: number;
  50199. /**
  50200. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50201. * Must not be equal to fallOff and superior to fallOff.
  50202. * Default value is 0.975
  50203. */
  50204. area: number;
  50205. /**
  50206. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50207. * Must not be equal to area and inferior to area.
  50208. * Default value is 0.0
  50209. */
  50210. fallOff: number;
  50211. /**
  50212. * The base color of the SSAO post-process
  50213. * The final result is "base + ssao" between [0, 1]
  50214. */
  50215. base: number;
  50216. private _scene;
  50217. private _depthTexture;
  50218. private _randomTexture;
  50219. private _originalColorPostProcess;
  50220. private _ssaoPostProcess;
  50221. private _blurHPostProcess;
  50222. private _blurVPostProcess;
  50223. private _ssaoCombinePostProcess;
  50224. private _firstUpdate;
  50225. /**
  50226. * @constructor
  50227. * @param name - The rendering pipeline name
  50228. * @param scene - The scene linked to this pipeline
  50229. * @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 }
  50230. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50231. */
  50232. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50233. /**
  50234. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50235. */
  50236. dispose(disableDepthRender?: boolean): void;
  50237. private _createBlurPostProcess;
  50238. /** @hidden */
  50239. _rebuild(): void;
  50240. private _createSSAOPostProcess;
  50241. private _createSSAOCombinePostProcess;
  50242. private _createRandomTexture;
  50243. }
  50244. }
  50245. declare module BABYLON {
  50246. /**
  50247. * Standard rendering pipeline
  50248. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50249. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50250. */
  50251. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50252. /**
  50253. * Public members
  50254. */
  50255. /**
  50256. * Post-process which contains the original scene color before the pipeline applies all the effects
  50257. */
  50258. originalPostProcess: Nullable<PostProcess>;
  50259. /**
  50260. * Post-process used to down scale an image x4
  50261. */
  50262. downSampleX4PostProcess: Nullable<PostProcess>;
  50263. /**
  50264. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50265. */
  50266. brightPassPostProcess: Nullable<PostProcess>;
  50267. /**
  50268. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50269. */
  50270. blurHPostProcesses: PostProcess[];
  50271. /**
  50272. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50273. */
  50274. blurVPostProcesses: PostProcess[];
  50275. /**
  50276. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50277. */
  50278. textureAdderPostProcess: Nullable<PostProcess>;
  50279. /**
  50280. * Post-process used to create volumetric lighting effect
  50281. */
  50282. volumetricLightPostProcess: Nullable<PostProcess>;
  50283. /**
  50284. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50285. */
  50286. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50287. /**
  50288. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50289. */
  50290. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50291. /**
  50292. * Post-process used to merge the volumetric light effect and the real scene color
  50293. */
  50294. volumetricLightMergePostProces: Nullable<PostProcess>;
  50295. /**
  50296. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50297. */
  50298. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50299. /**
  50300. * Base post-process used to calculate the average luminance of the final image for HDR
  50301. */
  50302. luminancePostProcess: Nullable<PostProcess>;
  50303. /**
  50304. * Post-processes used to create down sample post-processes in order to get
  50305. * the average luminance of the final image for HDR
  50306. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50307. */
  50308. luminanceDownSamplePostProcesses: PostProcess[];
  50309. /**
  50310. * Post-process used to create a HDR effect (light adaptation)
  50311. */
  50312. hdrPostProcess: Nullable<PostProcess>;
  50313. /**
  50314. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50315. */
  50316. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50317. /**
  50318. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50319. */
  50320. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50321. /**
  50322. * Post-process used to merge the final HDR post-process and the real scene color
  50323. */
  50324. hdrFinalPostProcess: Nullable<PostProcess>;
  50325. /**
  50326. * Post-process used to create a lens flare effect
  50327. */
  50328. lensFlarePostProcess: Nullable<PostProcess>;
  50329. /**
  50330. * Post-process that merges the result of the lens flare post-process and the real scene color
  50331. */
  50332. lensFlareComposePostProcess: Nullable<PostProcess>;
  50333. /**
  50334. * Post-process used to create a motion blur effect
  50335. */
  50336. motionBlurPostProcess: Nullable<PostProcess>;
  50337. /**
  50338. * Post-process used to create a depth of field effect
  50339. */
  50340. depthOfFieldPostProcess: Nullable<PostProcess>;
  50341. /**
  50342. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50343. */
  50344. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50345. /**
  50346. * Represents the brightness threshold in order to configure the illuminated surfaces
  50347. */
  50348. brightThreshold: number;
  50349. /**
  50350. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50351. */
  50352. blurWidth: number;
  50353. /**
  50354. * Sets if the blur for highlighted surfaces must be only horizontal
  50355. */
  50356. horizontalBlur: boolean;
  50357. /**
  50358. * Sets the overall exposure used by the pipeline
  50359. */
  50360. exposure: number;
  50361. /**
  50362. * Texture used typically to simulate "dirty" on camera lens
  50363. */
  50364. lensTexture: Nullable<Texture>;
  50365. /**
  50366. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50367. */
  50368. volumetricLightCoefficient: number;
  50369. /**
  50370. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50371. */
  50372. volumetricLightPower: number;
  50373. /**
  50374. * Used the set the blur intensity to smooth the volumetric lights
  50375. */
  50376. volumetricLightBlurScale: number;
  50377. /**
  50378. * Light (spot or directional) used to generate the volumetric lights rays
  50379. * The source light must have a shadow generate so the pipeline can get its
  50380. * depth map
  50381. */
  50382. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50383. /**
  50384. * For eye adaptation, represents the minimum luminance the eye can see
  50385. */
  50386. hdrMinimumLuminance: number;
  50387. /**
  50388. * For eye adaptation, represents the decrease luminance speed
  50389. */
  50390. hdrDecreaseRate: number;
  50391. /**
  50392. * For eye adaptation, represents the increase luminance speed
  50393. */
  50394. hdrIncreaseRate: number;
  50395. /**
  50396. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50397. */
  50398. lensColorTexture: Nullable<Texture>;
  50399. /**
  50400. * The overall strengh for the lens flare effect
  50401. */
  50402. lensFlareStrength: number;
  50403. /**
  50404. * Dispersion coefficient for lens flare ghosts
  50405. */
  50406. lensFlareGhostDispersal: number;
  50407. /**
  50408. * Main lens flare halo width
  50409. */
  50410. lensFlareHaloWidth: number;
  50411. /**
  50412. * Based on the lens distortion effect, defines how much the lens flare result
  50413. * is distorted
  50414. */
  50415. lensFlareDistortionStrength: number;
  50416. /**
  50417. * Lens star texture must be used to simulate rays on the flares and is available
  50418. * in the documentation
  50419. */
  50420. lensStarTexture: Nullable<Texture>;
  50421. /**
  50422. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50423. * flare effect by taking account of the dirt texture
  50424. */
  50425. lensFlareDirtTexture: Nullable<Texture>;
  50426. /**
  50427. * Represents the focal length for the depth of field effect
  50428. */
  50429. depthOfFieldDistance: number;
  50430. /**
  50431. * Represents the blur intensity for the blurred part of the depth of field effect
  50432. */
  50433. depthOfFieldBlurWidth: number;
  50434. /**
  50435. * For motion blur, defines how much the image is blurred by the movement
  50436. */
  50437. motionStrength: number;
  50438. /**
  50439. * List of animations for the pipeline (IAnimatable implementation)
  50440. */
  50441. animations: Animation[];
  50442. /**
  50443. * Private members
  50444. */
  50445. private _scene;
  50446. private _currentDepthOfFieldSource;
  50447. private _basePostProcess;
  50448. private _hdrCurrentLuminance;
  50449. private _floatTextureType;
  50450. private _ratio;
  50451. private _bloomEnabled;
  50452. private _depthOfFieldEnabled;
  50453. private _vlsEnabled;
  50454. private _lensFlareEnabled;
  50455. private _hdrEnabled;
  50456. private _motionBlurEnabled;
  50457. private _fxaaEnabled;
  50458. private _motionBlurSamples;
  50459. private _volumetricLightStepsCount;
  50460. private _samples;
  50461. /**
  50462. * @ignore
  50463. * Specifies if the bloom pipeline is enabled
  50464. */
  50465. BloomEnabled: boolean;
  50466. /**
  50467. * @ignore
  50468. * Specifies if the depth of field pipeline is enabed
  50469. */
  50470. DepthOfFieldEnabled: boolean;
  50471. /**
  50472. * @ignore
  50473. * Specifies if the lens flare pipeline is enabed
  50474. */
  50475. LensFlareEnabled: boolean;
  50476. /**
  50477. * @ignore
  50478. * Specifies if the HDR pipeline is enabled
  50479. */
  50480. HDREnabled: boolean;
  50481. /**
  50482. * @ignore
  50483. * Specifies if the volumetric lights scattering effect is enabled
  50484. */
  50485. VLSEnabled: boolean;
  50486. /**
  50487. * @ignore
  50488. * Specifies if the motion blur effect is enabled
  50489. */
  50490. MotionBlurEnabled: boolean;
  50491. /**
  50492. * Specifies if anti-aliasing is enabled
  50493. */
  50494. fxaaEnabled: boolean;
  50495. /**
  50496. * Specifies the number of steps used to calculate the volumetric lights
  50497. * Typically in interval [50, 200]
  50498. */
  50499. volumetricLightStepsCount: number;
  50500. /**
  50501. * Specifies the number of samples used for the motion blur effect
  50502. * Typically in interval [16, 64]
  50503. */
  50504. motionBlurSamples: number;
  50505. /**
  50506. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50507. */
  50508. samples: number;
  50509. /**
  50510. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50511. * @constructor
  50512. * @param name The rendering pipeline name
  50513. * @param scene The scene linked to this pipeline
  50514. * @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)
  50515. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50516. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50517. */
  50518. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50519. private _buildPipeline;
  50520. private _createDownSampleX4PostProcess;
  50521. private _createBrightPassPostProcess;
  50522. private _createBlurPostProcesses;
  50523. private _createTextureAdderPostProcess;
  50524. private _createVolumetricLightPostProcess;
  50525. private _createLuminancePostProcesses;
  50526. private _createHdrPostProcess;
  50527. private _createLensFlarePostProcess;
  50528. private _createDepthOfFieldPostProcess;
  50529. private _createMotionBlurPostProcess;
  50530. private _getDepthTexture;
  50531. private _disposePostProcesses;
  50532. /**
  50533. * Dispose of the pipeline and stop all post processes
  50534. */
  50535. dispose(): void;
  50536. /**
  50537. * Serialize the rendering pipeline (Used when exporting)
  50538. * @returns the serialized object
  50539. */
  50540. serialize(): any;
  50541. /**
  50542. * Parse the serialized pipeline
  50543. * @param source Source pipeline.
  50544. * @param scene The scene to load the pipeline to.
  50545. * @param rootUrl The URL of the serialized pipeline.
  50546. * @returns An instantiated pipeline from the serialized object.
  50547. */
  50548. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50549. /**
  50550. * Luminance steps
  50551. */
  50552. static LuminanceSteps: number;
  50553. }
  50554. }